python - “图形”对象在 networkx 模块 python 中没有属性 'nodes_iter'

标签 python networkx

我在 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/

相关文章:

python - 在heroku上部署selenium(未检测到Chrome二进制文件)

python networkx 在某些条件下删除节点和边

networkx - 保存并重新加载 OSMnx for NetworKX 的加权图

Python:两个网络之间的jaccard相似性?

python - undefined symbol : clock_gettime with tensorflow on ubuntu14. 04

python - 提高 Django 中的 INSERT 性能以处理大量大量数据的记录

Python URL 字符

python - 在networkx中添加边属性

python - Networkx 中缺少箭头

Python程序使用numpy和Scipy计算三重积分?