mermaid.flowchart.rank.layers

mermaid.flowchart.rank

layers(graph) -> layered

Put a flowchart's nodes into layers

graph is what mermaid.flowchart.parser.parse returns.

The result:

FieldHolds
graphthe graph
nodesa layout node per graph node, in the graph's order
layersthe layout nodes of each layer, dummies included
edges{ edge, from, to, reversed, chain, from_sub, to_sub }
loops{ node, edge } for each edge from a node to itself
clusters{ sub, path, lo, hi, left, right } for each subgraph that holds a node

A layout node is { id, kind, rank, path, up, down }. kind is "node", "dummy", "label" or "border". path lists the subgraphs the node lies in, the outermost first. up and down list the nodes it is linked to in the layer above and below. A real node holds its graph node in node; a label node holds the text's lines in label; both dummies hold their layout edge in edge.

A cluster spans the layers lo to hi, and holds in left and right a border node for each of them, by layer. A border node marks where the subgraph's frame stands in its layer: the nodes of the subgraph lie between the two.

An edge's chain runs from its upper end to its lower end through its dummies. reversed marks an edge laid out against its direction because it closed a cycle: its chain starts at to. from_sub and to_sub hold the subgraph an end named; the edge is laid out to that subgraph's first node. The parser refuses an edge to a subgraph with no node, and one between a subgraph and its own member. Each end then comes to a node, and both to one node only for an edge from a node to itself.

A layer's order here is the order of mention. mermaid.flowchart.order sets the order a layout uses.