AttributeError: 模块 ‘networkx’ 没有 ‘info’ 属性。

huangapple go评论56阅读模式
英文:

AttributeError: module 'networkx' has no attribute 'info'

问题

print(nx.info(G)) without the error
英文:
import networkx as nx
G = nx.read_edgelist('webpages.txt', create_using=nx.DiGraph())
print(nx.info(G))
AttributeError: module 'networkx' has no attribute 'info'

print(nx.info(G)) without the error

答案1

得分: 1

你可以只需 print(G) 以获取图的属性。

英文:

You can also just print(G) to get the graph properties

答案2

得分: 0

info 方法已从 networkx 3 中移除,您应考虑直接访问图属性。

print('节点数', len(G.nodes))
print('边数', len(G.edges))
print('平均度', sum(dict(G.degree).values()) / len(G.nodes))
英文:

info method has been removed from networkx 3

You should consider accessing the Graph properties directly instead

print('Number of nodes', len(G.nodes))
print('Number of edges', len(G.edges))
print('Average degree', sum(dict(G.degree).values()) / len(G.nodes))

huangapple
  • 本文由 发表于 2023年3月31日 19:00:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/75897778.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定