dgl.DGLGraph.all_edges¶
-
DGLGraph.
all_edges
(form='uv', sorted=False)[source]¶ Return all the edges.
Parameters: Returns: - A tuple of Tensors (u, v, eid) if form == ‘all’ –
eid[i]
is the ID of an edge betweenu[i]
andv[i]
. All edges are returned. - A pair of Tensors (u, v) if form == ‘uv’ – An edge exists between
u[i]
andv[i]
. Ifn
edges exist betweenu
andv
, thenu
andv
as a pair will appearn
times. - One Tensor if form == ‘eid’ –
eid[i]
is the ID of an edge in the graph.
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.all_edges() (tensor([0, 0, 1]), tensor([1, 2, 2])) >>> G.all_edges('all') (tensor([0, 0, 1]), tensor([1, 2, 2]), tensor([0, 1, 2]))
- A tuple of Tensors (u, v, eid) if form == ‘all’ –