Note
This is the documentation for the current state of the development branch of rustworkx. The documentation or APIs here can change prior to being released.
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:
factor (int branching) – The number of children at each node.
num_nodes (int) – The number of nodes in the graph.
weights (list) – A list of node weights. If the number of weights is less than
num_nodes
, extra nodes with None will be appended. The number of weights cannot exceed num_nodes.multigraph (bool) – When set to
False
the outputPyGraph
object 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
weights
is greater that n
import rustworkx.generators from rustworkx.visualization import mpl_draw graph = rustworkx.generators.full_rary_tree(5, 15) mpl_draw(graph)