add_star#
- add_star(G_to_add_to, nodes_for_star, **attr)[source]#
向图 G_to_add_to 添加一个星形结构。
nodes_for_star
中的第一个节点是星形的中心。它连接到所有其他节点。- 参数:
- G_to_add_to图
一个 NetworkX 图
- nodes_for_star可迭代容器
包含节点的容器。
- attr关键字参数,可选 (默认= 无属性)
要添加到星形结构中每条边的属性。
示例
>>> G = nx.Graph() >>> nx.add_star(G, [0, 1, 2, 3]) >>> nx.add_star(G, [10, 11, 12], weight=2)