dgl.DGLGraph.map_to_subgraph_nid

DGLGraph.map_to_subgraph_nid(parent_vids)[source]

Map the node Ids in the parent graph to the node Ids in the subgraph.

Parameters:parent_vids (list, tensor) – The node ID array in the parent graph.
Returns:The node ID array in the subgraph.
Return type:tensor

Examples

>>> import dgl
>>> g = dgl.DGLGraph()
>>> g.add_nodes(5)
>>> sg = g.subgrph([0,2,4])
>>> sg.map_to_subgraph([2,4])
tensor([1, 2])