Reducing Knapsack to TSP

Download Report

Transcript Reducing Knapsack to TSP

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
3
n+1
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
5
2
7
n+1
11
n+1
11
7
5
0
5
3
5
3
n+1
7
11
11
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
5
2
7
7
7
7
7
5
0
5
3
5
3
7
11 11
11
11
11
0
0
0
0
0
n+1