title: removing isolated vertices in networkx
body: <p>The documentation says that isolated vertices in graph can be obtained using networkx.isolates(<em>G</em>). It adds that the isolated vertices can be removed from a graph G using the code <em>G</em>.remove_nodes_from(nx.isolates(<em>G</em>)).</p>
  
  <p><a href="https://networkx.github.io/documentation/networkx-1.10/reference/generated/networkx.algorithms.isolate.isolates.html" rel="noreferrer">https://networkx.github.io/documentation/networkx-1.10/reference/generated/networkx.algorithms.isolate.isolates.html</a></p>
  
  <p><a href="https://i.stack.imgur.com/IqrCi.png" rel="noreferrer"><img src="https://i.stack.imgur.com/IqrCi.png" alt="screenshot of documentation(url above)"></a></p>
  
  <p>But I get the run time error "dictionary changed size during iteration" when I run the code. </p>
  
  <p>Error report:-<br/>
  <code>&gt;&gt;&gt; G.remove_nodes_from(nx.isolates(G))
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "/home/iiitdm/anaconda2/lib/python2.7/site-packages/networkx/classes/graph.py", line 617, in remove_nodes_from
      for n in nodes:
    File "/home/iiitdm/anaconda2/lib/python2.7/site-packages/networkx/algorithms/isolate.py", line 94, in &lt;genexpr&gt;
      return (n for n, d in G.degree() if d == 0)
    File "/home/iiitdm/anaconda2/lib/python2.7/site-packages/networkx/classes/reportviews.py", line 443, in __iter__
      for n in self._nodes:
  RuntimeError: dictionary changed size during iteration</code></p>
  
  <p>It is understandable and was expected because (I think) the generator object created using the function isolates() changes with G and hence changing graph G while it is being 'iterated' should give a similar error. Then that line in the documentation must be wrong, isn't it? Am I completely off the mark? I am pretty new to python.</p>
  
  <p>By the way, the object returned by networkx.isolates() is a generator object. </p>
  
  <p>Thank you</p>