Search code examples
pythonnetworkxconnected-components

How to find subgraphs of strongly connected components using networkx


as nx.strongly_connected_component_subgraphs() is now removed in version 2.4, I have tried using (G.subgraph(c) for c in strongly_connected_components(G)) similar to what we do for connected component subgraphs. but this just shows strongly_connected_component_subgraphs is deprecated. What to do for strongly connected subgraphs in networkx? sorry if this question is repeated.


Solution

  • Using nx.strongly_connected_components as in your shared approach, should be fine:

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

    This function is included in the latest version, 2.5, and does not rely on any other deprecated methods, as you can see in the source code. So make sure you aren't using the method that is actually raising the deprecation warning, nx.strongly_connected_component_subgraphs.