NetworkX

Previous topic

networkx.generators.atlas.graph_atlas_g

Next topic

networkx.generators.classic.barbell_graph

networkx.generators.classic.balanced_tree

balanced_tree(r, h, create_using=None)

Return the perfectly balanced r-tree of height h.

For r>=2, h>=1, this is the rooted tree where all leaves are at distance h from the root. The root has degree r and all other internal nodes have degree r+1.

number_of_nodes = 1+r+r**2+...+r**h = (r**(h+1)-1)/(r-1), number_of_edges = number_of_nodes - 1.

Node labels are the integers 0 (the root) up to number_of_nodes - 1.