2. Contents
Introduction
Hamiltonian Graph
Algorithm : Travelling Salesman Problem
Time Complexity
Simple Example
Applications
Conclusion
References
3. Introduction
Travelling salesman route will be plan in such a way that in a
given N number of cities cost of travelling from one city to any
other city what is the minimum round trip route that visit each
city once and then return to the starting place. The goal is to find
the shortest tour that visit each city in a given cities exactly ones
and then return to the starting city. The only solution to the
travelling salesman problem is to calculate and compare the
length of all possible ordered combinations.
4. Graph Representation
Adjacency Matrix: An adjacency matrix is a matrix which describes a graph by
representing which vertices are adjacent to which other vertices. If G is a graph of order
n, then its adjacency matrix is an n×n square matrix, where each row and column
corresponds to a vertex of G. The element aij of such a matrix specifies the number of
edges from vertex i to vertex j.
Adjacency List: An adjacency list represents a graph as an array of linked list. The
index of the array represents a vertex and each element in its linked list represents the
other vertices that form an edge with the vertex.
5. Hamiltonian graph
A Hamiltonian path or traceable path is a path that visits
each vertex of the graph exactly once. A graph that
contains a Hamiltonian path is called a traceable graph.
A graph is Hamiltonian-connected it for every pair of
vertices there is a Hamiltonian path between the two
vertices.
6. Dynamic Programming
Dynamic Programming is also used in optimization problems.
Like divide-and-conquer method, Dynamic Programming solves
problems by combining the solutions of subproblems. Moreover,
Dynamic Programming algorithm solves each sub-problem just
once and then saves its answer in a table, thereby avoiding the
work of re-computing the answer every time.
7. Algorithm: Traveling-Salesman-
Problem
1. 𝐶 ({1}, 1) = 0
2. for 𝑠 = 2 to n do
3. for all subsets 𝑆 Є {1, 2, 3, … , 𝑛} of size s and containing 1
4. 𝐶 (𝑆, 1) = ∞
5. for all 𝑗 Є 𝑆 and 𝑗 ≠ 1
6. 𝐶 (𝑆, 𝑗) = 𝑚𝑖𝑛 {𝐶 (𝑆 – {𝑗}, 𝑖) + 𝑑(𝑖, 𝑗) 𝑓𝑜𝑟 𝑖 Є 𝑆 𝑎𝑛𝑑 𝑖 ≠ 𝑗}
7. Return 𝑚𝑖𝑛𝑗 𝐶 ({1, 2, 3, … , 𝑛}, 𝑗) + 𝑑(𝑗, 𝑖)
8. Time Complexity
There are at the most 2 𝑛 .n sub-problems and each one
takes linear time to solve. Therefore, the total running
time is 𝑂(2 𝑛 . 𝑛 2 ).
9. Simple Example
IS there a route that
takes you through every
city and back to the
starting point 1 for less
than 7.
The solution is : 13241
10. Applications
A real-world application that calculates the
route of the Travelling Salesman Problem using
the current traffic intensity information from
Google Maps is prepared.
A user-friendly interface, displaying the
shortest route in distance or duration on Google
Maps, has been developed by adding different
features.
11. Conclusion
• It can be concluded that on application of TSP
algorithm with dynamic programming is able to
produce optimal route tour to serve a customers
including the shortest or minimum length of
travel time or optimal travel time.