You are on page 1of 20

UNIT

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

In this unit, you will learn to:


 Discuss the concept of graph theory, basic concepts of graphs and sub graphs
 Explain the concept of matrix representation of graphs, isomorphic graphs and paths and circuits
 Describe the Eulerian graphs and Hamiltonian graphs
 Explain the significance of city-route puzzle and seating arrangement problem
 Discuss the travelling salesman problem
JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
Mathematical Foundation for Computer Application

Learning Outcomes

At the end of this unit, you would:


 Evaluate the concept of graph theory, basic concepts of graphs and sub graphs
 Assess the concept of matrix representation of graphs, isomorphic graphs and paths and circuits
 Evaluate the importance of Eulerian graphs and Hamiltonian graphs
 Determine the significance of city-route puzzle and seating arrangement problem
 Explore the travelling salesman problem

Pre-Unit Preparatory Material

 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.

9.2 BASIC CONCEPT OF GRAPHS


If e is an edge, then e = {a, b} if an edge indicates the end vertices and we refer to this edge as ab or ba.
The vertices a and b are said to be incident with edge a and b and the edge ab is incident with each
vertex.
The vertices a and b are adjacent if they are the end vertices of an edge and two edges are adjacent if
they have a vertex in common.

9.2.1 Degree of a Vertex


The number of edges incident with a vertex a is called the degree of vertex and is denoted by the deg a
is as follows:
 A vertex a is said to be an even vertex if the degree of a is an even number.
 A vertex a is said to be an odd vertex if the degree of a is an odd number.
 A vertex is said to be isolative isolated if its degree is zero as shown in Figure 1:

2
UNIT 09: Graph Theory – 1 JGI JAIN
DEEMED-TO-BE UNIVERSIT Y

b
d
2
1 3

a 4
5 c
6

Figure 1: Isolated Vertex


The above graph has four vertices, V = {a, b, c, d} and six edges E = {1, 2, 3, 4, 5, 6}:
 Edge 1 joins a and b.  Edge 5 joins c and a.
 Edge 2 joins b and c.  Edge 6 joins a to itself.
 Edge 3 and 4 join c and d.

The edges are denoted by:


 Edge 1 is ab and ba.  Edge 5 is ca and ac.
 Edge 2 is bc and cb.  Edge 6 is aa.
 Edge 3 and 4 are cd and dc.

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.

9.2.2 Types of Graphs


Graphs are differentiated based on the interconnection of vertices the various types of graphs are:
 Simple graph: A simple graph is a graph in which each edge connects different vertices i.e. two
edges cannot connect the same pair of vertices.
In a simple graph, each is associated with an ordered pair of vertices and no other edge is associated
with the same pair of vertices.
 Multiple graph: A multigraph is a graph in which multiple edges are connecting the same pair of
vertices. When n-different edges are associated with the same unordered pair of vertices (a, b) we
say that ab is an edge of multiplicity.
 Loops: A graph may include edges that connect a vertex to itself such edges are called loops.
 Pseudo graph: The graph which may contain loops or multiple edges or both is called pseudograph.
Adjacency and incidency of pseudo graph is as follows:
 Vertices a and b of the graph are Adjacent if they are joined by an edge e.
 Vertices a and b are incident with the edge e is incident to a and b.
 Vertex degree of pseudo graph: The degree of a vertex V in a graph is the number of edges incident
with V with each loop counted twice.

3
JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
Mathematical Foundation for Computer Application

It is denoted by deg v is shown in Figure 2:


a
d

b c

Figure 2: Vertex Degree of Pseudo Graph


deg a = 2deg b = 2deg c = 3deg d = 1
 Degree sequence of pseudo graph: The degree sequence of a Graph G is sequence obtained by listing
the vertex degrees of G in increasing order with repetition if necessary.
Concerning the above graph, the degree sequence is 1, 2, 2, 3.

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

Figure 3: Complete Graph with n Vertex

4
UNIT 09: Graph Theory – 1 JGI JAIN
DEEMED-TO-BE UNIVERSIT Y

9.3 SUB GRAPHS


A graph G1 is a subgraph of another graph G if and only if the vertex and edge set of G1 are respectively
subsets of vertex and edge sets of G.
In other words, A Subgraph of a graph G is a graph, all of whose vertices are vertices of G and all of
whose edges are edges of G. Every graph is a subgraph of itself as shown in Figure 4:

A B
a b a b
a b

d
a c
d c d c
G1 G3
D C
G2

Figure 4: Sub Graphs


Here, G1 is a subgraph of G2, G1 is a subgraph of G3 but G3 is not a subgraph of G2.

9.4 MATRIX REPRESENTATION OF GRAPH


