This documents an unmaintained version of NetworkX. Please upgrade to a maintained version and see the current NetworkX documentation.
- disjoint_union(G, H)¶
Return the disjoint union of graphs G and H.
This algorithm forces distinct integer node labels.
G,H : graph
A NetworkX graph
U : A union graph with the same type as G.
A new graph is created, of the same class as G. It is recommended that G and H be either both directed or both undirected.
The nodes of G are relabeled 0 to len(G)-1, and the nodes of H are relabeled len(G) to len(G)+len(H)-1.
Graph, edge, and node attributes are propagated from G and H to the union graph. If a graph attribute is present in both G and H the value from H is used.