number_strongly_connected_components#

number_strongly_connected_components(G)[源码]#

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

参数:
GNetworkX 图

一个有向图。

返回:
n整数

强连通分量的数量

抛出:
NetworkXNotImplemented

如果 G 是无向图。

注意

仅适用于有向图。

示例

>>> 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