The Mathematics of Graphs
The Mathematics of Graphs
T HE M A THEM A T IC S
OF G RA P HS
BSCE-1A
GROUP 9
LEARNING OBJECTIVES
• Determining the edges, vertices, order, size, degree vertices, and degree sequence of a graph.
• Identify the adjacent and incident on vertices and edges of a graph.
• Construct different types of graphs.
• Distinguish the difference between a bipartite and a complete bipartite graph.
• Find the complement of a simple graph and complete bipartite graph.
• Differentiate walk, trail, path, circuit, and cycle.
• Show the two given graphs are isomorphic.
• Determine whether a graph is planar or nonplanar.
• Use Euler’s formula to determine planarity of a graph.
• Determine whether a graph is Eulerian, semi-Eulerian and non-Eulerian.
• Explore the applications of graphs.
CHAPTER OUTLINE
Unit 10.1: Basic Concepts
Unit 10.2: Graphs and Euler Circuits
Unit 10.3: Weighted Graphs
Unit 10.4: Euler’s Formula
Unit 10.5: Graph Coloring
UNIT 10.1: BASIC CONCEPTS
A. Introduction
Graph theory is a branch of mathematics concerned with networks of points connected
by lines. It is also defined as the study of graphs and its mathematical structures. It is used
to model pairwise relations between objects from a certain collection. Graph theory started
in recreational math problems but it has grown into a significant area of mathematics with
applications in computer science, social sciences, chemistry, operations research, and in
other fields.
In the field of computer science, graphs are used to represent networks of
communication, data organization, computational devices, the flow of computation, and
others. One good example is the link structure of a certain website which could be
represented by a direct graph. The vertices are the web pages at the website and a directed
edge from page X to page Y exists if and only if page X contains a link to page Y.
UNIT 10.1: BASIC CONCEPTS
We will begin with some definition on the basic terms used in graph theory before we introduce the
types of graphs.
A graph G consists of a non-empty finite set V(G) of elements called vertices (or nodes), and a finite
E(G) of unordered pairs (not necessary distinct) called edges (or edge family). The vertex set is denoted
as V(G) and the edge set is denoted as E(G) of graph G. Note that V(G) = {v1, v2, v3, …, vn} and E(G) =
{e1, e2, e3, …, en}, where v1 is for the vertices and e1 is for the edges. The graph in Figure 10.1 shows
that the set V(G) = {v1, v2, v4, v5} and E(G) = {e1, e2, e3, e4, e5, e6}.
One example of graph is shown in Figure 10.2. The set of vertices of graph G and edge family G is
reflected below: V(G) = {u, v, x, y, z} and E(G) = {uv, vx, xz, yz, uy, vy, uz, vz} = {e1, e2, e3, e4, e5, e6, e7,
e8}.
UNIT 10.1: BASIC CONCEPTS
The order of the graph is number of vertices and its size is determined by counting
the number of edges in a graph. Let us consider Figure 10.2, the order of graph G is 5
and while its size is 8. In addition, the graph G in Figure 10.3 has an order of 6 with a
size of 9.
Two vertices of graph G are adjacent (or neighbors) if there is an edge joining them,
and the edge joining them is called an incident. Likewise, two distinct edges are adjacent
if they have a vertex in common, and the vertex is the connecting the edges is called the
incident.
Given a graph as shown in Figure 10.4, vertex a and vertex b are adjacent to each
other since it is being connected by an edge ab; ab serves as an incident to vertex a and
vertex b. Also edges ab and bc are adjacent since there is a vertex b connecting them;
vertex b serves as an incident to edges ab and bc. Alternatively, vertex a and vertex d are
not adjacent because there is no edge connecting the two vertices.
UNIT 10.1: BASIC CONCEPTS
A pair of vertices consists of more than one edge is called multiple edges or parallel
edges, while an edge whose endpoints are the same vertex is called loop. A graph with no
loops is loop-free. Considering the graph in Figure 10.5 edge ac has multiple edges, while
vertex d contains a loop.
Other important term in graph is its degree. The degree of a vertex of graph G is the
number of edges incident with the vertex noted as deg(v1). The degree of the vertices, a, b,
c, d, and e of graph G in Figure 10.5 are 3, 4, 4, 4, and 1, respectively. The degree vertex is
represented by deg(a)=3, deg(b) = 4, deg(c) = 4, and deg(e) = 1. Take note that a vertex
with loop has a degree of 2.
• In addition, the degree sequence of a graph G consists of the degree written in increasing
order, with repeats are necessary noted as (v1, v2, …, vn) where v1 < v2 < … < vn.
Considering the same graph in Figure 10.5; the graph’s degree sequence is (1, 3, 4, 4, 4)
which was arranged in ascending order. It is written as degree sequence = (1, 3, 4, 4, 4).
UNIT 10.1: BASIC CONCEPTS
Lastly, a vertex is considered isolated if it does not belong to any edge and has a degree of 0 while an end-vertex (or pendant) is a
vertex with a degree of 1. The graph in Figure 10.6 shows that vertex a is an end-vertex f is an isolated vertex.
Theorem 10.1: In a graph G, the sum of the degrees of all vertices is twice the number of edges.
Corollary 10.1: The sum of the degrees of the vertices of a graph is an even number.
Corollary 10.2: In a graph G, the number of odd degree is even.
To verify Theorem 10.1, Corollary 10.1 and Corollary 10.2 by example; let us consider graph in Figure 10.4. The sum of the
degree vertices of the graph is 1 + 3 + 4 +4 + 4 = 16; number of edges is 8; and deg(a) = 3 and deg(e) = 1, thus the number of odd
degrees is e. Theorem 10.1, Corallary 10.1 and Corollary 10.2 hold based from the graph of Figure 10.5
Supplementary Exercise 10.1
1. Draw two examples of graphs.
2. Determine the isolated and end-vertex of the graph in Figure 10.4 if any.
3. Find the degree of all the vertices of the graph in Figure 10.5 and write its degree sequence.
UNIT 10.2: GRAPHS AND EULER’S CIRCUIT
A. Types of Graphs
In this section, we present some terms which are important in the study of graph
theory. This section formalizes some of the basic definitions with examples.
A simple graph G consists of non-empty finite set V(G) of elements and a finite
set E(G) of distinct unordered pairs of distinct elements of V(G), meaning it is a
graph with no loops and no multiple edges. Figure 10.7 shows graphs G1 and G2 are
examples of simple graphs.
Theorem 10.2: Let G be a simple graph with at least two vertices. Then G has at
least two vertices of the same degree.
Let us consider graphs below in verifying Theorem 10.2. Observe that vertices a
and d; b and e a of graph G in Figure 10.7 have the same degrees. Also, the degree
vertices f, h, j and k of graph G in Figure 10.8 have same degree.
UNIT 10.2: GRAPHS AND EULER’S CIRCUIT
A multigraph is a graph which consists of a V(G) and E(G) except that E contains
multiple edges. The graphs of the following figures below: Figure 10.9 is with
two multiple edges, Figure 10.10 is with three multiple edges, and the graph of
Figure 10.11 is with four multiple edges are example of multigraph.
UNIT 10.2: GRAPHS AND EULER’S CIRCUIT
A pseudograph is a graph with at least one loop, the graphs of Figure 10.12 and Figure
10.13 are pseudographs. A trivial graph is a graph with one vertex and no edge; Figure
10.14 illustrates a trivial graph.
A regular graph is a graph in which each vertex has the same degree. If each vertex has
degree r, the graph is regular of degree r or r-regular. The graph G1 in Figure 11.15 is an
example of a regular graph of degree 3. Another example of a regular graph is the graph is
the graph G2 which is known as the Peterson graph shown in the same figure. The graph
was named after Danish Mathematician Julius Peter Christian Petersen (1839-1910) who
developed it.
UNIT 10.2: GRAPHS AND EULER’S CIRCUIT
An empty graph has no vertices and no edges. A null graph is a graph whose
edge-set is empty. A null graph on n vertices is denoted by N0, N1, N2, N3, and N4,
is shown in Figure 10.16. Note that null graph is a regular of degree 0 and each vertex
is isolated.
UNIT 10.2: GRAPHS AND EULER’S CIRCUIT
A subgraph of graph G is a graph, each whose vertices belong to V(G) and each edge belong to E(G).
Symbolically, a subgraph of a graph G = (V, E) is a graph G’ = (V’, E’) with V’ C V and E’ C E. As
reflected in Figure 10.7 graph G1 is a subgraph of G2, since all the edges and vertices of C belong to G2.
On the contrary, G1 and G2 are not subgraphs of G3.
A complete graph is a simple graph in which pair of distinct vertices is adjacent (there exactly one edge
joining every pair of vertices). It is denoted by Kn on n vertices and it has ½n(n-1) edges. A complete
graph is a regular graph of degree n-1. Figure 10.18 shows graphs of K3, K4 and K5 with sizes 3, 6, and
10, respectively. Also, the complete graphs K3, K4 and K5 degree vertices are 2, 3, and 4, respectively.
UNIT 10.2: GRAPHS AND EULER’S CIRCUIT
A cycle graph is connected graph that is regular of degree 2, it is denoted by Cn. Figure 10.19 shows three examples of cycle graphs C3, C4,
and C5. On the contrary, a graph with no cycle is acyclic.
A path graph is a graph obtained from cycle graph (Cn) by removing an edge on n vertices, denoted by Pn. Figure 10.20 illustrates P2, P3, and
P4 graphs. A wheel graph is a graph obtained from Cn-1 by joining each vertex to a new vertex v is the wheel on n vertices, denoted by Wn. Figure
10.21 shows W4, W5 and W6 graphs.
Platonic graphs are graphs which formed from the vertices and edges of the five regular (platonic) solid – the tetrahedron, octahedron, cube,
icosahedron and dodecahedron as shown in Figure 10.22.
Figure 10.23 shows the platonic solids the tetrahedron, octahedron, cube, icosahedron and dodecahedron drawn in a plane. In addition, Table 10.1
shows the basic properties of the five platonic solids in terms of the number of vertices, edges and faces.
UNIT 10.2: GRAPHS AND EULER’S CIRCUIT
If the vertex set of graph G can be split into disjoint sets A and B so that each edge of G joins a vertex of A and a vertex of B, then G is
a bipartite graph. Alternatively, bipartite graph can be colored black and white vertices. Figure 10.24 illustrates G1 and G2 bipartite
graphs, notice the white vertices are connected to black vertices. In addition, the white vertices are not adjacent to each other, the same
with the black vertices.
Theorem 10.3: A graph G is bipartite if and only if all its cycles have even length.
A complete bipartite graph is a bipartite graph is which vertex in A is joined to each vertex in B by just one’s edge. It is denoted as
K1.3 with 4 for black vertices and s for white vertices. Figure 10.25 shoes three examples of complete bipartite graph, observed that
black vertices are connected with white vertices and there are no multiple edges.
UNIT 10.2: GRAPHS AND EULER’S CIRCUIT
The complement of complete bipartite graph is a graph having the following properties: no vertex in A
(black vertices) is adjacent to any vertex in B (white vertices); every vertex in A is adjacent to every vertex in
A; and every vertex in B is adjacent to every other vertex in B. Figure 10.27 shows graph K1.3 and K3.3 and
their complements. Observe that the complement of complete bipartite graphs is not connected.
UNIT 10.2: GRAPHS AND EULER’S CIRCUIT
Supplementary Exercise 10.2B
1. Construct a simple graph and its complement having 6 vertices.
2. Construct the complete bipartite graph K5.3 and its complement.
A trail is a walk with no repeated edges (the edges are distinct); while a path is a walk with no repeated vertices except possibly the
initial and terminal vertex (two vertices are distinct). A walk, path, or trail is called trivial if it has only one vertex and no edge. On the
other hand, a walk, path, or trail that is not trivial is called nontrivial. A nontrivial closed trail from a vertex v to itself is called circuit.
Let us consider Figure 11.28 a walk from b → c → d → e → f → d → h is a trail since there are no repeated edges (note that a repeated
vertex, is permissible like in the case of vertex d), while a walk from a → g → b → c → d → h → f is a path since there is no repeated
vertices.
Theorem 10.4: Let G be a graph and u, v be two vertices of G. If there is a walk from u to v, then there is a path from u to v.
A cycle is a cirvuit that does not contain any repetition except that the initial vertex and the terminal vertex (closed path such that n
≥ 3. A cycle of length k is called a k-cycle. A cycle is called even (odd) if it contains an even (odd) number of edges. Let us consider
Figure 10.29 the circuit a → b → c → d → h → g → f → a is a cycle or 7-cycle since it has a length of 7.
We summarize some important points concerning walks, trails, paths, circuits, and cycles as shown in table 10.2.
A graph is considered connected if and only if there is a path between each pair of vertices otherwise it is disconnected. Figure
10.30 shows that G1 is a connected graph, while G2 is disconnected graph. Notice that G 1 has 8 vertices and 8 edges, note that the
number of edges must be at least 7 edges (refer to Theorem 10.6). A graph that is disconnected contains two more pieces called
UNIT 10.2: GRAPHS AND EULER’S CIRCUIT
• A disconnecting set is a connected graph G with the set of edges whose removal disconnects G. The set of edges whose
removal increases the number of components of G are called cut edges, while the removal of vertex and all edges incident
with it are called cut vertices (or articulation points). A cutset is defined to be a disconnecting set, no proper subset of
which is a disconnecting set. A bridge is a cutset with only one edge.
If G is connected, its edge connectivity (G) is the size of the smallest cutset in G. In other words, (G) is the minimum
number of edges that we need to remove in order to disconnect G. Let us consider Figure 10.31 if G1 is the graph then (G1)
= 2, corresponding to the cutset {e5, e6}. The sets are {e1, e2, e3, e4} and {e7, e8, e9}, while the set disconnecting is {e5,
e6}. Figure 11.31 shoes that G2 is the resulting graph after the removal of the disconnecting set {e5, e6}.
Another example is the graph G in Figure 10.32 where (G1) = 1, since {e5} is just a bridge. The graph G2 is the
resulting graph after removing the disconnecting set {e5}.
UNIT 10.2: GRAPHS AND EULER’S CIRCUIT
Theorem 10.5: Let G be a simple graph with at most 2n vertices. If the degree
of each vertex is at least n, then the graph is connected.
Theorem 10.6: A connected graph with n vertices has at least n-1 edges.
Consider the two graphs shown in Figure 10.33 are isomorphic under the correspondence f(a) → d, f(b) → e, f(c) → f, f(t) → x, f(u) → y, f(v) → z (it
can also be written as: a ‹–› d, b ‹–› e, c ‹–› f, t ‹–› x, u ‹–› y, v ‹–› z). We can conclude that two “unlabeled graphs” are isomorphic if we can assign
labels so that the resulting “labeled graphs” are isomorphic. Let’s take for example the graphs in Figure 10.34, if we label the vertices of G1 and G2 we
can establish that they are isomorphic. On the other hand, G1 and G2 are not isomorphic to G3.
In addition, two graphs are isomorphic to one another and must have the same number of vertices, edges, vertices of any given degree, cycles, and
cycles of any given size. Conversely, G1 and G2 are said to be different if G1 is not isomorphic to G2.
Theorem 10.7: Simple graphs G1 and G2 are isomorphic if and only for some ordering of their respective vertices, their adjacency matrices are equal.
The isomorphism of graphs can also be shown using adjacency matrix as noted from Theorem 10.7. Let us consider the graphs G1 and G2 of Figure
10.33, below are the adjacency matrices of the following graphs.
UNIT 10.2: GRAPHS AND EULER’S CIRCUIT
Rearranging the rows and columns of the adjacency matrix for graph G2 as illustrated in the following adjacency matrices. It can be notice that the
adjacency matrix of G1 is similar to the adjacency matrix G1 is similar to the adjacency matrix G2. Thus we can say that It can be mapped as a one-to-one
correspondence of
A planar graph is a simple connected graph if it is possible to draw it on a plane such that no two edges of the graph intersect except possibly at a vertex
to which they are both incident. Any such drawing is a plane drawing or simply plane graph. The drawing is also referred to as embedding of the graph in
the plane.
A particular planar representation of a planar graph is called a map. A map divides the plane into a number of regions of faces. The graph G1 in Figure
10.35 is a planar graph since it is isomorphic to the plane graphs G2 and G3.
Two graphs are homeomorphic if both can be obtained from the same graph by a sequence of elementary subdivisions, in which a single edge uv is
replaced by two new edges uv-vx connecting to a new vertex v.
The graphs G2 and G3 of Figure 10.36 are homeomorphic because each can be obtained from graph G1 by sequence of elementary subdivisions. A
planar graph cannot be turned into nonplanar by elementary subdivisions, and a nonplanar graph cannot be turned into a planar graph. Homeomorphic
graphs are either both planar or both nonplanar.
A graph G is Eulerian if there is an Euler circuit in G that involves every edge exactly once. A non-Eulerian graph
UNIT 10.2: GRAPHS AND EULER’S CIRCUIT
If we denote vertices as a, b, c, d, and e to all the graphs of Figure 10.39 we could trace the Eulerian circuit and semi-Eulerian trail of
Figure 10.40. The Eulerian circuit on graph G1 is a → b → d → c → e → b → d → e → a → c → a (note that the circuit covers all the edges
once). The semi-Eulerian trail of graph G2is b → a → c → e → b → d → e → a → c → d. Observe that the trail in G2 starts and ends at odd
vertices. Graph G3 is neither Eulerian nor semi-Eulerian because there is no possible circuit or trail to cover all edges once.
Note that not every graph has an Eulerian path or circuit. In the Konigsberg Bridge Problem, it can solved by duplicating some edges
(Bridges) in the graph until an Euler circuit exists the process is called Eulerization. In order to eulerize a graph, edges are duplicated to
connect pairs of vertices with odd degree and giving them both even degree.
Consider the graph G1 of the Konigsberg Bridge Problem in Figure 10.41 it can be eulerized by determining the vertices with odd
degree such as a, b, c and d with degrees 3, 5, 3 and 3, respectively. Then, duplicating the edge ad, bd and cd, making all the degree of
vertices even such as deg(a) = 4, deg(b) = 6, deg(a) = 4, and deg(a) = 6. Now the graph G2 in Figure 10.43 contains an eulerian circuit.
Lemma 10.1: if G is a graph in which the degree of each vertex is at least 2, then G contains a cycle.
Theorem 10.9: A graph G is Eulerian if and only if every vertex in G has even degree.
UNIT 10.2: GRAPHS AND EULER’S CIRCUIT
Corollary 10.4: A connected graph is semi-Eulerian if and only if it has exactly two vertices of odd degrees.
A Hamiltonian path (or traceable path) is a path that visits each vertex exactly once. A Hamiltonian cycle (or Hamiltonian
circuit) is a cycle which visits each vertex exactly once and also returns to the starting vertex and the graph is called Hamiltonian
graph. It was named after an Irish mathematician Sir William Rowan Hamilton (1805-1865). On the other hand, a semi-
Hamiltonian graph is a graph that contains Hamiltonian path, but not a Hamiltonian cycle.
The graph of Figure 10.42 G1, G2 and G3 are Hamiltonian, semi-Hamiltonian and non-Hamiltonian, respectively. Take note
that Hamiltonian graph is a circuit that passes through each vertex once but does not need to pass through every edge, while semi-
Hamiltonian is a trail covering each vertex once does not need to cover each edge.
IF we denote a, b, c, and d of the graph in Figure 10.42 as shown in Figure 10.43 we could trace the Hamiltonian circuit and
Hamiltonian path. The Hamiltonian circuit on graph G1 is a → b → c → d → a (note that the circuit covers all the vertices and not
necessary all the edges). The semi-Hamiltonian path of graph G2 is d → a → b → c. Observe that the path covers all the vertices
but does not starts and ends in the same vertex. Graph G3 is neither Hamiltonian nor semi-Hamiltonian because there is no
possible circuit or path to cover all vertices once.
Let us consider the tree in Figure 10.48 and test Theorem 10.13. Notice that G1 contains no cycle with an edge of v-1 = 5-1 = 4; all
pairs of vertices contain an edge (or a bridge); there is only exactly one path from one vertex to another, and whenever we introduce a
UNIT 10.3: WEIGHED GRAPHS
Table 10.3 shows some examples of trees with their corresponding number vertices and edges. It can be observed that the
number of vertices is one more than the number of edges. Trees have many descriptions, and each contributes to the concrete
understanding of graphs. Theorem 10.13 forms some of the most useful descriptions.
Trees are also used in representing chemical structures such as Methane (CH4), Ethane (C2H6 and Butane (C3H8) on the left
and on the right are their respective tree representations as shown in Figure 11.51. The model molecules of hydrocarbons
represent each atom a vertex (Hyrdogen-H and Carbon-C) and each chemical bond by an edge.
Since a tree isomorphism preserves root and edge incidence, the level number (1) a vertex is a tree isomorphism invariant;
(2) paths from the root to the leaves is a tree isomorphism invariant; (3) levels in a tree (longest path) is a tree isomorphism
invariant; and (4) leaf descendants of a vertex and the level number of a vertex are both tree isomorphism invariants.
Theorem 10.15: Two trees are isomorphic if and only if they have the same (i) number levels and the same number of vertices
UNIT 10.3: WEIGHED GRAPHS
Let us consider the trees in Figure 10.52, notice that T1, T2, nad T3 have the same degree sequence of (1, 1, 1, 2, 3). Observe
also that there is a one-to-one correspondence between the vertices of the trees T1, T2 and T3 and the number of edges joining
any the vertices of T1 is equal to the number of edges joining the corresponding vertices of T2, the same with T1 and T3, and
T2 and T3. Hence, T1, and T2 and T3 are isomorphic. If we put a label on all of the vertices of the trees as shown in Figure
10.53, we can map T1 to T2, T1 to T3, and even T2 to T3 notice that it preserves the connectivity of the vertices to other
vertices.
On the other hand, the T1, T2, and T3 trees in Figure 10.54 have degree sequence of (1, 1, 2, 2, ,2) (1, 1, 1, 2, 3),and (1, 1, 1,
1, 4), respectively. Also, there is no one-to-one correspondence between the vertices of the trees of T1 to T2, T1 to T3, and T2 to
T3. Thus, T1, T2, and T3 are non-isomorphic.
Figure 10.55 shows the tree different chemical structures of Pentane (C3H12).
In general, the different structures associated with a fixed formula are referred as isomers,
UNIT 10.3: WEIGHED GRAPHS
Supplementary Exercise 10.3A
1. Construct a tree with 8 vertices such that 2 vertices are of degree 4.
2. Draw a forest with 3 components and 9 vertices.
3. Draw the chemical structure of Benzene (CnHn).
4. Construct an isomorphic tree using 6 vertices.
5. Show the isomers of C4H10 (Butane and Isobutene).
UNIT 10.3: WEIGHED GRAPHS
B. Spanning Tree
A spanning tree of a graph is a subgraph which is a tree and contains all vertices of the graph. In Figure 10.56, the graphs T1, and T2,
T3 and T4 represent a spanning tree for the graph G on the left. Observe that the spanning tree is not unique and any connected graph has
at least one spanning tree.
Example 1: Let us examine Figure 10.57. Given a graph G we can obtain a spanning forest like F1 and F2 as shown below. Generally, we
can obtain a number of different forests in given a graph as noted in Theorem 10.18.
There are three known personalities who made a significant contribution in the field of graph theory, specifically on spanning tree namely: Robert Clay Prim,
Joseph Bernard Kruskal and Edsger W. Dijkstra.
Robert Clay Prim developed Prim’s algorithm in 1957 which is a greedy algorithm that determines a minimum spanning tree for a connected weighted
undirected graph. The algorithm finds a subset of the edges that forms a tree that includes every vertex, where the total weight of all the edges in the tree is
minimized. The same algorithm was developed by Vojtech Jarnik a Czech mathematician in 1930 and rediscovered by Edsger W. Dijkstra in 1959.The algorithm
sometimes called the DJP algorithm (or Jarnik algorithm or Prim-Jarnik algorithm).
Joseph Bernard Kruskal (1928-2010) is an American mathematician, statistician, computer scientist and psychometrician; he introduced the Kruskal’s
Algorithm for computing the Minimal Spanning Tree (MST of weighted tree. The Kruskal’s algorithm first orders the edges by weight and then proceeds through
the ordered list adding an edge to the partial MST provided that adding the new edge does not create a cycle. Minimal spanning trees have applications to the
construction and pricing of communication network.
Edgar W. Dijkstra (1930-2002), a Dutch computer scientist, conceived the Dijkstra’s Algorithm in 1956 which was later published in 1959. The algorithm is a
graph search algorithm that determines the single-source shortest-path problem for a graph producing a shortest path tree. Dijkstra’s Algorithm is frequently used
in routing and as a subroutine in other graph algorithms. It is a greedy algorithm and similar to Prim’s algorithm. Dijkstra’s Algorithm starts at a source vertex
and it grows a tree that spans all vertices reachable form shortest-path weights from the source vertex.
UNIT 10.3: WEIGHED GRAPHS
Example 4: Given a weighted graph G in Figure 10.60, find
spanning tree T such that the sum of the weights of the edges is
the smallest possible using Prim’s and Kruskal’s algorithms.
Solution: a. We will first evaluate the minimum spanning tree
solution of the given tree of Figure 10.60 using Prim’s Algorithm.
UNIT 10.3: WEIGHED GRAPHS
Observe that all the vertices are already connected and thus we already established the minimum spanning tree. Figure 11.61
shows the spanning tree with total weight of 3+6+7+3+2+8=29
b. This time we will determine the minimum spanning tree solution using Kruskal’s Algorithm.
UNIT 10.3: WEIGHED GRAPHS
UNIT 10.3: WEIGHED GRAPHS
The Kruskal’s Algorithm computes the following sequences of partitions:
After we already established a tree, we then solve for the total weight of the minimum spanning tree. 3+6+7+3+2+8=29
Figure 10.62 shoes the minimum spanning tree with the corresponding weight in each edge.
Theorem 10.21: Let G be any weighted connected graph. Each of Kruskal’s Algorithm and Prim’s Algorithm yields a
minimum spanning tree for G.
Thoerem 10.22: Let G be a weighted connected graph and v a vertex of G. Dijkstra’s Algorithm yields a shortest path tree
for G form v.
UNIT 10.3: WEIGHED GRAPHS
Supplementary Exercise 10.3B
1. Draw a forest F with c(G)=3 and 8 vertices.
2. Construct a spanning tree of a cycle graph C5.
3. Find the number of spanning trees of the complete graph K4.
4. Determine the minimum spanning tree of Figure 10.63 using Prim’s and Kruskal’s algorithms.
UNIT 10.3: WEIGHED GRAPHS
C. Weighted Graph
A lot of problems can be presented using graphs with weights assigned to their edges. The weights could
represent the distance between two locations, the travel time, the travel cost, etc. It is important to note that
the distance between vertices in a graph does not necessarily correspond to the weight of an edge. One good
example is the problem involving distances which can be presented by assigning distances between cities.
Let say, for example, the cities in the National Capitol Region such as Manila City, Quezon City, Caloocan,
Makati City, Pasig City, Parañaque City and others. The cities will serve as the vertices and the distances are
the weight of the edges. Such graphs are called weighted graphs since it contains a number to its edge.
This section covers some applications of graph theory such as the Shortest Path Algorithm, Travelling
Salesman Problem, and the Chinese Postman Problem.
UNIT 10.3: WEIGHED GRAPHS
There are several ways in determining the shortest path of any given weighted graph. This text specifically covers the simplest way to
do it and it is by the way of inspection. Let us consider the example below to illustrate on how to determine the shortest path.
Example 1: Suppose we have a map of the form shown in Figure 10.64, which the letters a, b, c, d, e, x refer to towns that are connected
by roads. If the length of these roads are as marked, what is the length of the shortest path form a to x?
Solution: Note that the answer can be obtained by taking any path from a to x calculating its length. Figure 10.65 below illustrates the
three possible paths from a to x and their total lengths.
The travelling salesman problem can be reformulated in terms of weighted graphs. In order to solve the travelling salesman problem,
we have to find a Hamiltonian cycle of least possible total weights in a weighted complete graph. One possible algorithm is to calculate
the total distance for all possible Hamiltonian cycles, but this is far more complicated for more than 5 vertices. Let us consider the
travelling salesman problem in the next example.
UNIT 10.3: WEIGHED GRAPHS
Example 2: A travelling salesman whishes to visit several given cities and return to his starting point,
covering the least possible total distance as shown in Figure 10.66.
Solution: We have to identify the list all the possible cycles form initial vertex a to terminal vertex a
including the total distance travelled.
The shortest possible route is a → b → c → d → e → f → a, given a total distance of 22, as can be seen by
inspection
UNIT 10.3: WEIGHED GRAPHS
The Chinese Postman Problem (CPP) is to find a shortest closed path or circuit that
visits every edge of a connected undirected. If the graph traveled has an Eulerian
circuit, then the circuit services is the ideal solution. It was originally studied by a
Chinese mathematician Mei-Ku Kuan in 1962 and Alan Goldman of the US National
Bureau of Standards, first coined the name “Chinese Postman Problem.”
Let us consider the example below to illustrate the Chinese postman problem.
Example 3. A postman wishes to deliver his letters, covering the least possible distance
and returning to his starting point. He must traverse each road in his route at least
once, but should avoid covering too many roads more than once. Figure 10.67 shows
the six destinations including the distances from one vertex to another.
Solution: Inspect if the graph contains an Eulerian circuit which is the required type. If
the graph is not Eulerian, then the problem is more difficult to solve. To show the ideas
involved, let us focus on our example, observe that there are exactly two vertices of
odd degrees in Figure 10.67. Thus, the graph is a semi-Eulerian which means that it
contains an Eulerian trail.
Notice that vertices c and f are the only vertices with odd degrees. We can find a trail
from vertex c to vertex f covering each edge exactly once. In order to return to the
initial vertex we need to find the shortest part form vertex c to vertex f.
The solution to the problem is taking the shortest path c → b → a → f with 5+2+3 = 10
including the original trail of the original graph, giving a total distance of 10+48 =58.
UNIT 10.3: WEIGHED GRAPHS
Solution: We can represent the information using weighted graph as shown in Figure 10.69 with vertices representing the countries
and each edge labeled with the price of the flight between the corresponding countries.
We start at Philippines and travel along the edge with the smallest weight ₱ 3,600, to Singapore. The edge of smallest weight
leaving Singapore is the edge to Thailand (₱ 2,100). Form Thailand, the edge of smallest weight is the edge to Vietnam (₱ 3,500).
From Vietnam, the edge of smallest weight is the edge to Philippines, of weight ₱ 4,400. However, we cannot use this edge,
because it would bring us to Philippines. We can take the smallest edge to Malaysia (₱ 6,500). Next is to take flight to Indonesia
with the smallest edge weight of ₱2,500. Lastly, we take a flight to Philippines (₱ 6,800)
The total weight of the edges and thus the total airfare for the Southeast Asian (Philippines → Singapore → Thailand → Vietnam →
Malaysia → Indonesia → Philippines) trip, is ₱ 3,600+ ₱ 2,100+ ₱ 3,500+ ₱ 6,500+ ₱ 6,800 = ₱ 25,000.
Supplementary Exercise 10.3C
1. Determine the shortest path from vertex a to vertex d in Figure 10.66.
2. A DSWD representative of a barangay wishes to visit several streets and return to his starting point, covering the least possible
UNIT 10.4: EULER’S FORMULA
Euler noticed that all planar representation of a graph splits the plane into the same faces/regions. He discovered a relationship among the number of regions, the
number of vertices, and the number edges of a planar graph.
Theorem 10.23: Theorem on the Number of Vertices and Edges: For a simple, connected, planar graph with v vertices and e edges.
1. If the planar representation divides the plane into r regions/faces then v-e + r=2.
2. If v≥ 3, then e ≤ 3v – 6.
3. If v ≥3, and there are no cycles of lengths 3, then e ≤ 2v – 4.
Corollary 10.7: If G is a plane with c(G) connected components then v-3 +r=1 + c(G).
Theorem 10.24: The graph K5 and K33 are nonplanar.
We can use Theorem 10.23 to prove that certain graphs are not planar. Notice that if every cycle of a finite planar G contains at least n edges, since each edge occurs on
exactly two faces/regions, we have the inequality kr ≤ 2e.
Example1: Determine whether the following graphs are planar: (a) cube, (b) K3, and (c) K33,
Solution: a. The graph of the cube has the following: v=8, e=12, and r=6. Applying the rules on Theorem 10.23 to determine whether the graph of a cube is planar.
Since all the rules were satisfied we can say that the cube is planar. We can also verify from Figure 10.70 that graph G1 can be drawn as graph G2.
Since we know that K33 is nonplanar(contradiction to e ≤ 2v -4) as reflected in Figure 10.72 of graph G2. Note that the graph K33 cannot
be drawn in such a way that no edges will intersect.
Example 2. Verify Euler’s Formula for the planar graph in Figure 10.73.
Solution: There are ten edges (e=10), seven vertices (v=7,) and five regions (including the infinite space, r=5) in the graph in Figure
10.74, we get
Let graph G is a graph. A k-coloring of G partitions the vertex set v into set v1, v2, v3, …, vk where each set v, is an independent
set. Note that an independent set is when no two vertices in the set are adjacent. The independent sets v1, v2, v3, …, vk are called color
classes.
Example 3: Determine the chromatic number of a cycle graph with 5 and 6 vertices
Solution: The cycle graph C5 in Figure 10.81 has a chromatic number of ꭓ(C5) = 3 and C6 has ꭓ(C6)=2.
Solution: We can represent the given information by a graph. Each subject is represented by a vertex and an edge connecting the vertices corresponds to
common student in the course they represent. Each slot for the departmental examination is represented by a different color. A schedule of the examination
corresponds to a coloring of the associated graph.
Since the chromatic graph of this graph is 3, three time slots are needed.
A coloring of the graph using three colors and the associated schedule are
shown in Figure 10.83.