Copying subgraph features to parent in DGL0.5.0

Dear DGL developers,

I’ve been working on a model that requires the node/edge features to be copied between subgraphs and the parent graph:

 g_sub1 = g.subgraph(filter1)
 model1(g_sub1)
 g_sub1.copy_to_parent()

 # Transferring the data to another component
 # Some pooling operations from the parent graph to subgraph 2

 g_sub2 = g.subgraph(filter2)
 model2(g_sub2)
 g_sub2.copy_to_parent()
 res = dgl.sum_nodes(g, "some_feature")

After updating to DGL0.5.0, I got the error: AttributeError: 'DGLHeteroGraph' object has no attribute 'copy_to_parent'. Reading through the document it appears that the parent copying functions are deleted. What is the recommended way to do such data transfer from subgraphs to the parent since 0.5.0? Thanks!

From 0.5, subgraphs extracted via DGL APIs automatically inherits node and edge features from the parent graph. DGL also saves the original nodes/edge IDs in subg.ndata[dgl.NID] and subg.edata[dgl.EID] if nodes/edges are relabeled. This new behavior makes the following DGLGraph methods useless and we thus remove them:

  • DGLGraph.parent , DGLGraph.parent_nid , DGLGraph.parent_eid , DGLGraph.map_to_subgraph_nid , DGLGraph.copy_from_parent , DGLGraph.copy_to_parent and DGLGraph.detach_parent .

Great, it seems that dgl.NID does exactly what I need! I have another question that, since 0.5.0 is the batch information preserved after taking g.subgraph(filter)? I noticed that the individual graph indices are dropped after taking sugraphs in version 0.4, but am curious if DGL5.0 supported that feature.

Thanks a bunch!

Do you mean preserving the batch information when taking a subgraph of a batched graph? I think that’s not preserved.