TRAVELLING SALESMAN PROBLEM
DYNAMIC PROGRAMMING
SOLUTION
SAMPLE GRAPH
COST(k,l) = 10(k+l)
30
3
50
30
70
50
2
60
THE TRAVELLING SALESMAN PROBLEM
In a complete weighted graph find a tour of minimum cost.
Let a journey be defined as follows. A journey J(k,S) starts at a node k, passes
through all the nodes in S at most once and terminates at node 1. S is a subset of the
nodes of the graph excluding node 1.
S is the null set
J(2,) = 30, J(3,) = 40, J(4,) = 50---direct paths to node 1.
S has one element
J(2, {3}) = cost(2,3) + J(3, ) = 50 + 30 = 80
J(2, {4}) = cost(2,4) + J(4, ) = 60 + 40 = 100
J(3, {2}) = cost(3,2) + J(3, ) = 50 + 30 = 80
J(3, {4}) = cost(3,4) + J(4, ) = 70 + 40 = 110
J(4, {2}) = cost(4,2) + J(2, ) = 60 + 20 = 80
J(4, {3}) = cost(4,3) + J(3, ) = 70 + 30 = 100
S has two elements
J(2, {3,4}) = min{cost(2,3) + J(3, {4}), cost(2,4) + J(4, {3})}= min(50 + 110, 60 + 100)
= min(160,160) = 160
J(3, {2,4})=min{ cost(3,2) + J(2,{4}), cost(3,4) + J(4, {3})}= min(50 + 100, 70 + 100)
=min(150,170)=150
J(4, {2,3})=min{ cost(4,2) + J(2, {3}), cost(4,3) + J(3, {2})} = min(60 + 80, 70 + 80)
=min(140, 150) = 140
S has three elements
J(1, {2,3,4}) = min{ cost(1,2) + J(2, {3,4}), cost(1,3) + J(3, {2,4}),
cost(1,4) + J(4,{2,3})}
= min{ 30 + 160, 40 + 150, 50 + 140}
= min(190,190,190)
= 190
THE MINIMUM COST TOURS ARE THUS
1-2-4-3-1 OR 1-3-2-4-1 OR 1-4-2-3-1
OR 1-3-4-2-1
SAMPLE GRAPH
COST(k,l) = 10(k+l)
30
3
50
30
70
50
2
60