def contracted_edge(G, edge, self_loops=True):
 if (not G.has_edge(*edge)):
  raise ValueError('Edge {0} does not exist in graph G; cannot contract it'.format(edge))
 return contracted_nodes(G, self_loops=self_loops, *edge)

def contracted_edge ( G , edge , self_loops = True ) : if ( not G . has_edge ( * edge ) ) : raise ValueError ( 'Edge {0} does not exist in graph G; cannot contract it' . format ( edge ) ) return contracted_nodes ( G , self_loops = self_loops , * edge )
returns the graph that results from contracting the specified edge .