dgl.DGLHeteroGraph.has_node

DGLHeteroGraph.has_node(vid, ntype=None)[source]

Whether the graph has a node with a particular id and type.

Parameters:
  • vid (int) – The node ID.
  • ntype (str, optional) – The node type. Can be omitted if there is only one node type in the graph. (Default: None)
Returns:

True if the node exists, False otherwise

Return type:

bool

Examples

>>> g.has_node(0, 'user')
True
>>> g.has_node(4, 'user')
False

See also

has_nodes()