本文へ移動

@eightkk/vue-weave / core / layoutFlowGraph

Function: layoutFlowGraph() ​

layoutFlowGraph<N, E>(nodes, edges, options): GraphFlowLayout

Defined in: src/core/graphFlow.ts:183

Projects quantities on the edges of a graph into a Sankey-style picture: node boxes ordered in ranks along the flow and, for each edge, a band whose width is quantity × scale on one scale for the whole picture.

Ranks come from the layered layout (layoutLayeredGraph with barycenter crossing reduction) of the forward edges. Each node box is nodeThickness long along the flow and max(inflow, outflow) × scale across it (at least minNodeSize; see GraphFlowNode.value for nodes with reference bands). Bands are stacked along a node side from its top (LR, RL) or left (TB, BT), sorted by the position of their other end, so they cross as little as possible. The totals are reported as given and never balanced: where inflow and outflow differ, the shorter stack leaves the rest of the box empty and difference says by how much.

Units are never mixed: only edges whose unit is displayUnit are drawn and summed; the others are returned in excluded. A quantity of 0 keeps its band, with thickness 0, drawn as a minBandWidth hairline.

Cycles terminate: an iterative depth-first search in input order marks the edges that close a cycle, and self-loops, as reference bands. They are routed back through lanes beside the ranks (below for LR and RL, to the right for TB and BT), drawn dashed by the renderers, and counted in referenceInflow and referenceOutflow, not in the node totals. Loops are not unrolled; to show rework as forward flow across periods, give each period its own node copies first.

Throws Error for unknown endpoints, duplicate IDs and a missing or empty unit, and RangeError for a quantity that is not a finite number of at least 0, an unknown direction and invalid sizes. The inputs are not modified.

Type Parameters ​

N ​

N extends IdentifiedNode

E ​

E extends GraphEdge<unknown>

Parameters ​

nodes ​

readonly N[]

edges ​

readonly E[]

options ​

GraphFlowOptions<N, E>

Returns ​

GraphFlowLayout

MIT ライセンスで公開しています。