aryagraph.generators.classic.balanced_tree#

aryagraph.generators.classic.balanced_tree(r: int, h: int, *, directed: bool = False) → Graph[source]#

Perfectly balanced r-ary tree of height h.

Nodes are numbered breadth-first from the root 0; node i’s children are r·i + 1 … r·i + r. There are (r^(h+1) - 1) / (r - 1) nodes (h + 1 when r = 1). Directed arcs point from parent to child.