aryagraph.layout.tree#

aryagraph.layout.tree(g: Any, *, root: Hashable | Iterable[Hashable] | None = None, orientation: str = 'TB', sizes: Any = None, node_sep: float = 24.0, rank_sep: float = 64.0, seed: int = 0) → Layout[source]#

Tidy layered tree drawing (Walker’s algorithm, linear time).

Parameters:
  • root – Root node (or one root per component). Default: the unique source of a directed graph if there is one, else the node of minimum eccentricity.

  • orientation – "TB" (root on top), "BT", "LR" (root on the left) or "RL".

  • sizes – {node: (w, h)} in pixels (default 36×36). Neighbours on a level are separated by their half-widths plus node_sep; levels by the tallest box of each level plus rank_sep.

Returns:

Layout – Metric layout (pixels, boxes start at (0, 0)). meta holds orientation, roots, depth and parent (spanning tree), rank_positions, node_sep and rank_sep. Forests are drawn tree by tree, side by side, sharing level coordinates.

Notes

Complexity: O(n + m).