dgl.DGLGraph.find_edges¶
-
DGLGraph.
find_edges
(eid)¶ Given an edge ID array, return the source and destination node ID array s and d. s[i] and d[i] are source and destination node ID for edge eid[i].
Parameters: eid (list, tensor) – The edge ID array. Returns: - tensor – The source node ID array.
- tensor – The destination node ID array.
Examples
The following example uses PyTorch backend.
>>> G = dgl.DGLGraph() >>> G.add_nodes(3) >>> G.add_edges([0, 0, 1], [1, 2, 2]) # (0, 1), (0, 2), (1, 2) >>> G.find_edges([0, 2]) (tensor([0, 1]), tensor([1, 2]))