Module balanced_flow

Source
Expand description

A control-flow graph can be said to have “balanced flow” if the flow (execution count) of each node is equal to the sum of its in-edge flows, and also equal to the sum of its out-edge flows.

Control-flow graphs typically have one or more nodes that don’t satisfy the balanced-flow property, e.g.:

  • The start node has out-edges, but no in-edges.
  • Return nodes have in-edges, but no out-edges.
  • Yield nodes can have an out-flow that is less than their in-flow.
  • Inescapable loops cause the in-flow/out-flow relationship to break down.

Balanced-flow graphs are nevertheless useful for analysis, so this module provides a wrapper type (BalancedFlowGraph) that imposes balanced flow on an underlying graph. This is done by non-destructively adding synthetic nodes and edges as necessary.

Structs§

BalancedFlowGraph 🔒
A view of an underlying graph that has been augmented to have “balanced flow”. This means that the flow (execution count) of each node is equal to the sum of its in-edge flows, and also equal to the sum of its out-edge flows.