DGLHeteroGraph.out_edges(u, form='uv', etype=None)[source]

Return the outbound edges of the node(s) with the specified type.

  • u (int, list, tensor) – The node id(s) of source type.
  • form (str, optional) –

    The return form. Currently support:

    • 'eid' : one eid tensor
    • 'all' : a tuple (u, v, eid)
    • 'uv' : a pair (u, v), default
  • etype (str or tuple of str, optional) – The edge type. Can be omitted if there is only one edge type in the graph. (Default: None)

All outbound edges from u are returned.

  • If form='eid', return a tensor for the ids of the outbound edges of the nodes with the specified type.
  • If form='all', return a 3-tuple of tensors (eu, ev, eid). eid[i] gives the ID of the edge from eu[i] to ev[i].
  • If form='uv', return a 2-tuple of tensors (eu, ev). ev[i] is the destination node of the edge from eu[i].

Return type:

tensor or (tensor, tensor, tensor) or (tensor, tensor)


>>> g = dgl.bipartite([(0, 0), (1, 1), (1, 2)], 'user', 'plays', 'game')
>>> g.out_edges([0, 1], form='eid')
tensor([0, 1, 2])
>>> g.out_edges([0, 1], form='all')
(tensor([0, 1, 1]), tensor([0, 1, 2]), tensor([0, 1, 2]))
>>> g.out_edges([0, 1], form='uv')
(tensor([0, 1, 1]), tensor([0, 1, 2]))