networkx.MultiGraph.clear_edges

MultiGraph.clear_edges()

Remove all edges from the graph without altering nodes.

Examples

>>> G = nx.path_graph(4)  # or DiGraph, MultiGraph, MultiDiGraph, etc
>>> G.clear_edges()
>>> list(G.nodes)
[0, 1, 2, 3]
>>> list(G.edges)
[]