Hi everyone !
I am currently trying to get a subgraph of my big graph with dgl, and for that I am using the function :
graph.subgraph(…). In this function, there is the argument relabel_nodes and it seems that it does not work, I don’t know why.
Here is my code :
# node number to extract
li = [1, 1369, 1373, 1373, 1374, 1380, 22389, 140832, 143046, 145310, 145391, 145440, 148924, 413736, 564627]
g = graph.subgraph(li, relabel_nodes=False)
g_nx = dgl.to_networkx(g)
plt.figure(figsize=[15,7])
nx.draw(g_nx, with_labels = True)
and here is the issue I have :
DGLError Traceback (most recent call last)
Cell In[128], line 3
1 li = [1, 1369, 1373, 1373, 1374, 1380, 22389, 140832, 143046, 145310, 145391, 145440, 148924, 413736, 564627]
----> 3 g = graph.subgraph(li, relabel_nodes=False)
4 g_nx = dgl.to_networkx(g)
5 plt.figure(figsize=[15,7])
File ~/workspace/202107_fra_f_fullcb/.venv/lib64/python3.9/site-packages/dgl/utils/internal.py:1051, in alias_func.._fn(*args, **kwargs)
1049 @wraps(func)
1050 def _fn(*args, **kwargs):
→ 1051 return func(*args, **kwargs)
File ~/workspace/202107_fra_f_fullcb/.venv/lib64/python3.9/site-packages/dgl/subgraph.py:164, in node_subgraph(graph, nodes, relabel_nodes, store_ids, output_device)
158 device = context_of(nodes)
160 induced_nodes = [
161 nodes.get(ntype, F.copy_to(F.tensor([], graph.idtype), device))
162 for ntype in graph.ntypes
163 ]
→ 164 sgi = graph._graph.node_subgraph(induced_nodes, relabel_nodes)
165 induced_edges = sgi.induced_edges
166 # (BarclayII) should not write induced_nodes = sgi.induced_nodes due to the same
167 # bug in #1453.
File ~/workspace/202107_fra_f_fullcb/.venv/lib64/python3.9/site-packages/dgl/heterograph_index.py:1038, in HeteroGraphIndex.node_subgraph(self, induced_nodes, relabel_nodes)
1021 “”“Return the induced node subgraph.
1022
1023 Parameters
(…)
1035 The subgraph index.
1036 “””
1037 vids = [F.to_dgl_nd(nodes) for nodes in induced_nodes]
→ 1038 return _CAPI_DGLHeteroVertexSubgraph(self, vids, relabel_nodes)
File dgl/_ffi/_cython/./function.pxi:295, in dgl._ffi._cy3.core.FunctionBase.call()
File dgl/_ffi/_cython/./function.pxi:227, in dgl._ffi._cy3.core.FuncCall()
File dgl/_ffi/_cython/./function.pxi:217, in dgl._ffi._cy3.core.FuncCall3()
DGLError: [07:34:58] /opt/dgl/src/graph/heterograph_capi.cc:407: Check failed: relabel_nodes: Node subgraph only supports relabel_nodes=True.
Stack trace:
[bt] (0) /home/f41017/workspace/202107_fra_f_fullcb/.venv/lib64/python3.9/site-packages/dgl/libdgl.so(+0x5261f0) [0x7fdd3f82b1f0]
[bt] (1) /home/f41017/workspace/202107_fra_f_fullcb/.venv/lib64/python3.9/site-packages/dgl/libdgl.so(+0x52f052) [0x7fdd3f834052]
[bt] (2) /home/f41017/workspace/202107_fra_f_fullcb/.venv/lib64/python3.9/site-packages/dgl/libdgl.so(DGLFuncCall+0x48) [0x7fdd3f7b8bb8]
[bt] (3) /home/f41017/workspace/202107_fra_f_fullcb/.venv/lib64/python3.9/site-packages/dgl/_ffi/_cy3/core.cpython-39-x86_64-linux-gnu.so(+0x16863) [0x7fdd3f0fc863]
[bt] (4) /home/f41017/workspace/202107_fra_f_fullcb/.venv/lib64/python3.9/site-packages/dgl/_ffi/_cy3/core.cpython-39-x86_64-linux-gnu.so(+0x1707b) [0x7fdd3f0fd07b]
[bt] (5) /lib64/libpython3.9.so.1.0(_PyObject_MakeTpCall+0x2df) [0x7fde437d9c9f]
[bt] (6) /lib64/libpython3.9.so.1.0(_PyEval_EvalFrameDefault+0x548c) [0x7fde438a4a9c]
[bt] (7) /lib64/libpython3.9.so.1.0(+0x1ee642) [0x7fde4388f642]
[bt] (8) /lib64/libpython3.9.so.1.0(_PyEval_EvalFrameDefault+0x52ae) [0x7fde438a48be]
It seems that the argument relabel_nodes=False is not supported. If you have any idea of how i can display my graph nodes with renaming it, please tell me.
Thank you all and have a good day !