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