def new_edge_key(u, v)
      if @adj[u] && @adj[u][v]
        keys = @adj[u][v]
        key = keys.length
        while keys.include?(key)
          key += 1
        end
        return key
      else
        return 0
      end
    end
def new_edge_key(u, v)
      if @adj[u] && @adj[u][v]
        keys = @adj[u][v]
        key = keys.length
        while keys.include?(key)
          key += 1
        end
        return key
      else
        return 0
      end
    end
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
 -----
 The new key is the number of existing edges between 'u' and 'v', increased if necessary to ensure uniqueness. The first edge will have key 0, the second edge 1, etc. If an edge is removed, new keys may not be in this order.

 Parameters
 ----------
 u, v: nodes

 Returns
 -------
 key: int