如何使用networkx找到强连通组件的子图



由于nx.strongly_connected_component_subgraphs()现在在版本2.4中被删除,我尝试使用类似于我们对连接组件子图所做的(G.subgraph(c) for c in strongly_connected_components(G))。但这只是表明stronglyconnectedcomponentsubgraph已被弃用。对于networkx中的强连通子图该怎么办?如果这个问题重复,很抱歉。

在共享方法中使用nx.strongly_connected_components应该很好:

(G.subgraph(c) for c in nx.strongly_connected_components(G))

该函数包含在最新版本2.5中,并且不依赖于任何其他不推荐使用的方法,正如您在源代码中看到的那样。因此,请确保您没有使用实际引发弃用警告nx.strongly_connected_component_subgraphs的方法。

最新更新