'Return 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 : int'

def new_edge_key(self, u, v):

    try:
        keydict = self._adj[u][v]
    except KeyError:
        return 0
    key = len(keydict)
    while (key in keydict):
        key += 1
    return key
