Test for to_networkx conversion fails when enabled
- Dominant language
- Python
- Stars
- 14.3k
- Forks
- 3.1k
- PR merge metrics
- No merged PRs in 30d
Description
## 🐛 Bug
The [existing test](https://github.com/dmlc/dgl/blob/master/tests/python/common/function/test_basics.py#L202) for the `to_networkx` conversion is disabled. When it is enabled, it fails with `dgl._ffi.base.DGLError: Expect edge_id_attr_name and edge_attrs to be None when nx_graph is undirected, got None and ['h']`.
## To Reproduce
Smallest code snippet that reproduces the behaviour:
```
nxg = nx.cycle_graph(5)
nxg.remove_nodes_from([0, 4])
for u in nxg.nodes():
nxg.nodes[u]["h"] = F.tensor([u])
for u, v, d in nxg.edges(data=True):
d["h"] = F.tensor([u, v])
g = dgl.from_networkx(nxg, node_attrs=["h"], edge_attrs=["h"])
```
## Expected behavior
Either the error should not be raised, or a better explanation of why this happens is needed in the docs. The test should then be updated accordingly.
## Environment
- macOS 13.3
- Python 3.10
- Latest DGL version, installed with `pip install dgl -f https://data.dgl.ai/wheels/repo.html` together with PyTorch (`pip install torch`)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.