NetworkX

Previous topic

networkx.MultiDiGraph.remove_edge

Next topic

networkx.MultiDiGraph.add_star

networkx.MultiDiGraph.remove_edges_from

MultiDiGraph.remove_edges_from(ebunch)

Remove all edges specified in ebunch.

Parameters:

ebunch: list or container of edge tuples :

Each edge given in the list or container will be removed from the graph. The edges can be:

  • 2-tuples (u,v) All edges between u and v are removed.
  • 3-tuples (u,v,key) The edge identified by key is removed.

See also

remove_edge
remove a single edge

Notes

Will fail silently if an edge in ebunch is not in the graph.

Examples

>>> G = nx.MultiGraph() # or MultiDiGraph
>>> G.add_path([0,1,2,3])
>>> ebunch=[(1,2),(2,3)]
>>> G.remove_edges_from(ebunch) 

Removing multiple copies of edges

>>> G = nx.MultiGraph() 
>>> G.add_edges_from([(1,2),(1,2),(1,2)])
>>> G.remove_edges_from([(1,2),(1,2)])
>>> print G.edges()
[(1, 2)]
>>> G.remove_edges_from([(1,2),(1,2)]) # silently ignore extra copy
>>> print G.edges() # now empty graph
[]