rustworkx.generators.directed_binomial_tree_graph#

directed_binomial_tree_graph(order, weights=None, bidirectional=False, multigraph=True)#

Generate a directed binomial tree of order n recursively.

The edges propagate towards right and bottom direction if bidirectional is False

Parameters:
  • order (int) – Order of the binomial tree. The maximum allowed value for order on the platform your running on. If it’s a 64bit platform the max value is 60 and on 32bit systems the max value is 29. Any order value above these will raise an OverflowError.

  • weights (list) – A list of node weights. If the number of weights is less than 2**order, extra nodes with None will be appended.

  • bidirectional – A parameter to indicate if edges should exist in both directions between nodes. Defaults to False.

  • multigraph (bool) – When set to False the output PyDiGraph 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 directed binomial tree with 2^n vertices and 2^n - 1 edges.

Return type:

PyDiGraph

Raises:
  • IndexError – If the lenght of weights is greater that 2^n

  • OverflowError – If the input order exceeds the maximum value for the current platform.

import rustworkx.generators
from rustworkx.visualization import mpl_draw

graph = rustworkx.generators.directed_binomial_tree_graph(4)
mpl_draw(graph)
../_images/rustworkx.generators.directed_binomial_tree_graph_0_0.png