Professional Documents
Culture Documents
MCA Mathematical Foundation For Computer Application 09
MCA Mathematical Foundation For Computer Application 09
09 Graph Theory – 1
Names of Sub-Units
Introduction to Graph Theory, Basic concepts of Graphs, Sub graphs, Matrix Representation of Graphs,
Isomorphic Graphs, Paths and Circuits, Eulerian Graphs, Hamiltonian Graphs, City-Route Puzzle,
Seating Arrangement Problem, Travelling-Salesman Problem
Overview
This unit begins by discussing about the concept of graph theory, basic concepts of graphs and sub
graphs. Next, the unit discusses the matrix representation of graphs, isomorphic graphs and paths
and circuits. Further the unit explains the Eulerian graphs, Hamiltonian graphs and city-route puzzle.
Towards the end, the unit discusses the seating arrangement problem and travelling-salesman
problem.
Learning Objectives
Learning Outcomes
https://www.tutorialspoint.com/graph_theory/graph_theory_tutorial.pdf
9.1 INTRODUCTION
Graph Theory is a branch of Discrete Mathematics that deals with the study of Graphs. The graph is a
set of vertices (also called nodes or points) that are connected by edges.
A Graph is a set of structures that represent relations between objects, places, people, etc. Graphs can
be found on road maps, constellations and drawings.
Graph theory is a real-life application of Mathematics. We have effective methods and algorithms
which helps in solving problems like City – Route Puzzle, Seating arrangement problem and Travelling
Salesman Problem.
A graph is a pair (V, E) of sets, V is non-empty and each element of E is a set of two distinct elements of
V. The elements of V are known as vertices and elements of E are known as edges.
2
UNIT 09: Graph Theory – 1 JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
b
d
2
1 3
a 4
5 c
6
The set of vertices V of a graph may be finite or infinite. If vertex set is infinite the graph is called an
infinite graph and if vertex it is finite graph is called a finite graph.
The edge of a graph can be a straight-line segment or curve.
3
JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
Mathematical Foundation for Computer Application
b c
Handshaking Lemma
The following points describe the handshaking lemma is as follows:
In any graph, the sum of all the vertex degrees is twice the no. of edges.
Proof: Consider a graph G = (V, E). Since each edge is connected by exactly 2 vertices.
Therefore, each edge contributes two to the sum of the degree of vertices.
The sum of degrees of vertices is twice the n of edges i.e.,
2e = deg (vi)
Note: The sum of the degrees of vertices is always even.
Complete graph: Complete graph is a graph in which each vertex is connected by the other by
exactly one edge.
The complete graph with n vertices is denoted by Kn.
Figure 3 depicts complete graph with n vertex is as follows:
k2
k3 k4
k5 k6 k7
4
UNIT 09: Graph Theory – 1 JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
A B
a b a b
a b
d
a c
d c d c
G1 G3
D C
G2
0 a c
1 1 0
0 0 1 0
A = 0 0 0 1
0 0 0 0
d
b
5
JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
Mathematical Foundation for Computer Application
3 1
0 0 1 1
0 0 1 1
Adjacency Matrix, A =
1 1 0 0
1 1 0 0
1
0 0 0
0 0 1 0
Permutation Matrix, P =
0 0 0 1
0 1 0 0
P is the 4× 4 matrix with row 1 of 4 × 4 identity matrix as its first row. Row 2 of the identity matrix is its
4th row. Row 3 of the identity matrix as its 2nd row and row 4 of the identity matrix as its 3rd row.
6
UNIT 09: Graph Theory – 1 JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
The definition of isomorphism is Symmetric, i.e., if G1 is isomorphic to G2 then G2 is isomorphic to G1. Also
if f : V1 V2 is an isomorphism then f 1 : V2 V1 is an isomorphism.
Two graphs are said to be isomorphic if there is a bijection between their vertex sets that preserves
incidence relations, i.e., a vertex v is incident with an edge e if G 1iff f(v) is incident with f(e) in G 2. In
other words, isomorphism relabels the vertices without changing any of the incidence relations. Two
graphs G1 and G2 are isomorphic if G2 can be obtained by relabeling the vertices of G1. The one–to–one
correspondence should be such that the number of edges joining each pair of vertices in G 1 is equal to
the number of edges joining the corresponding pair of vertices in G 2. Thus, if the graphs are isomorphic
then they must look similar and represent a different graph and one can be obtained from the other by
relabeling as shown in Figure 6:
u2 v1
u1 u3 v5 v2
u5 u4 v4 v3
G1 G2
u3 v3 u4 v4
u5 v5 u6 v6
u1 v1
u6 u2 v6 v2
u5 u3 v5 v3
u4 v4
G3 G4
u3 v3 u4 v4
u5 v5 u6 v6
7
JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
Mathematical Foundation for Computer Application
a
e
b
d
c
a
e
b
d
c
Figure 9: Trail
a – b – c – d – e – b – d is a trail. Vertex b is repeated twice but no edge is repeated twice.
Path: A Path is a walk in which all the edges are different. Figure 10 depicts in path all the edges are
different:
a
e
b
d
c
8
UNIT 09: Graph Theory – 1 JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
a
e
b
d
c
a
e
b
d
c
9
JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
Mathematical Foundation for Computer Application
Components of a Disconnected Graph: Every disconnected graph can be split up into several
connected subgraphs called Components.
Figure 14 depicts components of disconnected graph:
Bridge
B E
A D G
C F
Theorem 1: Let G be a graph in which each vertex has an even degree, then G can be split into cycles, no
two of which have an edge in common.
Proof: Let G be a graph in which each vertex has an even degree starting from the vertex u arbitrarily
traversing edges and never repeating an edge, we from the first cycle in G because every vertex has an
even degree if we enter a vertex through an edge, we must be able to leave it via a different edge. Since
there is only a finite number of vertices, we must eventually reach for vertex v that we have never met
before.
10
UNIT 09: Graph Theory – 1 JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
The edges of the trail between the two occurrences of the vertex v must form a cycle C1. Next is a graph H
(possibly connected) in which each vertex has an even degree. If H has any edges, (i.e., if G is not just C1),
we can repeat the procedure above to find a cycle C2 in H with zero edges common with C1.
The removal of edges from H leads to yet another graph in which each vertex has even a degree and
which therefore contains cycle C3. We continue in this way until there are no edges left at which stage
we have several cycles c1, c2, , ck which together include every edge of G and no two of which have an
edge in common.
Theorem 2: A Connected graph is Eulerian if and only if each vertex has an even degree.
Proof: We first prove that if G is Eulerian then each vertex of G has an even degree. Let G be Eulerian graph
then there exist an Eulerian trail. Whenever this trail passes through a vertex there is a contribution of
2 to the degree of that vertex. Since each vertex is the sum of 2’s which an even number is. Hence every
vertex of G has an even degree.
Conversely, we will prove that if each vertex of a connected graph G has an even degree then G is Eulerian.
Let G be a connected graph in which each vertex has an even degree, from the previous theorem we
know that G can be split into cycles, no two of which have an edge in common. We now fit these cycles
to form an Eulerian trail.
We start at a vertex of a cycle C1 and travel around C1 until we met another vertex of cycle C2, we travel
the edges to this cycle and then resume travelling around C1 this gives a closed trail C1 and C2. If this trail
includes all the edges in G then we have required Eulerian trail if not we travel around our new closed
trail and add a new cycle C3 to it since G is connected to our closed trail, we continue this process until all
cycles have the required Eulerian trail. Hence, G is Eulerian.
Theorem 3: A connected graph is Semi–Eulerian if and only if it has exactly two vertices of odd degree.
Proof: We first prove that if G is Semi–Eulerian then G has exactly 2 vertices of odd degree.
Let G be Semi–Eulerian graph.
Let v and w be the starting and the finishing vertices of an open trail. Let us add an edge (say e) joining
v and w. Then by the previous theorem, we obtain an Eulerian graph in which each vertex has an even
degree. And we recover G by removing the edge e and we see that v and w are the only vertices of odd
degree.
Next, we prove that if a connected graph g has exactly 2 vertices of an odd degree then G is Semi–
Eulerian.
Let G be a graph with exactly 2 vertices of odd degrees v and w. We thus obtain a connected graph in
which each vertex has an even degree. Then by theorem 2, the graph is Eulerian, so it has an Eulerian
trail. Removal of edge e from this trail produces an open trail that includes every edge of G. So G is Semi–
Eulerian.
11
JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
Mathematical Foundation for Computer Application
B E
A D G
C F
12
UNIT 09: Graph Theory – 1 JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
a 1 b
5
6
2
8 e
4
7
c
d 3
a 1 b
5
6 f
2
8 e
4 g
7
c
d 3
13
JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
Mathematical Foundation for Computer Application
Find a route that crosses each bridge exactly once and returns to the starting point as shown in
Figure 19:
a) C b)
C
A
D D
A
B B
Day-2 Day-3
Day-1
1 1 1
2 2 2
7 7 7
3 3 3
6 6 6
4 4 4
5 5 5
14
UNIT 09: Graph Theory – 1 JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
In each subsequent arrangement, we are increasing the length of the edge by 1. We can increase it to a
certain limit, i.e., (n-1)/2.
After (n-1)/2 the edge lengths will start decreasing.
On Day 1, the length of each edge (number of vertices between the endpoints) is 0.
On Day 2, the length of each edge is 1.
On Day 3 the length of each edge is 2.
If we try to draw Day 4, the first edge would be between vertices 1 and 6 and the length would be 2 which
is different from what we expect i.e. 3. Hence, we cannot draw the arrangement for the fourth day.
Example: Nine members of a club meet every day for a game. They sit at a round table for a game, but
no two members who sat together will sit together in the future. How long is this possible?
Solution: The seating arrangement of 9 persons can be represented as follows:
Any two members can occupy consecutive tables. The neighbouring persons can be represented by an
edge. Then each arrangement will be a cycle on 9 vertices. These cycles can be chosen from k9 (since
each member can sit with anybody in the beginning) as shown in Figure 21:
9
1
8
6
4
5
Thus, 4 distinct arrangements as required are the edge disjoint (none of the persons sitting together will
sit together in the next arrangements) Hamiltonian cycles of K9, which is possible only for four days.
15
JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
Mathematical Foundation for Computer Application
V1
5 4
V2 2 V3
5
3 3
8
2 5
2
V4 V5
16
UNIT 09: Graph Theory – 1 JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
Now to reach V1, The total distance will be 18 as shown in Figure 23:
V1
V1 4
V2 2
V3
V1
4 4
V2 2 2
V3
V3
V4
V1 V1
4 4
V2 2 V2 2
V3 V3
2 2
2 2
V4 V5 V4 V5
17
JGI JAINDEEMED-TO-BE UNIVERSIT Y
Mathematical Foundation for Computer Application
Graph theory provides an exceptionally simple way to characterise the complexity of various
ecological networks.
Degree distribution or network topology serves as basic measurements to describe their structure.
Such indices facilitate comparison between different systems.
Graph theory is an incredibly rich area for programmers and designers. Graphs can be used to solve
some very complex problems, such as least cost routing, mapping, program analysis and so on.
A graph is a pair (V, E) of sets, V is non-empty and each element of E is a set of two distinct elements
of V. The elements of V are known as vertices and elements of E are known as edges.
A graph may include edges that connect a vertex to itself such edges are called loops.
A Complete graph is a graph in which each vertex is connected by the other by exactly one edge.
A walk-in Pseudograph is an alternating sequence of vertices and edges beginning and ending with
a vertex in which edge is incident with a vertex immediately preceding it and the vertex following it.
A Connected graph is Eulerian if it contains a closed trial that includes every edge. Such a trail is
called as Eulerian Trail.
A Connected graph is a Hamiltonian if it contains a cycle that includes every vertex. Such a cycle is
called as Hamiltonian Cycle.
9.13 GLOSSARY
Graph: A graph is a pair (V, E) of sets that is non-empty and each element of E is a set of two distinct
elements of V.
Trail: A Trail is a walk in which all the edges but not necessarily all the vertices are different.
Path: A Path is a walk in which all the edges are different and all the edges are different.
Circuit: A Closed Trail is called a Circuit.
Subgraph: It is a graph G is a graph, all of whose vertices are vertices of G and all of whose edges
are edges of G.
Isomorphic graphs: Two graphs are said to be isomorphic if there is a bijection between their vertex
sets that preserves incidence relations.
Path: It is a walk in which all the edges are different.
Disconnected graph: It is an edge in a connected graph is a bridge if its removal leads to a
disconnected graph.
Eulerian graph: It is an Eulerian if it contains a closed trial that includes every edge. Such a trail is
called as Eulerian Trail.
Semi-Eulerian graph: It is a connected graph is Semi Eulerian if there is an open trail that includes
every edge and such a trail is called Semi–Eulerian graph.
Hamiltonian cycle: It is a connected graph is a Hamiltonian if it contains a cycle that includes every
vertex. Such a cycle is called as Hamiltonian Cycle.
18
UNIT 09: Graph Theory – 1 JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
Hamiltonian circuit: It is a closed walk in a graph that visits each vertex exactly once.
City–route puzzle: It is also known as Konigsberg Bridge Problem.
Travelling Salesman Problem: It is used to find the Hamiltonian cycle of least weight in a weighted
graph.
https://www.zib.de/groetschel/teaching/WS1314/BondyMurtyGTWA.pdf
https://www.tutorialspoint.com/design_and_analysis_of_algorithms/design_and_analysis_of_
algorithms_travelling_salesman_problem.htm.
19
JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
Mathematical Foundation for Computer Application
Discuss with your friend and classmates about the concept of graphs, types of graphs and
their importance. Also discuss about the city-route problem, Travelling-salesman problem and
Hamiltonian graph
20