首页 > 解决方案 > 如何使用networkx查找强连接组件的子图

问题描述

正如nx.strongly_connected_component_subgraphs()现在在 2.4 版中删除的那样,我尝试使用(G.subgraph(c) for c in strongly_connected_components(G))类似于我们对连接组件子图所做的操作。但这只是表明 strong_connected_component_subgraphs 已被弃用。对networkx中的强连接子图怎么办?对不起,如果这个问题被重复。

标签: pythonnetworkxconnected-components

解决方案


在您的共享方法中使用nx.strongly_connected_componentsas 应该没问题:

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

此功能包含在最新版本 2.5中,并且不依赖任何其他已弃用的方法,如您在源代码中所见。因此,请确保您没有使用实际引发弃用警告的方法,nx.strongly_connected_component_subgraphs.


推荐阅读