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

OpenersNotesSection(Spacer1)Details and Options

The graph union (RefLink[Graph, paclet:ref/Graph])[(Subscript[v, 1]),(Subscript[e, 1])]⋃(RefLink[Graph, paclet:ref/Graph])[(Subscript[v, 2]),(Subscript[e, 2])] is given by (RefLink[Graph, paclet:ref/Graph])[(Subscript[v, 1])⋃(Subscript[v, 2]),(Subscript[e, 1])⋃(Subscript[e, 2])].

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

OpenersPrimaryExamplesSection(Spacer1)Examples  (14)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Obtain the graph union of two graphs:

g=;h=;

GraphUnion[g,h]

Highlight the graph union:

HighlightGraph[%,{g,h}]

OpenersExampleSection1(Spacer1)Scope  (6)

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

GraphUnion[,]

Directed graphs:

GraphUnion[,]

Multigraphs:

GraphUnion[,]

Mixed graphs:

GraphUnion[,]

Use rules to specify the graph:

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

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

GraphUnion[,,]

OpenersExampleSection3(Spacer1)Properties & Relations  (7)

The vertices of the graph union are the union of the vertices of the graphs:

g1=;g2=;

VertexList[GraphUnion[g1,g2]]==Union[VertexList[g1],VertexList[g2]]

The edges of the graph union are the union of the edges of the graphs:

g1=;g2=;

edgeSameQ[e1_,e2_]:=SameQ[e1,e2]||SameQ[e1,Reverse[e2]]

EdgeList[GraphUnion[g1,g2]]==Union[EdgeList[g1],EdgeList[g2],SameTest->edgeSameQ]

The graph union of a graph and its subgraph is isomorphic to itself:

g=;

IsomorphicGraphQ[g,GraphUnion[g,Subgraph[g,Range[4]]]]

The graph union of any simple graph and its complement is a complete graph:

g=;

CompleteGraphQ[GraphUnion[g,GraphComplement[g]]]

The (RefLink[GraphUnion, paclet:ref/GraphUnion]) of two graphs has the same vertices as (RefLink[GraphDifference, paclet:ref/GraphDifference]):

VertexList[GraphUnion[,]]==VertexList[GraphDifference[,]]

The (RefLink[GraphUnion, paclet:ref/GraphUnion]) of two graphs has the same vertices as (RefLink[GraphIntersection, paclet:ref/GraphIntersection]):

VertexList[GraphUnion[,]]==VertexList[GraphIntersection[,]]

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

g1=;g2=;

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

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[GraphDisjointUnion, paclet:ref/GraphDisjointUnion])  ▪  (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[Graphs & Networks, paclet:guide/GraphsAndNetworks])}, {▪(RefLinkPlain[Graph Construction & Representation, paclet:guide/GraphConstructionAndRepresentation])}, {▪(RefLinkPlain[Computation on Graphs, paclet:guide/ComputationOnGraphs])}, {▪(RefLinkPlain[Graph Operations and Modifications, paclet:guide/GraphModifications])}})}})