title: NetworkX largest component no longer working?
body: <p>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.</p>
  
  <p>However, when I try to get the largest component of a graph G using the example code on the documentation page</p>
  
  <pre><code>G=nx.path_graph(4)
  G.add_edge(5,6)
  H=nx.connected_component_subgraphs(G)[0]
  </code></pre>
  
  <p>I get </p>
  
  <pre><code>TypeError: 'generator' object has no attribute '__getitem__'
  </code></pre>
  
  <p>It used to work on my other computer with earlier versions of networkx (1.7 I think, not 100% sure)</p>
  
  <p>Now I am using a different computer with python 2.7.7 and networkx 1.9. Is it a version problem?</p>
  
  <p>I have written a small function with a couple lines myself to find the largest component, just wondering why this error came out.</p>
  
  <p>BTW, I can get the components by converting the generator object to a list.</p>
  
  <pre><code>components = [comp for comp in nx.connected_components(G)]
  </code></pre>
  
  <p>But the list is not sorted by component size as stated in the documentation.</p>
  
  <p>example:</p>
  
  <pre><code>G = nx.Graph()
  G.add_edges_from([(1,2),(1,3),(4,5)])
  G.add_nodes_from(range(6,20))
  components = [comp for comp in nx.connected_components(G)]
  component_size = [len(comp) for comp in components]
  print G.number_of_nodes(), G.number_of_edges(), component_size
  
  G = nx.Graph()
  G.add_edges_from([(1000,2000),(1000,3000),(4000,5000)])
  G.add_nodes_from(range(6,20))
  components = [comp for comp in nx.connected_components(G)]
  component_size = [len(comp) for comp in components]
  print G.number_of_nodes(), G.number_of_edges(), component_size
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>19 3 [3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
  19 3 [2, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
  </code></pre>
  
  <p>looks like when the node names are large numbers and when there are a bunch of single nodes, the returned subgraphs are not sorted properly</p>