NetworkX largest component no longer working?
The networkx-1.9 documentation is here http://networkx.github.io/documentation/networkx-1.9/reference/generated/networkx.algorithms.components.connected.connected_components.html#networkx.algorithms.components.connected.connected_components
The interface was changed to return a generator (as you figured out). The example in the documentation shows how to do what you ask.
Generate a sorted list of connected components, largest first.
>> G = nx.path_graph(4)
>>> G.add_path([10, 11, 12])
>>> sorted(nx.connected_components(G), key = len, reverse=True)
[[0, 1, 2, 3], [10, 11, 12]]
or
>>> sorted(nx.connected_component_subgraphs(G), key = len, reverse=True)
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)