Skip to content
← All questions

How does a 2-Opt swap work to improve a route?

A 2-Opt swap improves a route by selecting two edges in the current route, removing them, and reconnecting the four endpoints in a different way to form a new, valid cycle. This operation is particularly effective at eliminating self-intersections in a route, thereby reducing the total distance.

Conditions

  • Requires an existing valid TSP route.
  • Involves selecting two distinct edges.
  • The reconnection must produce a single valid cycle.

Reasoning, step by step

  1. Identify two edges in the current route that can be swapped.
  2. Remove the two selected edges.
  3. Reconnect the four endpoints of the removed edges in a different configuration.
  4. Verify that the new configuration forms a valid single cycle.
  5. Calculate the new total distance to confirm improvement.

Example

The video shows a 2-Opt swap being applied to a self-crossing greedy route, successfully eliminating the intersection and reducing the total distance from 8969 km to 8570 km.

Common misconceptions

  • Believing that a 2-Opt swap can only be applied to routes generated by the Greedy Algorithm.
  • Assuming that any random reconnection of two edges will always improve the route.

Watch the explanation

Explore next

Answers are generated from source material and independently checked. Consult the original video or creator if something is unclear.