列表的顺序不符合预期

时间:2015-07-18 09:07:24

标签: python graph networkx

我有一个列表getElementById()

node_list

我从In [1]: node_list Out[1]: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 1, 2, 3, 4, 5, 6]

NetworkXG添加节点
node_list

但是当我得到节点列表时,模式就会改变!

In [2]: import networkx as nx

In [3]: G = nx.Graph()

In [4]: G.add_nodes_from(node_list)

我希望In [5]: list(G.nodes()) Out[5]: ['a', 1, 'c', 'b', 'e', 'd', 'g', 'f', 'i', 'h', 'j', 2, 3, 4, 6, 5] Out[5]处于相同的模式,但这并没有发生。怎么办呢?

1 个答案:

答案 0 :(得分:2)

<img class="avatar" src="personal_ava.png" avatar-id="53" style="left: 445px; top: 425px;"> <div class="employee-descr" employee-id="53">Test T.T</div>

From the docstring

plan([],_).
plan([ Item | RemainingItems ], Groups) :-
  doStuff(Groups, Item, UpdatedGroups),
  rulesObeyed(UpdatedGroups),
  plan(RemainingItems, UpdatedGroups).