add_star#

add_star(G_to_add_to, nodes_for_star, **attr)[源代码]#

在图G中添加一个星,在图G中添加一个星。

中的第一个节点 nodes_for_star 是星星的中心。它连接到所有其他节点。

参数
G_to_add_to图表

网络X图表

nodes_for_star可迭代容器

节点的容器。

attr关键字参数,可选(默认值=无属性)

要添加到星形中每条边的属性。

实例

>>> G = nx.Graph()
>>> nx.add_star(G, [0, 1, 2, 3])
>>> nx.add_star(G, [10, 11, 12], weight=2)