英文:
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))
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论