Travelling salesman problem is the most notorious computational
problem. We can use brute-force approach to evaluate every
possible tour and select the best one. For n number of vertices in a
graph, there are (n−1)! number of possibilities. Thus, maintaining a
higher complexity.
However, instead of using brute-force, using the dynamic
programming approach will obtain the solution in lesser time,
though there is no polynomial time algorithm.
Travelling Salesman Dynamic Programming
Algorithm
Let us consider a graph G = (V,E), where V is a set of cities and E is
a set of weighted edges. An edge e(u, v) represents that
vertices u and v are connected. Distance between
vertex u and v is d(u, v), which should be non-negative.
Suppose we have started at city 1 and after visiting some cities now
we are in city j. Hence, this is a partial tour. We certainly need to
know j, since this will determine which cities are most convenient to
visit next. We also need to know all the cities visited so far, so that
we don't repeat any of them. Hence, this is an appropriate sub-
problem.
For a subset of cities S ϵ� {1,2,3,...,n} that includes 1,
and j ϵ� S, let C(S, j) be the length of the shortest path visiting
each node in S exactly once, starting at 1 and ending at j.
When |S|> 1 , we define 𝑪C(S,1)= ∝∝ since the path cannot start
and end at 1.
Now, let express C(S, j) in terms of smaller sub-problems. We need
to start at 1 and end at j. We should select the next city in such a
way that
C(S,j)=minC(S−{j},i)+d(i,j)whereiϵS and i≠j