Download presentation
Presentation is loading. Please wait.
1
Traveling Salesman Problems Repetitive Nearest-Neighbor and Cheapest-Link Algorithms Chapter: 6
2
Repetitive Nearest-Neighbor Algorithm Let A be any vertex. Apply the nearest-neighbor algorithm using A as the starting vertex and calculate the total cost associated with the circuit. Repeat the process using each of the other vertices (B,C, D, E) of the graph as the staring vertex. Keep the best one from all the Hamilton circuits. If there is a designated starting vertex, rewrite this circuit with that vertex as the reference point.
3
Repetitive Nearest-Neighbor Algorithm $133 $185 $121 $174 $199 $200 $120 $152 $150 $119 A B C D E Step 1: Let A be any vertex. Apply nearest-neighbor Algo. Calculate the cost of circuit At point A: EdgeWeight AE$133 AD$152 AC$119 Min AB$185
4
Repetitive Nearest-Neighbor Algorithm $133 $185 $121 $174 $199 $200 $120 $152 $150 $119 A B C D E Step 1: Let A be any vertex. Apply nearest-neighbor Algo. Calculate the cost of circuit At point C: EdgeWeight CB$121 CA$119 Already visited CE$120 Min CD$174
5
Repetitive Nearest-Neighbor Algorithm $133 $185 $121 $174 $199 $200 $120 $152 $150 $119 A B C D E Step 1: Let A be any vertex. Apply nearest-neighbor Algo. Calculate the cost of circuit At point E: EdgeWeight EA$133 Cannot revisit A as all vertices are visited yet EB$200 EC$120 Already visited ED$199 Min
6
Repetitive Nearest-Neighbor Algorithm $133 $185 $121 $174 $199 $200 $120 $152 $150 $119 A B C D E Step 1: Let A be any vertex. Apply nearest-neighbor Algo. Calculate the cost of circuit At point D: EdgeWeight DE$199 DA$152 DB$150 Min DC$174
7
Repetitive Nearest-Neighbor Algorithm $133 $185 $121 $174 $199 $200 $120 $152 $150 $119 A B C D E Step 1: Let A be any vertex. Apply nearest-neighbor Algo. Calculate the cost of circuit At point B: From the last vertex (B), return to the starting point (A). All vertices have been visited Selected edge: BA
8
Repetitive Nearest-Neighbor Algorithm $133 $185 $121 $174 $199 $200 $120 $152 $150 $119 A B C D E Step 1: Let A be any vertex. Apply nearest-neighbor Algo. Calculate the cost of circuit Using the Nearest-Neighbor algorithm with A as the starting vertex, we got: Hamilton circuit: A, C, E, D, B, A Cost associated with the Hamilton circuit: $119+$120+$199+ $150+$185 = $773
9
Repetitive Nearest-Neighbor Algorithm Starting pointHamilton CircuitCost BB, C, A, E, D, B$722 CC, A, E, D, B, C$722 DD, B, C, A, E, D$722 EE, C, A, D, B, E$741 $133 $185 $121 $174 $199 $200 $120 $152 $150 $119 A B C D E Step 2: Repeat the process using each of the other vertices (B,C, D, E) of the graph as the staring vertex.
10
Repetitive Nearest-Neighbor Algorithm Starting pointHamilton CircuitCost AA, C, E, D, B, A$773 BB, C, A, E, D, B$722 CC, A, E, D, B, C$722 DD, B, C, A, E, D$722 EE, C, A, D, B, E$741 $133 $185 $121 $174 $199 $200 $120 $152 $150 $119 A B C D E Step 3: Keep the best one from all the Hamilton circuits. If there is a designated starting vertex, rewrite this circuit with that vertex as the reference point.
11
Repetitive Nearest-Neighbor Algorithm The Best one from all Hamilton circuits: B, C, A, E, D, B C, A, E, D, B, C D, B, C, A, E, D B, C, A, E, D, B Rewrite with A as the starting vertex A, E, D, B, C, A B, C, A, E, D, B Rewrite with C as the starting vertex C, A, E, D, B, C B, C, A, E, D, B Rewrite with E as the starting vertex E, D, B, C, A, E $133 $185 $121 $174 $199 $200 $120 $152 $150 $119 A B C D E Step 3: Keep the best one from all the Hamilton circuits. If there is a designated starting vertex, rewrite this circuit with that vertex as the reference point. Tie: Select randomly
12
Cheapest-Link Algorithm $133 $185 $121 $174 $199 $200 $120 $152 $150 $119 A B C D E Pick the edge with the smallest weight first. Mark the edge (say in red). Pick the next “cheapest” edge and mark the edge in red. Continue picking the “cheapest” edge available and mark the edge in red except when –It closes a circuit –It results in three edges coming out of a single vertex When there are no more vertices to join, close the red circuit.
13
Cheapest-Link Algorithm $133 $185 $121 $174 $199 $200 $120 $152 $150 $119 A B C D E Step 1: Pick the edge with the smallest weight first. Mark the edge (say in red). Edge AC (Weight: $119)
14
Cheapest-Link Algorithm $133 $185 $121 $174 $199 $200 $120 $152 $150 $119 A B C D E Step 2: Pick the next “cheapest” edge. Mark the edge (say in red). Edge EC (Weight: $120)
15
Cheapest-Link Algorithm $133 $185 $121 $174 $199 $200 $120 $152 $150 $119 A B C D E Step 3: Continue picking the next “cheapest” edge. Mark the edge (say in red) except when it results in 3 edges coming out of a single vertex. Edge BC Weight ($121)
16
Cheapest-Link Algorithm $133 $185 $121 $174 $199 $200 $120 $152 $150 $119 A B C D E Step 3: Continue picking the next “cheapest” edge. Mark the edge (say in red) except when it closes a circuit. Edge AE Weight ($133)
17
Cheapest-Link Algorithm $185 $174 $199 $200 $120 $152 $150 $119 A B C D E Step 3: Continue picking the next “cheapest” edge. Mark the edge (say in red). Edge BD Weight ($150)
18
Cheapest-Link Algorithm $185 $174 $199 $200 $120 $152 $150 $119 A B C D E Step 3: Continue picking the next “cheapest” edge. Mark the edge (say in red). Edge AD Weight ($152)
19
Cheapest-Link Algorithm $185 $174 $199 $200 $120 $152 $150 $119 A B C D E Step 4: When there are no more vertices to join, close the red circuit Edge EB Weight ($200)
20
Summary of Cheapest-Link Algorithm $185 $174 $199 $200 $120 $152 $150 $119 A B C D E StepCheapest edgeWeightUsed in circuit? 1AC$119Yes 2EC$120Yes 3BC$121No, step 3(b) 4EA$133No, step 3(a) 5DB$150Yes 6AD$152Yes 7EB$200Yes, close the ckt.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.