struct BlocksInfo {
id: BlockId,
succs: BTreeSet<BlockWithRank<usize>>,
flow: BTreeSet<BlockWithRank<(BigRational, isize)>>,
}
Expand description
Information used to compute the switch exits. We compute this information for every block in the graph. Note that we make sure to use immutable sets because we rely a lot on cloning.
Fields§
§id: BlockId
§succs: BTreeSet<BlockWithRank<usize>>
All the successors of the block
flow: BTreeSet<BlockWithRank<(BigRational, isize)>>
Let’s say we put a quantity of water equal to 1 on the block, and the water flows downards. Whenever there is a branching, the quantity of water gets equally divided between the branches. When the control flows join, we put the water back together. The set below computes the amount of water received by each descendant of the node.
TODO: there must be a known algorithm which computes this, right?… This is exactly this problems: https://stackoverflow.com/questions/78221666/algorithm-for-total-flow-through-weighted-directed-acyclic-graph TODO: the way I compute this is not efficient.
Remark: in order to rank the nodes, we also use the negation of the rank given by the topological order. The last elements of the set have the highest flow, that is they are the nodes to which the maximum number of paths converge. If several nodes have the same flow, we want to take the highest one in the hierarchy: hence the use of the inverse of the topological rank.
Ex.:
A -- we start here
|
|---------------------------------------
| | | |
B:(0.25,-1) C:(0.25,-2) D:(0.25,-3) E:(0.25,-4)
| | |
|--------------------------
|
F:(0.75,-5)
|
|
G:(0.75,-6)
The “best” node (with the highest (flow, rank) in the graph above is F.
Trait Implementations§
source§impl Clone for BlocksInfo
impl Clone for BlocksInfo
source§fn clone(&self) -> BlocksInfo
fn clone(&self) -> BlocksInfo
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for BlocksInfo
impl RefUnwindSafe for BlocksInfo
impl Send for BlocksInfo
impl Sync for BlocksInfo
impl Unpin for BlocksInfo
impl UnwindSafe for BlocksInfo
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<I, T> ExtractContext<I, ()> for T
impl<I, T> ExtractContext<I, ()> for T
§fn extract_context(self, _original_input: I)
fn extract_context(self, _original_input: I)
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more