我在 python2.7 中使用产生错误的 networkx 模块有以下功能。
for H in networkx.connected_component_subgraphs(G):
bestScore = -1.0
for n, d in H.nodes_iter(data=True):
if d['Score'] > bestScore:
bestScore = d['Score']
bestSV = n
if bestSV is not None:
selectedSVs.add(bestSV)
错误:
Traceback (most recent call last):
File "cnvClassifier.py", line 128, in <module>
for n, d in H.nodes_iter(data=True):
AttributeError: 'Graph' object has no attribute 'nodes_iter'
有人知道哪里出了问题吗?
最佳答案
您可能正在使用 networkx-2.0 的预发布版本,它删除了 nodes_iter() 方法,现在提供具有相同功能的 nodes() 方法。 参见 this有关 networkx-2.0 更改的详细信息。
关于python - “图形”对象在 networkx 模块 python 中没有属性 'nodes_iter',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33734836/