when I study Chapter 1.4 about DGL in website: https://docs.dgl.ai/guide/graph-external.html
the code is:
import dgl
import torch as th
import scipy.sparse as sp
spmat = sp.rand(100, 100, density=0.05) # 5% nonzero entries
dgl.from_scipy(spmat) # from SciPy
import networkx as nx
nx_g = nx.path_graph(5) # a chain 0-1-2-3-4
dgl.from_networkx(nx_g) # from networkx
Error information:
Traceback (most recent call last):
File “D:/PycharmProject_data/DGL_env_test/test.py”, line 11, in
g = dgl.from_networkx(nx_g)
File “D:\Anaconda3\envs\DGL_python36\lib\site-packages\dgl\convert.py”, line 986, in from_networkx
nx_graph, idtype, edge_id_attr_name=edge_id_attr_name)
File “D:\Anaconda3\envs\DGL_python36\lib\site-packages\dgl\utils\data.py”, line 182, in graphdata2tensors
data, idtype, edge_id_attr_name=edge_id_attr_name)
File “D:\Anaconda3\envs\DGL_python36\lib\site-packages\dgl\utils\data.py”, line 92, in networkx2tensor
for e in nx_graph.edges:
TypeError: ‘method’ object is not iterable
Process finished with exit code 1
any answer is appreciate,Thanks!