【发布时间】:2014-11-11 19:51:22
【问题描述】:
我有一个networkx 图形对象G。每个节点都有一个关于G.nodes() 的索引。我跟踪节点索引,因为我对邻接矩阵进行了一些计算,因为邻接矩阵中的每个行索引都对应于G.nodes() 中的节点索引。但是现在我想在图中添加新节点,这会改变旧节点的索引吗?
我不会删除任何节点。
G = nx.Graph()
#add some nodes to G.
#record the indices of those nodes in a dictionary that maps from a node name to a node index from the list G.nodes()
#add more nodes and edges to G.
#Did the indices of the old nodes change?
【问题讨论】:
-
您能否发布更多代码,以便我们更清楚地看到您的要求?