dgl.DGLGraph.has_nodes

DGLGraph.has_nodes(vids)

Return a 0-1 array a given the node ID array vids.

a[i] is 1 if the graph contains node vids[i], 0 otherwise.

Parameters:vid (list or tensor) – The array of node IDs.
Returns:a – 0-1 array indicating existence
Return type:tensor

Examples

The following example uses PyTorch backend.

>>> G = dgl.DGLGraph()
>>> G.add_nodes(3)
>>> G.has_nodes([0, 1, 2, 3, 4])
tensor([1, 1, 1, 0, 0])

See also

has_node()