admin管理员组

文章数量:1596345

解决:AttributeError: 'Graph' object has no attribute 'number_of_selfloops'

目录

解决:AttributeError: 'Graph' object has no attribute 'number_of_selfloops'

#问题

#解决

#完整错误


#问题

import networkx as nx

edges = [(1, 2), (1, 6), (2, 3), (2, 4), (2, 6),(3, 4), (3, 5), (4, 8), (4, 9), (6, 7)]

G.add_edges_from(edges)
nx.draw_networkx(G)

print("Total number of nodes: ", int(G.number_of_nodes()))
print("Total number of edges: ", int(G.number_of_edges()))
print("List of all nodes: ", list(G.nodes()))
print("List of all edges: ", list(G.edges(data = True)))
print("Degree for all nodes: ", dict

本文标签: GraphAttributeErrorobjectnumberofselfloopsattribute