60 likes | 249 Views
Reducing Knapsack to TSP. Professor Pasi Franti. Step 1: Equivalent Graph Construction. Given Knapsack instance: KP={2,3,5,7,11} Draw A node in the plane for each item:. 2. 7. 5. 3. 11. Step 1: Equivalent Graph Construction. Given Knapsack instance: KP={2,3,5,7,11}
E N D
Reducing Knapsack to TSP Professor Pasi Franti
Step 1: Equivalent Graph Construction • Given Knapsack instance: • KP={2,3,5,7,11} • Draw A node in the plane for each item: 2 7 5 3 11
Step 1: Equivalent Graph Construction • Given Knapsack instance: • KP={2,3,5,7,11} • Add starting node and ending node: 2 7 5 0 n+1 3 11 Note: total of n+2 nodes required for a Knapsack instance of n items
Step 1: Equivalent Graph Construction • Given Knapsack instance: • KP={2,3,5,7,11} • Draw links from each smaller node to the bigger node with the weight w equal to destination node: 7 2 7 n+1 11 5 n+1 2 11 7 5 5 0 n+1 3 5 7 11 11 3 11
Step 1: Equivalent Graph Construction • Given Knapsack instance: • KP={2,3,5,7,11} • Assume for each node that going back cost is 0 and going up cost is w: 7 2 7 7 5 7 7 2 0 7 0 5 0 5 0 n+1 0 3 0 5 7 11 11 11 3 11 11