2-opt swap move

:

  1. Given some route , we choose two non-adjacent edges in the cycle.
  2. Compare the weight of these two edges. with
  3. If the second pair of edges are smaller than the first, , we replace the two first edges to reduce our total graph weight.
  4. Ensure the swap does not disconnect the graph.

2-opt approximation algorithm

The 2-opt algorithm is a polynomial-time algorithm for solving TSP that is no worse than twice the global optimal solution.

Given some graph . We can use a Minimum Spanning Tree algorithm to produce tree . Then perform Preorder traversal on the nodes in order to find a Hamiltonian cycle . Using this path, we perform 2-opt swap move on while the path is not optimal.

:

  1. Construct MST of
  2. Let be the preorder traversal of .
  3. While is not local optimal:
  4. Return

[todo:gif of pdf slides running algorithm]

Proving Approximation Ratio for 2-opt

Theorem: the 2-opt algorithm has an approximation ratio of . Proof:

  1. Let and denote the local optimum found by 2-opt and the global optimum Hamiltonian cycle respectively. We want to show .
  2. Remove one edge from to create a path . This new path is a tree and still connects all points.
  3. Let denote the minimum spanning tree as computed by the first step of the 2-opt. It follows that .
  4. The length of the preorder traversal is at most twice the length of the spanning tree.
  5. Every application of the 2-opt swap only goes to further reduce the length of the cycle, such that:
  6. Hence we can summarise this as:

Hence, we can also state that TSP is 2-approximable.

Some algorithms push this further, such as the Christofides ‘76 algorithm, which is -approx.