>>> g = nx.Graph()
>>> g.add_nodes_from( [0,1] )
>>> g.nodes()
[0, 1]
# We have two nodes, zero edges.
# User clicks two vertices, say 0 and 1.
# We add one more node first.
>>> g.add_node(2)
# Then we add the new edges
>>> g.add_path([0,2,1])
>>> g.nodes()
[0, 1, 2]
>>> g.edges()
[(0, 2), (1, 2)]
似乎您可以使用add_path()函数。在
示例:
相关问题 更多 >
编程相关推荐