dgl.DGLGraph.out_edges¶
-
DGLGraph.
out_edges
(v, form='uv')¶ Return the outbound edges of the node(s).
Parameters: Returns: - A tuple of Tensors
(eu, ev, eid)
ifform == 'all'
. –eid[i]
is the ID of an outbound edge fromeu[i]
toev[i]
. All outbound edges fromv
are returned. - A pair of Tensors (eu, ev) if form == ‘uv’ –
ev[i]
is the destination node of an outbound edge fromeu[i]
. All outbound edges fromv
are returned. - One Tensor if form == ‘eid’ –
eid[i]
is ID of an outbound edge from any of the nodes inv
.
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)
For a single node:
>>> G.out_edges(0) (tensor([0, 0]), tensor([1, 2])) >>> G.out_edges(0, 'all') (tensor([0, 0]), tensor([1, 2]), tensor([0, 1])) >>> G.out_edges(0, 'eid') tensor([0, 1])
For multiple nodes:
>>> G.out_edges([0, 1]) (tensor([0, 0, 1]), tensor([1, 2, 2])) >>> G.out_edges([0, 1], 'all') (tensor([0, 0, 1]), tensor([1, 2, 2]), tensor([0, 1, 2]))
- A tuple of Tensors