def union(G, H, rename=(None, None), name=None):
 if (not (G.is_multigraph() == H.is_multigraph())):
  raise nx.NetworkXError('G and H must both be graphs or multigraphs.')
 R = G.__class__()
 if (name is None):
  name = ('union( %s, %s )' % (G.name, H.name))
 R.name = name
 def add_prefix(graph, prefix):
  if (prefix is None):
   return graph
  def label(x):
   if is_string_like(x):
    name = (prefix + x)
   else:
    name = (prefix + repr(x))
   return name
  return nx.relabel_nodes(graph, label)
 G = add_prefix(G, rename[0])
 H = add_prefix(H, rename[1])
 if (set(G) & set(H)):
  raise nx.NetworkXError('The node sets of G and H are not disjoint.', 'Use appropriate rename=(Gprefix,Hprefix)or use disjoint_union(G,H).')
 if G.is_multigraph():
  G_edges = G.edges(keys=True, data=True)
 else:
  G_edges = G.edges(data=True)
 if H.is_multigraph():
  H_edges = H.edges(keys=True, data=True)
 else:
  H_edges = H.edges(data=True)
 R.add_nodes_from(G)
 R.add_edges_from(G_edges)
 R.add_nodes_from(H)
 R.add_edges_from(H_edges)
 R.node.update(G.node)
 R.node.update(H.node)
 R.graph.update(G.graph)
 R.graph.update(H.graph)
 return R

def union ( G , H , rename = ( None , None ) , name = None ) : if ( not ( G . is_multigraph ( ) == H . is_multigraph ( ) ) ) : raise nx . NetworkXError ( 'G and H must both be graphs or multigraphs.' ) R = G . __class__ ( ) if ( name is None ) : name = ( 'union( %s, %s )' % ( G . name , H . name ) ) R . name = name def add_prefix ( graph , prefix ) : if ( prefix is None ) : return graph def label ( x ) : if is_string_like ( x ) : name = ( prefix + x ) else : name = ( prefix + repr ( x ) ) return name return nx . relabel_nodes ( graph , label ) G = add_prefix ( G , rename [ 0 ] ) H = add_prefix ( H , rename [ 1 ] ) if ( set ( G ) & set ( H ) ) : raise nx . NetworkXError ( 'The node sets of G and H are not disjoint.' , 'Use appropriate rename=(Gprefix,Hprefix)or use disjoint_union(G,H).' ) if G . is_multigraph ( ) : G_edges = G . edges ( keys = True , data = True ) else : G_edges = G . edges ( data = True ) if H . is_multigraph ( ) : H_edges = H . edges ( keys = True , data = True ) else : H_edges = H . edges ( data = True ) R . add_nodes_from ( G ) R . add_edges_from ( G_edges ) R . add_nodes_from ( H ) R . add_edges_from ( H_edges ) R . node . update ( G . node ) R . node . update ( H . node ) R . graph . update ( G . graph ) R . graph . update ( H . graph ) return R
return the union of _u_ and _v_ .