rustworkx.generators.full_rary_tree¶
- full_rary_tree(branching_factor, num_nodes, /, weights=None, multigraph=True)¶
Creates a full r-ary tree of n nodes. Sometimes called a k-ary, n-ary, or m-ary tree.
- Parameters:
order (int) – Order of the tree.
weights (list) – A list of node weights. If the number of weights is less than n, extra nodes with with None will be appended.
multigraph (bool) – When set to False the output
PyGraphobject will not be not be a multigraph and won’t allow parallel edges to be added. Instead calls which would create a parallel edge will update the existing edge.
- Returns:
A r-ary tree.
- Return type:
- Raises:
IndexError – If the lenght of
weightsis greater that n
import rustworkx.generators from rustworkx.visualization import mpl_draw graph = rustworkx.generators.full_rary_tree(5, 15) mpl_draw(graph)