在执行下列操作时:
import networkx as nx
import matplotlib.pyplot as plt
import csv
with open("nutrients.csv") as file:
reader = csv.reader(file)
G = nx.Graph(reader) #initialize Graph
print(G.nodes()) #this part works fine
print(repr(G.edges))
G.selfloop_edges()#attribute of question它又回来了
AttributeError:“图”对象没有属性'selfloop_edge‘
有谁知道会有什么问题吗?
发布于 2020-05-13 07:30:30
您将得到一个错误,因为此方法已从基图类移到主命名空间中,请参见从1.X到2.0的迁移指南。所以,要么您正在查看1.X的文档,要么使用以前版本中的代码。
您需要将此方法调用为:
nx.selfloop_edges(G, data=True) https://stackoverflow.com/questions/61766600
复制相似问题