gives the graph disjoint union of the graphs g1 and g2.


gives the disjoint union of g1, g2, .


uses rules vw to specify the graph g.

Details and Options

Background & Context

  • GraphDisjointUnion gives a new graph obtained from two or more directed or undirected graphs obtained by separately taking the unions of the original vertex and edge sets. For edges with same vertex labels in different graphs, GraphDisjointUnion keeps all of them, but uniquely relabels vertices. GraphDisjointUnion therefore corresponds to the usual meaning of graph union in graph theoretical parlance. The resulting graph has canonically indexed vertices with labels from 1 to the sum of initial graph vertex counts. The particular labeling of the resulting graph may therefore depend on the ordering of vertices in the original graph and on the order in which the original graphs are specified, but differently labeled graphs obtained from GraphDisjointUnion in this way all belong to the same isomorphism class.
  • The adjacency matrix for a disjoint union corresponds to the block diagonal matrix of the original graph adjacency matrices.
  • Related functions include GraphUnion, GraphIntersection, and GraphDifference. Unlike GraphDisjointUnion, GraphUnion keeps only one edge if multiple edges exist in different graphs having the same vertex labels. GraphIntersection gives the graph obtained from the union of vertex sets and intersection of edge sets of the original graphs. GraphDifference gives the graph obtained from the union of vertex sets of two graphs and the complement of the second graphs edge set with respect to the first. GraphComplement gives the graph that has the same vertex set as a given graph, but with edges corresponding to absent edges in the original (and vice versa).


open all close all

Basic Examples  (1)

Obtain the graph disjoint union of two graphs:

Click for copyable input
Click for copyable input

Scope  (6)

Properties & Relations  (4)

Introduced in 2010
Updated in 2015