Problem with .find_edges() with EdgeDataLoader

Hi there,

when I try to apply find_edges() on my graph positive_graph that is generated by the dgl.EdgeDataLoader , I get an error:

positive_graph.find_edges(561, 'signalling interaction')
Traceback (most recent call last):
  File "<ipython-input-21-6472dba516d0>", line 1, in <module>
    positive_graph.find_edges(561, 'signalling interaction_inverse')
  File "/...python3.8/site-packages/dgl/", line 2903, in find_edges
    raise DGLError('Invalid edge ID {:d}'.format(max_eid))
dgl._ffi.base.DGLError: Invalid edge ID 561

When I try it with the original DGLHeteroGraph I used, it works.

Why can I not access the node IDs from the positive_graph? And could I instead access the node IDs from the Heterograph or do I need a mapping for that?


I managed to get the edge IDs from the positive graph, but since I cannot use find_edges() on the positive_graph, I apply it to the entire graph g.

Yet, the indices do not seem to be the same. So is there a mapping from the entire graph g to the positive_graph for the nodes indices?

for canonical_etype in positive_graph.canonical_etypes:
    # find edge IDs
    edge_ids = positive_graph.edata[dgl.EID][canonical_etype]
    # get node IDs from entire graph g 
    src_node_ids, dst_node_ids = g.find_edges(
1 Like

Is this part of 1737?

It is another approach than in that post, but I am trying to achieve the same goal. BarclayII told me that the find_edges() cannot be applied to the positive graph generated by the EdgeDataLoader. Instead you can only apply it to the original graph.

Have you tried positive_graph.ndata[dgl.NID]?

1 Like

Yes, that worked to get the original indices of the nodes :+1: