#NEWLINE# def disjoint_union( G , H ) : #NEWLINE# #INDENT# ' Return the disjoint union of graphs G and H.\n\n    This algorithm forces distinct integer node labels.\n\n    Parameters\n    ----------\n    G,H : graph\n       A NetworkX graph\n\n    Returns\n    -------\n    U : A union graph with the same type as G.\n\n    Notes\n    -----\n    A new graph is created, of the same class as G.  It is recommended\n    that G and H be either both directed or both undirected.\n\n    The nodes of G are relabeled 0 to len(G)-1, and the nodes of H are\n    relabeled len(G) to len(G)+len(H)-1.\n\n    Graph, edge, and node attributes are propagated from G and H\n    to the union graph.  If a graph attribute is present in both\n    G and H the value from H is used.\n    ' #NEWLINE# R1 = nx . convert_node_labels_to_integers ( G ) #NEWLINE# R2 = nx . convert_node_labels_to_integers ( H , first_label = len ( R1 ) ) #NEWLINE# R = union ( R1 , R2 ) #NEWLINE# R . name = ( 'disjoint_union( %s, %s )' % ( G . name , H . name ) ) #NEWLINE# R . graph . update ( G . graph ) #NEWLINE# R . graph . update ( R1 . graph ) #NEWLINE# return R