number_strongly_connected_components#
- number_strongly_connected_components(G)[source]#
Returns number of strongly connected components in graph.
- Parameters:
- GNetworkX graph
A directed graph.
- Returns:
- ninteger
Number of strongly connected components
- Raises:
- NetworkXNotImplemented
If G is undirected.
See also
Notes
For directed graphs only.
Examples
>>> G = nx.DiGraph( ... [(0, 1), (1, 2), (2, 0), (2, 3), (4, 5), (3, 4), (5, 6), (6, 3), (6, 7)] ... ) >>> nx.number_strongly_connected_components(G) 3 ----
Additional backends implement this function
- 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 strongly 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 strongly connected components as input and returns an iterable
component_chunks
. The default chunking is done by slicing the list of strongly connected components inton_jobs
number of chunks.
[Source]