Warning

This documents an unmaintained version of NetworkX. Please upgrade to a maintained version and see the current NetworkX documentation.

networkx.MultiGraph.new_edge_key

MultiGraph.new_edge_key(u, v)[source]

Returns an unused key for edges between nodes u and v.

The nodes u and v do not need to be already in the graph.

Notes

In the standard MultiGraph class the new key is the number of existing edges between u and v (increased if necessary to ensure unused). The first edge will have key 0, then 1, etc. If an edge is removed further new_edge_keys may not be in this order.

Parameters:u, v (nodes)
Returns:key
Return type:int