GraphTheory - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Mathematics : Discrete Mathematics : Graph Theory : GraphTheory Package : GraphTheory/GraphUnion

GraphTheory

  

GraphUnion

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

GraphUnion(G1,...,Gs)

Parameters

G1,...,Gs

-

graphs

Description

• 

The GraphUnion function returns a graph G which is the union of the graphs G1,...,Gs, such that

VerticesG=VerticesG1VerticesGs

EdgesG=EdgesG1EdgesGs

• 

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.

Examples

withGraphTheory:

G1Graphdirected,1,2,3,1,2,2,3

G1Graph 1: a directed unweighted graph with 3 vertices and 2 arc(s)

(1)

G2Graphdirected,1,2,3,3,1,2,3

G2Graph 2: a directed unweighted graph with 3 vertices and 2 arc(s)

(2)

GGraphUnionG1,G2

GGraph 3: a directed unweighted graph with 3 vertices and 3 arc(s)

(3)

VerticesG

1,2,3

(4)

EdgesG

1,2,2,3,3,1

(5)

In this example, note that the vertices of G1 and G2 are permuted differently.

G1Grapha,b,c,a,b,3,b,c,4

G1Graph 4: an undirected weighted graph with 3 vertices and 2 edge(s)

(6)

G2Grapha,c,b,a,c,5,b,c,6

G2Graph 5: an undirected weighted graph with 3 vertices and 2 edge(s)

(7)

GGraphUnionG1,G2

GGraph 6: an undirected weighted graph with 3 vertices and 3 edge(s)

(8)

VerticesG

a,b,c

(9)

EdgesG

a,b,a,c,b,c

(10)

WeightMatrixG1,WeightMatrixG2,WeightMatrixG

030304040,050506060,03530105100

(11)

In this example, note that there is one common vertex between the two graphs

G1Grapha,b,a,b

G1Graph 7: an undirected unweighted graph with 2 vertices and 1 edge(s)

(12)

G2Grapha,c,a,c

G2Graph 8: an undirected unweighted graph with 2 vertices and 1 edge(s)

(13)

GGraphUnionG1,G2

GGraph 9: an undirected unweighted graph with 3 vertices and 2 edge(s)

(14)

VerticesG

a,b,c

(15)

EdgesG

a,b,a,c

(16)

See Also

CartesianProduct

DisjointUnion

GraphJoin