aryagraph.layout.hierarchical#
- aryagraph.layout.hierarchical(g: Any, *, orientation: str = 'TB', sizes: Any = None, node_sep: float = 28.0, rank_sep: float = 72.0, layering: str = 'network_simplex', ranks: Mapping[Hashable, int] | None = None, crossing_passes: int = 24, seed: int = 0, compact: bool = True, max_width: int | None = None) Layout[source]#
Layered (Sugiyama) layout: the right picture for DAGs, pipelines and flows.
- Parameters:
orientation –
"TB"(sources on top, the default),"BT","LR"or"RL".sizes –
{node: (w, h)}rendered box in pixels (default 36×36). Neighbours in a layer keephalf-widths + node_sepapart; consecutive layers keep rank_sep between their tallest boxes.layering –
"network_simplex"(minimum total edge length, balanced; the default),"longest_path"or"coffman_graham"(at most max_width real nodes per layer, default ⌈√n⌉).ranks –
{node: int}layer override for every node. Edges that then point upwards are treated as reversed; edges inside a layer are drawn flat.crossing_passes – Maximum number of sweeps (median, sifting, transpose) in the main phase.
seed – Seeds the extra random initial orders tried on small graphs.
compact – Refine the Brandes–Köpf coordinates with dot’s network-simplex positioning (straighter, narrower drawings; skipped for very large layered graphs) and pack isolated nodes into a block of rows.
Falsekeeps the plain balanced Brandes–Köpf result.max_width – Width bound for
layering="coffman_graham".
- Returns:
Layout – Metric layout (pixels; node boxes and bend points start at (0, 0)).
routes[(u, v)]holds the bend points of every edge spanning more than one layer, ordered from u to v (also for reversed edges).meta:orientation,layers(NodeMap node → layer),crossings,reversed_edges,flat_edges,rank_sep,node_sepandrank_positions(coordinate of each layer along the rank axis).
Examples
>>> lay = hierarchical(DAG([("a", "b"), ("a", "c"), ("b", "d"), ("c", "d")])) >>> lay.meta["layers"]["d"], lay.meta["crossings"] (2, 0)