number_strongly_connected_components#

number_strongly_connected_components(G)[source]#

返回图中强连通分量的数量。

Parameters:
GNetworkX 图

一个有向图。

Returns:
n整数

强连通分量的数量

Raises:
NetworkXNotImplemented

如果 G 是无向图。

Notes

仅适用于有向图。

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