({{, (RefLink[GraphDisjointUnion, paclet:ref/GraphDisjointUnion])[(Subscript[g, 1]),(Subscript[g, 2])] 
gives the graph disjoint union of the graphs (Subscript[g, 1]) and (Subscript[g, 2]).}, {, (RefLink[GraphDisjointUnion, paclet:ref/GraphDisjointUnion])[(Subscript[g, 1]),(Subscript[g, 2]),…]
gives the disjoint union of (Subscript[g, 1]), (Subscript[g, 2]), ….}, {, (RefLink[GraphDisjointUnion, paclet:ref/GraphDisjointUnion])[{v->w,…},…]
uses rules v->w to specify the graph g.}})

OpenersNotesSection(Spacer1)Details and Options

The graph disjoint union is given by the graph union of (RefLink[IndexGraph, paclet:ref/IndexGraph])[(Subscript[g, 1]),1] and (RefLink[IndexGraph, paclet:ref/IndexGraph])[(Subscript[g, 2]),n+1] where n is the (RefLink[VertexCount, paclet:ref/VertexCount]) for (Subscript[g, 1]).

(RefLink[GraphDisjointUnion, paclet:ref/GraphDisjointUnion]) works with undirected graphs, directed graphs, multigraphs, and mixed graphs.

OpenersPrimaryExamplesSection(Spacer1)Examples  (11)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Obtain the graph disjoint union of two graphs:

g=;h=;

GraphDisjointUnion[g,h]

OpenersExampleSection1(Spacer1)Scope  (6)

(RefLink[GraphDisjointUnion, paclet:ref/GraphDisjointUnion]) works with undirected graphs:

GraphDisjointUnion[,]

Directed graphs:

GraphDisjointUnion[,]

Multigraphs:

GraphDisjointUnion[,]

Mixed graphs:

GraphDisjointUnion[,]

Use rules to specify the graph:

GraphDisjointUnion[{1->2,2->3,3->1,4->3,2->4},{1->2,3->2,4->3,4->1}]

(RefLink[GraphDisjointUnion, paclet:ref/GraphDisjointUnion]) works with more than two graphs:

GraphDisjointUnion[,,]

OpenersExampleSection3(Spacer1)Properties & Relations  (4)

The (RefLink[VertexCount, paclet:ref/VertexCount]) of the graph disjoint union is the total of vertex counts for the graphs:

g1=;g2=;

VertexCount[GraphDisjointUnion[g1,g2]]==VertexCount[g1]+VertexCount[g2]

The (RefLink[EdgeCount, paclet:ref/EdgeCount]) of the graph disjoint union is the total edges of the graphs:

g1=;g2=;

EdgeCount[GraphDisjointUnion[g1,g2]]==EdgeCount[g1]+EdgeCount[g2]

The graph disjoint union can be found using (RefLink[GraphUnion, paclet:ref/GraphUnion]):

g1=;g2=;

GraphDisjointUnion[g1,g2]==GraphUnion[g1,IndexGraph[g2,VertexCount[g1]+1]]

The adjacency matrix for a disjoint union corresponds to the block diagonal of adjacency matrices:

g1=;g2=;

MatrixPlot/@AdjacencyMatrix/@{g1,g2,GraphDisjointUnion[g1,g2]}

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[GraphUnion, paclet:ref/GraphUnion])  ▪  (RefLink[GraphIntersection, paclet:ref/GraphIntersection])  ▪  (RefLink[GraphDifference, paclet:ref/GraphDifference])  ▪  (RefLink[GraphComplement, paclet:ref/GraphComplement])  ▪  (RefLink[BooleanGraph, paclet:ref/BooleanGraph])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Graph Operations and Modifications, paclet:guide/GraphModifications])}})}})