A Graph is represented using Adjacency Matrix.
Let G be a graph with n vertices labelled v1, v2, .......... , vn. For each i and j with 1 ≤ i, j ≤ n, define:
aij = 1, if vivj is an edge
aij = 0, if vivj is not an edge
The adjacency matrix of G is the n × n matrix A = [aij] whose (i, j) entry is aij.
Adjacency matrix of Undirected Graph:
a c
0 1 1 0
 
1 0 1 0 
A = 1 
1 0 1
0 0 1 0 
 
 b d
 
Adjacency matrix of Directed Graph: 

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

9.4.1 Properties of Adjacency Matrix


Let G be a graph with vertices v1, v2, v3…, vn and let A = [aij] be the adjacency matrix of G. Then:
1. The diagonal entries of A are all 0 i.e. aii = 0.
2. The adjacency matrix is Symmetric. i.e. <<Eqn9.96.wmf>>
3. Degree vi is the number of 1’s in row i. This is also the no. of 1’s in column i as row i and row i are the
same by symmetry.
4. The ij entry of A2 is the number of different walks of length 2 from vi to vj. In particular, the degree of
vi is the ith main diagonal entry of A2.
5. In general, for any k ≥ 1, the ijth entry of Ak is several walks of length k from vi to vj

9.4.2 Permutation Matrix


It is a matrix whose rows are the rows of the identity matrix but not necessarily in their natural order.
Example: For the given graph, as shown in Figure 5:

3 1

Figure 5: Example of Permutation Matrix

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.

9.5 ISOMORPHIC GRAPHS


Two graphs G1= G1(V1, E1) and G2 = G2(V2, E2) are said to be Isomorphic if there is a one-to-one function
f : V1 V2 s.t:
 If vw is an edge in E1 , then f(v)f(w) is an edge in E2
 Every edge in E2 has the form f(v)f(w) for some edge vw in E1.

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

Figure 6: Isomorphic Graphs


The graphs G1 and G2 are isomorphic to each other with the one-to-one correspondence between the
vertex and edge sets of both the graphs:
u1  v 1 u2  v2

u3  v3 u4  v4

u5  v5 u6  v6

Figure 7 depicts the graphs G1 and G2 are isomorphic to each other:

u1 v1

u6 u2 v6 v2

u5 u3 v5 v3

u4 v4
G3 G4

Figure 7: Graphs G1 and G2 are isomorphic to each other


The graphs G3 and G4 are isomorphic to each other with the one-to-one correspondence between the
vertex and edge sets of both the graphs:
u1  v 1 u2  v2

u3  v3 u4  v4

u5  v5 u6  v6

7
JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
Mathematical Foundation for Computer Application

9.6 A PATHS AND CIRCUITS


The following points describe the paths and circuits in graphs are as follows:
 Walk: 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 walk of length k in a graph is a succession of k edges of the form uv, vw, wx, …., yz. This walk is
denoted by uvwx… ....... yz and is referred to as the walk between u and z.
When the edges are undirected so we can refer to a walk from z to u. Then, the walk is represented
by zy ...... xwvu.
The edges or vertices are not required to be different in walking as shown in Figure 8:

a
e
b

d
c

Figure 8: Walk in Pseudograph


a – b – d – a – b – c is a walk of length 5. Here, the edge ab is included twice and the vertices a, b, are
also included twice.
 Trail: A Trail is a walk in which all the edges but not necessarily all the vertices are different as
shown in Figure 9:

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

Figure 10: Different Edges in Path

8
UNIT 09: Graph Theory – 1 JGI JAIN
DEEMED-TO-BE UNIVERSIT Y

a – b – c – d – e is a path where no edge or vertex is repeated.


 Circuit: A Closed Trail is called a Circuit as shown in Figure 11:

a
e
b

d
c

Figure 11: Circuit


a – b – c – d – e – b – d – a is a closed trail which is known as Circuit.
 Cycle: A circuit in which the first vertex appears exactly twice i.e. at the beginning and the end and
in which no other vertex appears more than once is a Cycle. A closed trial with distinct vertices is a
cycle as shown in Figure 12:

a
e
b

d
c

Figure 12: Cycle


a – b – c – d – a is a cycle.
 N – Cycle: A Cycle with n vertices is called as n – cycle. A cycle is even if n is even and odd if n is odd.
 Connectedness: A Pseudo graph is connected if there exists a walk between any two vertices.
A graph is connected if it is in one piece i.e. if there is a path between each pair of vertices and is
disconnected otherwise as shown in Figure 13:

Connected Graph Disconnected Graph

