NetworkX

Previous topic

graph_atlas_g

Next topic

barbell_graph

balanced_tree

balanced_tree(r, h, create_using=None)[source]

Return the perfectly balanced r-tree of height h.

Parameters :

r : int

Branching factor of the tree

h : int

Height of the tree

create_using : NetworkX graph type, optional

Use specified type to construct graph (default = networkx.Graph)

Returns :

G : networkx Graph

A tree with n nodes

Notes

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.

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

Also refered to as a complete r-ary tree.