def merge(self, u, v):
    ''' merge u to v, where v is in the graph
    '''
    u_adjs = self.adjacents(u)
    for z,w in u_adjs:
      self.edges.pop((u,z))
      self.edges.pop((z,u))
    self.vertices.remove(u)
    v_adjs = dict(self.adjacents(v))
    for n, w in u_adjs:
      if n == v:
        continue
      v_adjs[n] = v_adjs.get(n,0) + w
    for n, w in v_adjs.iteritems():
      self.edges[(v,n)] = w
      self.edges[(n,v)] = w
 merge u to v, where v is in the graph
    
recipes/Python/576907_Minimum_Cut_Solver/recipe-576907.py