Returns the number of weakly connected components in G.
- GNetworkX graph
A directed graph.
Number of weakly connected components
If G is undirected.
For directed graphs only.
>>> G = nx.DiGraph([(0, 1), (2, 1), (3, 4)]) >>> nx.number_weakly_connected_components(G) 2