NetworkX largest component no longer working?

前端 未结 2 350
Happy的楠姐
Happy的楠姐 2021-01-04 06:14

according to networkx documentation, connected_component_subgraphs(G) returns a sorted list of all components. Thus the very first one should be the largest component.

2条回答
  •  醉梦人生
    2021-01-04 06:25

    As for version 2.4: nx.connected_component_subgraphs(G) is removed.

    Instead to get the same result use:

    connected_subgraphs = [G.subgraph(cc) for cc in nx.connected_components(G)]
    

    And to get the giant component:

    Gcc = max(nx.connected_components(G), key=len)
    giantC = G.subgraph(Gcc)
    

提交回复
热议问题