3.4.4.6. networkx.MultiGraph.__len__

MultiGraph.__len__()

Return the number of nodes. Use the expression ‘len(G)’.

Returns:

nnodes : int

The number of nodes in the graph.

Examples

>>> G = nx.path_graph(4)  # or DiGraph, MultiGraph, MultiDiGraph, etc
>>> len(G)
4