Remove all edges

Hi all,

I have a large graph g. How can I remove all edges efficiently?

This kills my kernel:

g.set_fast_edge_removal()
for e in g.edges(): g.remove_edge(e)

Many thanks

Haiko

You should never remove while you are iterating! It says so in the documentation.

You can do:

g.clear_edges()

which is the fastest, or:

for e in list(g.edges()):
    g.remove_edge(e)

which is slower and uses more memory, but avoids the crash.