Figure 13: Connected and Disconnected Graph


 Bridge: An edge in a connected graph is a bridge if its removal leads to a disconnected graph.

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

Figure 14 : Components of Disconnected Graph

9.7 EULERIAN GRAPHS


A Connected graph is Eulerian if it contains a closed trial that includes every edge. Such a trail is called
as Eulerian Trail as shown in Figure 15:

B E

A D G

C F

Figure 15: Eulerian Graphs


Closed Trail including every edge:
b–e–g–f–e–d–c–f–d–b–c–a–b

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.

9.7.1 Semi–Eulerian Graph


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.

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

9.8 HAMILTONIAN GRAPHS


A Connected graph is a Hamiltonian if it contains a cycle that includes every vertex. Such a cycle is
called as Hamiltonian Cycle as shown in Figure 16:

B E

A D G

C F

Figure 16: Hamiltonian Graphs


Cycle that contains each vertex:
a – b –d – e – g – f – c – a

9.8.1 Properties of Cycles in Graph


Some of the properties of cycles in graph is as follows:
 Suppose H is a cycle in a graph G, for each vertex v of H, precisely 2 edges incident which v is in H,
hence if H is a Hamiltonian cycle of G and a vertex v in G has degree 2 then both the edges incident
with v must be a part of H.
Explanation: Any vertex (except the first and last) appears exactly once in a cycle. If the cycle is
Hamiltonian then every vertex is in H and both the edges incident with any vertex of degree 2 must
be in H.
 The only cycle contained in H is H itself, i.e., H contains no proper cycle.
Explanation: Suppose C is a cycle contained in at such that C ≠ H. Then there is a vertex y in H that is
not in C. Let x be any vertex in C since H contains both x and y. There is a path using edges of H from x
to y. Thus, H contains some edges vw where vertex v is in C but w is not. Hence, H contains two edges
of C that are incident with v together with the edge vw. Hence, there is three edges incident with v
that must be a part of H which contradicts the above property hence H is not a cycle.

9.8.2 Dirac’s Theorem


If G is a simple graph with m vertices, where m ≥ 3. If deg(v) ≥ {m}/{2} for each vertex v, then the graph
G is Hamiltonian graph.

9.8.3 Ore’s Theorem


If G is a simple graph with m vertices, where m ≥ 2 if deg(x) + deg(y) ≥ m for each pair of non-adjacent
vertices x and y, then the graph G is the Hamiltonian graph as shown in Figure 17:

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

Figure 17: Ore's Theorem


In the above example, the sum of the degree of vertices a and c is 6 and is greater than total vertices, 5
using Ore’s theorem, it is a Hamiltonian Graph.

9.8.4 Non-Hamiltonian Graph


Figure 18 depicts non-hamiltonian graph:

a 1 b

5
6 f
2
8 e
4 g
7
c
d 3

Figure 18: Non-Hamiltonian Graph


In the above example, the sum of the degree of vertices a and f is 4 and is less than total vertices, 4 using
Ore’s theorem, it is not a Hamiltonian Graph.

9.8.5 Hamiltonian Circuit


A Hamiltonian circuit is a closed walk in a graph that visits each vertex exactly once. The start and end
vertex (which happens to be the same) is visited twice.
A complete graph with m vertices has m (m -1)/2 edges. Hence, in a complete graph of m vertices where
m is odd and greater than 1, there are (m -1)/2 edge disjoint Hamiltonian Circuits.

9.9 CITY–ROUTE PUZZLE


The City–Route Puzzle is also known as Konigsberg Bridge Problem. In the 18th century, Konigsberg was
the capital of East Prussia. The Pregel river floats through the town and is split into 2 branches around
the island called Kneiphof which is labeled as A in figure a. Seven bridges cross the rivers providing links
among the 4 landmasses labelled A, B, C, D in figure a.

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

Figure 19: City-Route Puzzle


The Konigsberg bridge problem was to start on one of the landmasses, walk over each of 7 seven bridges
exactly once.
For the Konigsberg bridge problem, Euler’s idea was to realize that the physical layout of the land, water
and bridges could be modelled by the graph shown in figure b.
Landmasses are represented by small circles on the vertex and bridges are lines or edges which can be
straight or curved. Euler showed that it was not possible to choose a vertex then proceed along the edge
one after the other and return to the chosen vertex covering each edge exactly once.
Hence, it is not possible to solve the bridge problem if there are four odd vertices. According to Euler, we
could only solve it if either all the vertices in the graph were even, or if only two of the vertices were odd.

9.10 SEATING ARRANGEMENT PROBLEM


Consider the seating arrangement case:
Let us assume that the dining table is round and the total number of members is 7 (numbered from 1 to
7) as shown in Figure 20:

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

