COM­P4804: Al­go­rithms II
$\new­com­mand{\R}{\mathbb{R}}\De­clar­e­Math­Op­er­a­tor{\E}{\mathbf{E}}\De­clar­e­Math­Op­er­a­tor{\deg}{deg}$
Ap­prox­i­ma­tions for the TSP

Imag­ine we have a trav­el­ling sales­man who starts in some city and has to visit each of $n-1$ other cities (to sell some­thing in each one) and re­turn home. He wants to do this tour with as lit­tle cost as pos­si­ble. Here, cost might be travel time, gaso­line, elec­tric­ity, you name it.

The Met­ric Trav­el­ling Sales­man prob­lem

The input is an $n\times n$ dis­tance ma­trix $d$ where $d_{i,j}$ de­notes the cost of trav­el­ling from city $i$ to city $j$. This ma­trix de­fines met­ric:

  1. $d_{i,j}\ge 0$ for all $i,j\in\{1,\ldots,n\}$ (non-neg­a­tive)
  2. $d_{i,i} = 0$ for all $i\in\{1,\ldots,n\}$
  3. $d_{i,j}=d_{j,i}$ for all $i,j\in\{1,\ldots,n\}$ (sym­met­ric)
  4. $d_{i,k}\le d_{i,j} + d_{j,k}$ for all $i,j,k\in\{1,\ldots,n\}$ (tri­an­gle in­equal­ity)

The goal is to find a per­mu­ta­tion $\pi=\pi_1,\ldots,\pi_n$ of $1,\ldots,n$ that min­i­mizes the func­tion \[ w(\pi) = \sum_{i=1}^{n-1}d_{\pi_i,\pi_{i+1}} + d_{\pi_n,\pi_1} \en­space . \]

An Ap­prox­i­ma­tion Based on the Min­i­mum Span­ning Trees

We can think of $d$ as a com­plete weighted graph $G$ whose ver­tex set is $V=\{1,\ldots,n\}$ and for which the weight of the edge $ij$ is $d_{i,j}$. We can com­pute the min­i­mum span­ning tree of this graph in $O(n^2)$ time using an old al­go­rithm of Borůvka.

A minimum spanning tree

Let $T$ be this min­i­mum span­ning tree and imag­ine per­form­ing a tra­ver­sal of $T$ and record­ing the list of ver­tices as we en­counter them. This gives us a list of ver­tices in which the num­ber of times a par­tic­u­lar ver­tex $v$ ap­pears is equal to its de­gree, $\deg(v)$.

Traversing the MST

In this ex­am­ple, we ob­tain the se­quence \[ S_1 = 1, 3, 1, 2, 4, 5, 6, 5, 4, 8, 7, 8, 10, 8, 9, 8, 4, 2, 1 \en­space . \] Now, re­move all but the first oc­curence of each ver­tex in his se­quence (ex­cept 1): \[ S_2 = 1, 3, 2, 4, 5, 6, 8, 7, 10, 9, \en­space . \]

Shortcuts

Note that $S_2$ is a per­mu­ta­tion of $\{1,\ldots,n\}$ since $S_1$ con­tains every el­e­ment of $\{1,\ldots,n\}$ at least once and there­fore $S_2$ con­tains every el­e­ment ex­actly once. There­fore, $S_2$ is a valid so­lu­tion for the Trav­el­ling Sales­man Prob­lem. How good is it?

Each edge of T is used ex­actly twice $S_1$, so \[ w(S_1) = 2w(T) \en­space . \] By the tri­an­gle in­equal­ity \[ w(S_2) \le w(S_1) \en­space . \] Re­mem­ber that $T$ is a min­i­mum span­ning tree; it's a min­i­mum weight con­nected sub­graph of $G$. But a trav­el­ling sales­man tour is also a con­nected sub­graph of $G$, so \[ w(T) \le w(C^\star) \en­space , \] where $C^\star$ is any op­ti­mal trav­el­ling sales­man tour. Putting all these to­gether, we have \[ w(S_2) \le w(S_1) \le 2w(T) \le 2w(C^\star) \en­space . \] We have just found a so­lu­tion, $S_2$, to the trav­el­ling sales­man prob­lem whose weight is at most twice that of the op­ti­mal so­lu­tion.

The­o­rem: There is an $O(n^2)$ time al­go­ritm that solves pro­duces a so­lu­tion to the trav­el­ling sales­man prob­lem whose cost is at most twice that of an op­ti­mal so­lu­tion.

Christofides' al­go­rithm

We can think of the pre­ced­ing al­go­rithm as start­ing with the min­i­mum span­ning tree $T$ and then dou­bling each edge of $T$ to ob­tain an­other (non-sim­ple) graph $T'$. The de­gree of each ver­tex in $T'$ is dou­ble its de­gree in $T$. In par­tic­u­lar, the de­gree of each ver­tex is even. This means that $T'$ is Euler­ian, there is a closed walk in $T'$ that crosses every each of $T'$ ex­actly once. It's this walk that we use to make $S_1$ and the weight of this walk is, of course, $2w(T)$ be­cause it uses each edge of $T$ twice.

But there's a bet­ter way to make $T$ Euler­ian. Let $V'$ be the set of $T$'s odd de­gree ver­tices. Con­vince your­self that $|V'|$ is even. Now, group the ver­tices of $V'$ into pairs and. for each pair, add an edge be­tween them to ob­tain a new graph $T''$. Call this set of $|V'|/2$ edges $M$ (for match­ing). Now $T''$ is also Euler­ian, so there is a closed walk that crosses each of edges ex­actly once.

A minimum spanning tree

This means that we have found a so­lu­tion to the trav­el­ling sales­man prob­lem whose cost is \[ w(T) + w(M) \] We al­ready know that $w(T)\le w(C^\star)$. For $M$, we rely on an al­go­rithm for the min­i­mum weight per­fect match­ing prob­lem, which runs in $O(n^3)$ time. Still, we need to re­late $w(M)$ to $w(C^\star)$. To do this, con­nect the ver­tices in $V'$ into a cycle, $C$, in the order they ap­pear in $C^\star$. By the tri­an­gle in­equal­ity $w(C) \le w(C^\star)$. What's more, $C$ can be par­ti­tioned into two per­fect match­ing by al­ter­nately col­or­ing its edges red and blue. One of these two match­ings has weight at most $w(C)/2$. Now $M$ is a min­i­mum weight per­fect match­ing of $V'$, so \[ w(M) \le w(C)/2 \le w(C^\star)/2 \en­space . \] And that's it, the so­lu­tion we've found has weight \[ w(T) + w(M) \le w(C^\star) + w(C^\star)/2 = \frac{3}{2}w(C^\star) \]

The­o­rem: There is an $O(n^3)$ time al­go­ritm that solves pro­duces a so­lu­tion to the trav­el­ling sales­man prob­lem whose cost is at most $3/2$ that of an op­ti­mal so­lu­tion.