Skip to main content

Module graph_layout

Module graph_layout 

Source
Expand description

Layered (Sugiyama-style) layout of a directed graph of boxes — nodes in layers (stages) along one axis, ordered across it to keep crossings low.

The steps: cycles broken by a DFS in input order; ranks by longest path (a pinned layer wins; sources pulled up to just before their nearest successor); a dummy vertex per layer a long edge passes; barycenter sweeps plus adjacent transposition, the fewest crossings kept (counted per layer pair with a Fenwick tree); a weighted least-squares (isotonic) placement along each layer; ports spread along a box’s side; optional swimlanes as bands. A graph whose every node is pinned in both axes is drawn on a grid where it is placed, with straight edges.

Node sizes come from the caller (the box contents are the drawing’s business); the result is in px with the origin at the top-left margin. Moved here from anofox-visualization’s ::DIAGRAM (sipemu/ggplot-rs#497, DataZooDE/anofox-visualization#1153).

Structs§

GraphEdge
A directed edge; label_w is the width (px) of its label, if it has one: left to right, the gap between two layers is at least as wide as the labels that cross it.
GraphLayout
The laid-out graph.
GraphNode
A node: its box size, its swimlane, and optional pins (a layer, and a position across it; both pinned on every node → the grid layout).
LayeredParams
Spacing and options; the defaults are anofox-visualization’s diagram.
PlacedNode
A placed node: centre, size, layer, and rank in reading order (layer by layer, then along it).

Enums§

Direction
Which way the layers run.

Functions§

layered
Lay out nodes and edges in layers (see the module docs).