小编dre*_*tak的帖子

NetworkX随机排列节点顺序

我是编程的初学者,现在是我的新手,所以您好!

我在networkX中的节点顺序有问题。这段代码:

letters = []
G = nx.Graph()
for i in range(nodesNum):
    letter = ascii_lowercase[i]
    letters.append(letter)
    print letters

G.add_nodes_from(letters)
print "G.nodes  = ", (G.nodes())
Run Code Online (Sandbox Code Playgroud)

返回此:

['a']
['a', 'b']
['a', 'b', 'c']
['a', 'b', 'c', 'd']
['a', 'b', 'c', 'd', 'e']
['a', 'b', 'c', 'd', 'e', 'f']
['a', 'b', 'c', 'd', 'e', 'f', 'g']
['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']
['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i']
['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'] …
Run Code Online (Sandbox Code Playgroud)

python graph nodes networkx python-2.7

6
推荐指数
1
解决办法
2577
查看次数

标签 统计

graph ×1

networkx ×1

nodes ×1

python ×1

python-2.7 ×1