GraphTheory
GraphUnion
construct graph union of graphs
Calling Sequence
Parameters
Description
Examples
GraphUnion(G1,...,Gs)
G1,...,Gs
-
graphs
The GraphUnion function returns a graph G which is the union of the graphs G1,...,Gs, such that
Vertices⁡G=Vertices⁡G1∪⋯∪Vertices⁡Gs
Edges⁡G=Edges⁡G1∪⋯∪Edges⁡Gs
Note that the graphs G1,...,Gs must all be directed or all undirected, and the resulting graph is directed or undirected, respectively. Likewise, the graphs G1,...,Gs must all be weighted or all unweighted, and the resulting graph is then weighted or unweighted, respectively.
Moreover, if G1,...,Gs are all weighted graphs, the resulting graph is a weighted graph where the weight of any common edge is the sum of the weights of that edge in G1,...,Gs.
with⁡GraphTheory:
G1≔Graph⁡directed,1,2,3,1,2,2,3
G1≔Graph 1: a directed graph with 3 vertices and 2 arc(s)
G2≔Graph⁡directed,1,2,3,2,3,3,1
G2≔Graph 2: a directed graph with 3 vertices and 2 arc(s)
G≔GraphUnion⁡G1,G2
G≔Graph 3: a directed graph with 3 vertices and 3 arc(s)
Vertices⁡G
1,2,3
Edges⁡G
1,2,2,3,3,1
In this example, note that the vertices of G1 and G2 are permuted differently.
G1≔Graph⁡a,b,c,a,b,3,b,c,4
G1≔Graph 4: an undirected weighted graph with 3 vertices and 2 edge(s)
G2≔Graph⁡a,c,b,a,c,5,b,c,6
G2≔Graph 5: an undirected weighted graph with 3 vertices and 2 edge(s)
G≔Graph 6: an undirected weighted graph with 3 vertices and 3 edge(s)
a,b,c
a,b,a,c,b,c
WeightMatrix⁡G1,WeightMatrix⁡G2,WeightMatrix⁡G
030304040,050506060,03530105100
In this example, note that there is one common vertex between the two graphs
G1≔Graph⁡a,b,a,b
G1≔Graph 7: an undirected graph with 2 vertices and 1 edge(s)
G2≔Graph⁡a,c,a,c
G2≔Graph 8: an undirected graph with 2 vertices and 1 edge(s)
G≔Graph 9: an undirected graph with 3 vertices and 2 edge(s)
a,b,a,c
See Also
CartesianProduct
DisjointUnion
GraphIntersection
GraphJoin
Download Help Document