title: Remove all edges from a graph in networkx
body: <p>I perform the following python commands, trying to remove all edges from the graph <code>G</code>.</p>
  
  <pre><code>def method(G):
    edges = G.edges()
    G.remove_edges_from(edges)
  </code></pre>
  
  <p>But it yields the following error:</p>
  
  <pre><code>RuntimeError: dictionary changed size during iteration.
  </code></pre>
  
  <p>It seems like the command iterates through the edges, but when I remove an edge, it modifies the iterator during iteration, which causes an error.</p>
  
  <p>How do I get around this?</p>