Christofides algorithm: Difference between revisions

Content deleted Content added
No edit summary
 
(25 intermediate revisions by 14 users not shown)
Line 1:
{{Short description|Approximation for the travelling salesman problem}}
{{CS1 config|mode=cs2}}
The '''Christofides algorithm''' or '''Christofides–Serdyukov algorithm''' is an [[algorithm]] for finding approximate solutions to the [[travelling salesman problem]], on instances where the distances form a [[metric space]] (they are symmetric and obey the [[triangle inequality]]).<ref name="gt">{{citation|title=Algorithm Design and Applications|first1=Michael T.|last1=Goodrich|author1-link=Michael T. Goodrich|first2=Roberto|last2=Tamassia|author2-link=Roberto Tamassia|publisher=Wiley|year=2015|pages=513–514|chapter=18.1.2 The Christofides Approximation Algorithm}}.</ref>
It is an [[approximation algorithm]] that guarantees that its solutions will be within a factor of 3/2 of the optimal solution length, and is named after [[Nicos Christofides]] and [[Anatoliy I. Serdyukov]] ({{lang-langx|ru|Анатолий Иванович Сердюков}});. Christofides published the latteralgorithm in 1976; Serdyukov discovered it independently in 1976 (but thepublished publicationit is datedin 1978).<ref name=cri>{{citation|last=Christofides|first=Nicos|author-link=Nicos Christofides|year=1976|title=Worst-case analysis of a new heuristic for the travelling salesman problem|others=Report 388|institution=Graduate School of Industrial Administration, CMU|url=https://apps.dtic.mil/dtic/tr/fulltext/u2/a025602.pdf|archive-url=https://web.archive.org/web/20190721172134/https://apps.dtic.mil/dtic/tr/fulltext/u2/a025602.pdf|url-status=live|archive-date=July 21, 2019}}
</ref><ref name=vabe>{{citation|last1=van Bevern|first1=René|last2=Slugina|first2=Viktoriia A.|year=2020|title=A historical note on the 3/2-approximation algorithm for the metric traveling salesman problem|journal=Historia Mathematica|volume=53|pages=118–127|doi=10.1016/j.hm.2020.04.003|arxiv=2004.02437|s2cid=214803097}}
</ref><ref name=ser>{{citation|last=Serdyukov|first=Anatoliy|date=1978|title=О некоторых экстремальных обходах в графах|trans-title = On some extremal walks in graphs|language=ru|url=http://nas1.math.nsc.ru/aim/journals/us/us17/us17_007.pdf|journal=Upravlyaemye Sistemy (Управляемые системы)|volume=17|pages=76–79}}</ref>
Line 11 ⟶ 13:
# Create a [[minimum spanning tree]] {{mvar|T}} of {{mvar|G}}.
# Let {{mvar|O}} be the set of vertices with odd [[degree (graph theory)|degree]] in {{mvar|T}}. By the [[handshaking lemma]], {{mvar|O}} has an even number of vertices.
# Find a minimum-weight [[perfect matching]] {{mvar|M}} in the subgraph [[induced subgraph|induced]] givenin by{{mvar|G}} the vertices fromby {{mvar|O}}.
# Combine the edges of {{mvar|M}} and {{mvar|T}} to form a connected [[multigraph]] {{mvar|H}} in which each vertex has even degree.
# Form an [[Eulerian circuit]] in {{mvar|H}}.
# Make the circuit found in previous step into a [[Hamiltonian circuit]] by skipping repeated vertices (''shortcutting'').
 
The stepsSteps 5 and 6 do not necessarily yield only onea single result.; Asas such, the heuristic can give several different paths.
 
===Computational complexity===
The worst-case complexity of the algorithm is dominated by the perfect matching step, which has <math> O(n^3) </math> complexity.<ref name=cri/> Serdyukov's paper claimed <math> O(n^3 \log n) </math> complexity,<ref name=ser/> because the author was only aware of a less efficient perfect matching algorithm.<ref name=vabe/>
 
== Approximation ratio ==
 
The cost of the solution produced by the algorithm is within {{math|3/2}} of the optimum.
To prove this, let {{mvar|C}} be the optimal traveling salesman tour. Removing an edge from {{mvar|C}} produces a spanning tree, which must have weight at least that of the minimum spanning tree, implying that {{math|''w''(''T'') ≤ ''w''(''C'')}} - lower bound to the cost of the optimal solution.
 
The algorithm addresses the problem that {{math|T}} is not a tour by identifying all the odd degree vertices in {{math|T}}; since the sum of degrees in any graph is even (by the [[handshaking lemma]]), there is an even number of such vertices. The algorithm finds a minimum-weight perfect matching {{math|M}} among the odd-degree ones.
 
Next, number the vertices of {{mvar|O}} in cyclic order around {{mvar|C}}, and partition {{mvar|C}} into two sets of paths: the ones in which the first path vertex in cyclic order has an odd number and the ones in which the first path vertex has an even number.
Each set of paths corresponds to a perfect matching of {{mvar|O}} that matches the two endpoints of each path, and the weight of this matching is at most equal to the weight of the paths. In fact, each path endpoint will be connected to another endpoint, which also has an odd number of visits due to the nature of the tour.
 
Since these two sets of paths partition the edges of {{mvar|C}}, one of the two sets has at most half of the weight of {{mvar|C}}, and thanks to the triangle inequality its corresponding matching has weight that is also at most half the weight of {{mvar|C}}.
The minimum-weight perfect matching can have no larger weight, so {{math|''w''(''M'') ≤ ''w''(''C'')/2}}.
Adding the weights of {{mvar|T}} and {{mvar|M}} gives the weight of the Euler tour, at most {{math|3''w''(''C'')/2}}. Thanks to the triangle inequality, even though the Euler tour might revisit vertices, shortcutting does not increase the weight,
so the weight of the output is also at most {{math|3''w''(''C'')/2}}.<ref name="gt" />
 
==Lower bounds==
There exist inputs to the travelling salesman problem that cause the Christofides algorithm to find a solution whose approximation ratio is arbitrarily close to {{math|3/2}}. One such class of
inputs are formed by a [[path (graph theory)|path]] of {{mvar|n}} vertices, with the path edges having weight {{math|1}}, together with a set of edges connecting vertices two steps apart in the path with weight {{math|1 + ''ε''}}
for a number {{math|''ε''}} chosen close to zero but positive.

All remaining edges of the complete graph have distances given by the [[Shortest path problem|shortest path]]s in this subgraph.
Then the minimum spanning tree will be given by the path, of length {{math|''n'' &minus; 1}}, and the only two odd vertices will be the path endpoints, whose perfect matching consists of a single edge with weight approximately {{math|''n''/2}}.
 
The union of the tree and the matching is a cycle, with no possible shortcuts, and with weight approximately {{math|3''n''/2}}. However, the optimal solution uses the edges of weight {{math|1 + ''ε''}} together with two weight-{{math|1}} edges incident to the endpoints of the path,
and has total weight {{math|(1 + ''ε'')(''n'' &minus; 2) + 2}}, close to {{mvar|n}} for small values of {{math|''ε''}}. Hence we obtain an approximation ratio of 3/2.<ref>{{citation|title=Encyclopedia of Algorithms}|editor-first=Ming-Yang|editor-last=Kao|publisher=Springer-Verlag|year=2008|isbn=9780387307701|chapter-url=https://books.google.com/books?id=i3S9_GnHZwYC&pg=PA517|pages=517–519|chapter=Metric TSP|first=Markus|last=Bläser}}.</ref>
Line 55 ⟶ 64:
|[[File:TuM.svg|200px]] || Unite matching and spanning tree {{math|''T'' &cup; ''M''}} to form an Eulerian multigraph
|-
|[[File:Eulertour.svg|200px]] || Calculate Euler tour<br><br>Here the tour goes A->&rarr;B->&rarr;C->&rarr;A->&rarr;D->&rarr;E->&rarr;A. Equally valid is A->&rarr;B->&rarr;C->&rarr;A->&rarr;E->&rarr;D->&rarr;A.
|-
|[[File:Eulertour bereinigt.svg|200px]] || Remove repeated vertices, giving the algorithm's output.<br><br>If the alternate tour would have been used, the shortcut would be going from C to E which results in a shorter route (A->&rarr;B->&rarr;C->&rarr;E->&rarr;D->&rarr;A) if this is an euclidean graph as the route A->&rarr;B->&rarr;C->&rarr;D->&rarr;E->&rarr;A has intersecting lines which is proven not to be the shortest route.
|}
 
==Further developments==
This algorithm is no longer the best polynomial time approximation algorithm for the TSP on general metric spaces. Karlin, Klein, and Gharan introduced a [[randomized algorithm|randomized]] approximation algorithm with approximation ratio 1.5&nbsp;&minus;&nbsp;10<sup>−36</sup>. It follows similar principles to Christofides' algorithm, but uses a randomly chosen tree from a carefully chosen random distribution in place of the minimum spanning tree.<ref>{{citation
This algorithm still stands as the best polynomial time approximation algorithm that has been thoroughly peer-reviewed by the relevant scientific community for the traveling salesman problem on general metric spaces. In July 2020 Karlin, Klein, and Gharan released a preprint in which they introduced a novel approximation algorithm and claimed that its approximation ratio is 1.5&nbsp;&minus;&nbsp;10<sup>−36</sup>. Theirs is a [[randomized algorithm]] and it follows similar principles to Christofides' algorithm, but uses a randomly chosen tree from a carefully chosen random distribution in place of the minimum spanning tree.<ref>{{cite arXiv|last1=Karlin|first1=Anna R.|author1-link=Anna Karlin|last2=Klein|first2=Nathan|last3=Gharan|first3=Shayan Oveis|date=2020-08-30|title=A (Slightly) Improved Approximation Algorithm for Metric TSP|class=cs.DS|eprint=2007.01409}}</ref><ref>{{Cite web|last=Klarreich|first=Erica|author-link=Erica Klarreich|title=Computer Scientists Break Traveling Salesperson Record|url=https://www.quantamagazine.org/computer-scientists-break-traveling-salesperson-record-20201008/|access-date=2020-10-10|website=Quanta Magazine|date=8 October 2020|language=en}}</ref> The paper was published at [[Symposium on Theory of Computing|STOC'21]]<ref>{{Citation |last=Karlin |first=Anna R. |title=A (slightly) improved approximation algorithm for metric TSP |date=2021-06-15 |url=https://doi.org/10.1145/3406325.3451009 |work=Proceedings of the 53rd Annual ACM SIGACT Symposium on Theory of Computing |pages=32–45 |place=New York, NY, USA |publisher=Association for Computing Machinery |doi=10.1145/3406325.3451009 |isbn=978-1-4503-8053-9 |access-date=2022-04-20 |last2=Klein |first2=Nathan |last3=Gharan |first3=Shayan Oveis|arxiv=2007.01409 }} ([https://arxiv.org/pdf/2007.01409.pdf 2023 version])</ref> where it received a best paper award.<ref>{{Cite web |title=ACM SIGACT - STOC Best Paper Award |url=https://www.sigact.org/prizes/best_paper.html |access-date=2022-04-20 |website=www.sigact.org}}</ref>
| last1 = Karlin | first1 = Anna R. | author1-link = Anna Karlin
| last2 = Klein | first2 = Nathan
| last3 = Gharan | first3 = Shayan Oveis
| editor1-last = Khuller | editor1-first = Samir
| editor2-last = Vassilevska Williams | editor2-first = Virginia |editor2-link = Virginia Vassilevska Williams
| arxiv = 2007.01409
| contribution = A (slightly) improved approximation algorithm for metric TSP
| doi = 10.1145/3406325.3451009
| pages = 32–45
| publisher = Association for Computing Machinery
| title = STOC '21: 53rd Annual ACM SIGACT Symposium on Theory of Computing, Virtual Event, Italy, June 21-25, 2021
| year = 2021| isbn = 978-1-4503-8053-9 }}</ref><ref>{{citation|last=Klarreich|first=Erica|author-link=Erica Klarreich|title=Computer Scientists Break Traveling Salesperson Record|url=https://www.quantamagazine.org/computer-scientists-break-traveling-salesperson-record-20201008/|access-date=2020-10-10|magazine=Quanta Magazine|date=8 October 2020|language=en}}</ref> The paper received a best paper award at the 2021 [[Symposium on Theory of Computing]].<ref>{{citation |title=ACM SIGACT - STOC Best Paper Award |url=https://www.sigact.org/prizes/best_paper.html |access-date=2022-04-20 |website=www.sigact.org}}</ref>
 
In the special case of [[Euclidean space]] of dimension <math>d</math>, for any <math>c>0</math>, there is a polynomial-time algorithm that finds a tour of length at most <math>1+\tfrac1c</math> times the optimal for geometric instances of TSP in
 
:<math>O\left(n (\log n)^{(O(c \sqrt{d}))^{d-1}}\right)</math> time.
 
For each constant <math>c</math> this time bound is in [[polynomial time]], so this is called a [[polynomial-time approximation scheme]] (PTAS).<ref>Sanjeev Arora, Polynomial-time Approximation Schemes for Euclidean TSP and other Geometric Problems, Journal of the ACM 45(5) 753–782, 1998.</ref> [[Sanjeev Arora]] and [[Joseph S. B. Mitchell]] were awarded the [[Gödel Prize]] in 2010 for their simultaneous discovery of a PTAS for the Euclidean TSP.
 
Methods based on the Christofides–Serdyukov algorithm can also be used to approximate the [[stacker crane problem]], a generalization of the TSP in which the input consists of ordered pairs of points from a metric space that must be traversed consecutively and in order. For this problem, it achieves an approximation ratio of 9/5.<ref>{{citation
| last1 = Frederickson | first1 = Greg N.
| last2 = Hecht | first2 = Matthew S.
| last3 = Kim | first3 = Chul E.
| doi = 10.1137/0207017
| issue = 2
| journal = [[SIAM Journal on Computing]]
| mr = 489787
| pages = 178–193
| title = Approximation algorithms for some routing problems
| volume = 7
| year = 1978}}</ref>
 
== References ==
{{reflist|30em}}
 
==External links==