# dgl.DGLHeteroGraph.number_of_nodes¶

DGLHeteroGraph.number_of_nodes(ntype=None)[source]

Return the number of nodes of the given type in the heterograph.

Parameters: ntype (str, optional) – The node type. Can be omitted if there is only one node type in the graph. (Default: None) The number of nodes int

Examples

>>> g = dgl.graph([(0, 1), (1, 2)], 'user', 'follows')
>>> g.number_of_nodes('user')
3
>>> g.number_of_nodes()
3