rustworkx.generators.binomial_tree_graph#
- binomial_tree_graph(order, weights=None, multigraph=True)#
以递归方式生成一个阶数为n的无向二项式树。
- 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 (Sequence[Any]) – 一个节点权重序列,通常是一个列表。 如果权重数量小于
2**order,将会添加值为 None 的额外节点。multigraph (bool) – 当设置为
False时,输出PyGraph对象将不是多重图,并且 不允许添加平行边。相反,那些会创建平行边的调用 将更新现有边。
- Returns:
一个具有2^n个顶点和2^n - 1条边的二项树
- Return type:
- Raises:
索引错误 – 如果
weights的长度大于 2^nOverflowError – If the input order exceeds the maximum value for the current platform
import rustworkx.generators from rustworkx.visualization import mpl_draw graph = rustworkx.generators.binomial_tree_graph(4) mpl_draw(graph)