python - 为什么会出现 AttributeError : module 'networkx' has no attribute 'average_neighbor_in_degree' ?

标签 python networkx graph-theory attributeerror directed-graph

我有 networkx v.2.3,我需要计算有向图节点的平均邻居度。为什么该方法未被识别?

import networkx as nx

G = nx.DiGraph()
G.add_path([0,1,2,3])
nx.average_neighbor_in_degree(G)

最佳答案

networkx 1.6 中替换了 average_neighbor_in_degree 方法 - 参见 release notes (感谢@Delena Malan)。

此功能在 networkx 2.3 中可用 average_neighbor_degree使用 targetsource 关键字参数的方法:

代码:

import networkx as nx

G = nx.DiGraph()
G.add_path([0,1,2,3])
print(nx.average_neighbor_degree(G, source='in', target='in'))

输出:

{0: 1.0, 1: 1.0, 2: 1.0, 3: 0.0}

关于python - 为什么会出现 AttributeError : module 'networkx' has no attribute 'average_neighbor_in_degree' ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59822448/

相关文章:

Python NetworkX 增加圆形图的大小

algorithm - 找到访问树的所有节点的最小成本

neo4j - 分片 Neo4j 图,最小切割

python - 时区问题 - 所有时区都是本地时区?

python - (Python) 无法查看 Matplotlib 图

networkx - 使用 OSMnx 提取约束多边形

python - 使用 node2vec 创建嵌入

python - 二维数组 Django

python - 在 Python 中使用 xlwt 在 Excel 中生成折线图

algorithm - 无向图中直径和半径的关系?