dgl.DGLHeteroGraph.has_edges_between

DGLHeteroGraph.has_edges_between(u, v, etype=None)[source]

Whether the graph has edges of type etype.

Parameters:
  • u (list, tensor) – The node ID array of source type.
  • v (list, tensor) – The node ID array of destination type.
  • etype (str or tuple of str, optional) – The edge type. Can be omitted if there is only one edge type in the graph.
Returns:

a – Binary tensor indicating the existence of edges. a[i]=1 if the graph contains edge (u[i], v[i]) of type etype, 0 otherwise.

Return type:

tensor

Examples

The following example uses PyTorch backend.

>>> g.has_edges_between([0, 0], [1, 2], ('user', 'plays', 'game'))
tensor([1, 0])