I perform the following python commands, trying to remove all edges from the graph G.
def method(G):
edges = G.edges()
G.remove_edges_from(edges)
But it yields the following error:
RuntimeError: dictionary changed size during iteration.
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.
How do I get around this?