number_weakly_connected_components#
- number_weakly_connected_components(G)[source]#
Returns the number of weakly connected components in G.
- Parameters:
- GNetworkX graph
A directed graph.
- Returns:
- ninteger
Number of weakly connected components
- Raises:
- NetworkXNotImplemented
If G is undirected.
See also
Notes
For directed graphs only.
Examples
>>> G = nx.DiGraph([(0, 1), (2, 1), (3, 4)]) >>> nx.number_weakly_connected_components(G) 2 ----
Additional backends implement this function
cugraph : GPU-accelerated backend.
- parallelA networkx backend that uses joblib to run graph algorithms in parallel. Find the nx-parallel’s configuration guide here
The parallel computation is implemented by dividing the list of weakly connected components into chunks and then finding the length of each chunk in parallel and then adding all the lengths at the end.
- Additional parameters:
- get_chunksstr, function (default = “chunks”)
A function that takes in a list of weakly connected components as input and returns an iterable
component_chunks
. The default chunking is done by slicing the list of weakly connected components inton_jobs
number of chunks.
[Source]