# dgl.DGLGraph.subgraph¶

DGLGraph.subgraph(nodes)[source]

Return the subgraph induced on given nodes.

Parameters: nodes (list, or iterable) – A node ID array to construct subgraph. All nodes must exist in the graph. G – The subgraph. The nodes are relabeled so that node i in the subgraph is mapped to node nodes[i] in the original graph. The edges are also relabeled. One can retrieve the mapping from subgraph node/edge ID to parent node/edge ID via parent_nid and parent_eid properties of the subgraph. DGLGraph

Examples

The following example uses PyTorch backend.

>>> G = dgl.DGLGraph()