Figure 20: Seating Arrangement Problem

14
UNIT 09: Graph Theory – 1 JGI JAIN
DEEMED-TO-BE UNIVERSIT Y

Let us analyse the above images one by one:


 On Day 1, they can choose to sit in any possible arrangement as this is the time of beginning.
 On Day 2, the arrangement has to be an edge disjoint arrangement w.r.t Day 1.
 On Day 3, the arrangement has to be an edge disjoint arrangement w.r.t Day 1 and Day 2.

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

Figure 21: Example of Seating Arrangement Problem


Consider k9, a Hamiltonian cycle in k9 corresponds to seating arrangements. Each cycle has 9 edges. So
we can have,
2n + 1 = 9
2n = 9 – 1
8
n 4
2

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

9.10.1 Weighted Graph


A weighted graph is a graph G with vertices V and edges E, together with the function :E [0,], if e is
an edge the non-negative real number (e) is called the weight of e.
Note: The weight of a subgraph of G is the sum of the weights of the edges of the subgraph.

9.11 TRAVELLING–SALESMAN PROBLEM


On a Business Trip, a travelling salesman visits various towns and cities assigning each edge of weight
equal to the travel time between the cities at the ends, the travelling salesman’s graph becomes a
weighted graph. If the salesman doesn’t want to pass through the same community twice he needs a
Hamiltonian cycle through the graph. Among all the Hamiltonian Cycles, the salesman would like to
find, the cycle whose weight is minimum.
To find the Hamiltonian cycle of least weight in a weighted graph is called a Travelling Salesman Problem.

9.11.1 Dijkstra’s Algorithm


To find the shortest path from vertex A to vertex E in a weighted graph, we carry out the following
procedure:
 Step 1: Assign A the label (- , 0 ).
 Step 2: Until E is labelled or no further labels can be assigned, do the following:
 For each labelled vertex u (x, d) and each unlabelled vertex v adjacent to u, compute d + w(e)
where e is an edge in uv.
 Find the minimum value d of all the numbers d + w(e) found in a.
 For each u and v for which d + w(e) = d assign to v, the label (u, d). If a vertex can be labelled
(x, d) for various vertex x make your own choice and proceed further.
Example: Solve the following travelling salesman problem, for the graph shown in fig starting at vertex
V1 and ending at V1. Figure 22 depicts travelling-salesman problem:

V1

5 4

V2 2 V3
5

3 3
8

2 5

2
V4 V5

Figure 22: Travelling-Salesman Problem

16
UNIT 09: Graph Theory – 1 JGI JAIN
DEEMED-TO-BE UNIVERSIT Y

Solution: We have to start with vertex V1.

 Step 1: V1(-, 0), d = 0


For V4, d + w(e) = 5
For V5, d + w(e) = 8
For V2, d + w(e) = 5
For V3, d + w(e) = 4
min (d + w(e)) = 4

 Step 2: V3(V1, 4), Adjacent to V3 are V2, V4, V5


For V2, d + w(e) = 6
For V4, d + w(e) = 7
For V5, d + w(e) = 9
min (d + w(e)) = 6
V2(V3, 6) , Adjacent to V2 are V4 ,V5
For V4, d + w(e) = 8
For V5, d + w(e) = 9
min (d + w(e)) = 8
V4(V2, 8), Adjacent to V4 is V5
For V5, d + w(e) = 10

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

Conclusion 9.12 CONCLUSION

 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.

9.14 SELF-ASSESSMENT QUESTIONS

A. Essay Type Questions


1. What is the concept of graphs?
2. Explain the significance of sub graphs?
3. What is an isomorphic graph?
4. Describe the concept of Eulerian graph?
5. Explain Travelling-salesman problem with suitable example.

9.15 ANSWERS AND HINTS FOR SELF-ASSESSMENT QUESTIONS

B. Hints for Essay Type Questions


1. 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. Refer to Section Introduction
2. A graph G1 is a subgraph of another graph G if and only if the vertex and edge set of G1 are
respectively subsets of vertex and edge sets of G. Refer to Section Sub Graphs
3. 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 G1iff f(v) is incident with f(e) in G2.
Refer to Section Isomorphic Graphs
4. A Connected graph is Eulerian if it contains a closed trial that includes every edge. Such a trail is
called as Eulerian Trail. Refer to Section Eulerian Graphs
5. To find the Hamiltonian cycle of least weight in a weighted graph is called a Travelling Salesman
Problem. Refer to Section Travelling-Salesman Problem

@ 9.16 POST-UNIT READING MATERIAL

 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

9.17 TOPICS FOR DISCUSSION FORUMS

 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

You might also like