Mathematical Programming Computation

, Volume 6, Issue 1, pp 55–75 | Cite as

Deterministic “Snakes and Ladders” Heuristic for the Hamiltonian cycle problem

  • Pouya Baniasadi
  • Vladimir Ejov
  • Jerzy A. Filar
  • Michael HaythorpeEmail author
  • Serguei Rossomakhine
Full Length Paper


We present a polynomial complexity, deterministic, heuristic for solving the Hamiltonian cycle problem (HCP) in an undirected graph of order \(n\). Although finding a Hamiltonian cycle is not theoretically guaranteed, we have observed that the heuristic is successful even in cases where such cycles are extremely rare, and it also performs very well on all HCP instances of large graphs listed on the TSPLIB web page. The heuristic owes its name to a visualisation of its iterations. All vertices of the graph are placed on a given circle in some order. The graph’s edges are classified as either snakes or ladders, with snakes forming arcs of the circle and ladders forming its chords. The heuristic strives to place exactly \(n\) snakes on the circle, thereby forming a Hamiltonian cycle. The Snakes and Ladders Heuristic uses transformations inspired by \(k\)-opt algorithms such as the, now classical, Lin–Kernighan heuristic to reorder the vertices on the circle in order to transform some ladders into snakes and vice versa. The use of a suitable stopping criterion ensures the heuristic terminates in polynomial time if no improvement is made in \(n^3\) major iterations.


Hamiltonian cycle problem Lin–Kernighan Heuristic  Polynomial time Connected graph 

Mathematics Subject Classification

05C85 05C45 68R10 



The authors gratefully acknowledge useful comments from the anonymous referees which improved the exposition, and useful discussions with Brendan McKay and Gordon Royle that helped us to find suitable test instances. The editor, William Cook, also contributed significantly by suggesting further testing and changes of inaccurate statements. The research presented in this manuscript was supported by the ARC Discovery Grant DP120100532.


  1. 1.
    Applegate, D.L., Bixby, R.B., Chavátal, V., Cook, W.J.: Concorde TSP Solver. (2003)
  2. 2.
    Applegate, D.L., Bixby, R.B., Chavátal, V., Cook, W.J.: The Traveling Salesman Problem: A Computational Study. Princeton University Press, Princeton (2006)Google Scholar
  3. 3.
    Baniasadi, P., Clancy, K., Ejov, V., Filar, J.A., Haythorpe, M., Rossomakhine, S.: Snakes and Ladders Heuristic-Web Interface. (2012)
  4. 4.
    Bouwer, I.Z., Chernoff, W.W., Monson, B., Star, Z.: The Foster Census. Charles Babbage Research Center, Winnipeg (1988)zbMATHGoogle Scholar
  5. 5.
    Eppstein, D.: The traveling salesman problem for cubic graphs. In: Dehne, F., Sack, J.R., Smid, M. (eds.) Algorithms and Data Structures. Lecture Notes in Computer Science, vol. 2748. pp. 307–318. Springer, Berlin (2003)Google Scholar
  6. 6.
    Flood, M.M.: The Traveling Salesman Problem. Oper. Res. 4, 61–75 (1956)CrossRefMathSciNetGoogle Scholar
  7. 7.
    Gutin, G., Punnen, A.P.: Traveling Salesman Problem and Its Variations. Kluwer Academic Publishers, Boston (2002)Google Scholar
  8. 8.
    Helsgaun, K.: An effective implementation of Lin-Kernighan traveling salesman heuristic. Eur. J. Oper. Res. 126, 106–130 (2000)CrossRefzbMATHMathSciNetGoogle Scholar
  9. 9.
    Isaacs, R.: Infinite families of nontrivial trivalent graphs which are not Tait colorable. Am. Math. Monthly 82, 221–239 (1975)CrossRefzbMATHMathSciNetGoogle Scholar
  10. 10.
    Lawler, E.L., Lenstra, J.K., Rinooy Kan, A.H.G., Shmoys, D.B.: The Traveling Salesman Problem: A Guided Tour of Combinatorial Optimization. Wiley, New York (1985)Google Scholar
  11. 11.
    Lin, S.: Computer solutions of the traveling salesman problem. Bell Syst. Tech. J. 44, 2245–2269 (1965)CrossRefzbMATHGoogle Scholar
  12. 12.
    Lin, S., Kernighan, B.W.: An effective Heuristic algorithm for the traveling salesman problem. Oper. Res. 21, 496–516 (1973)CrossRefMathSciNetGoogle Scholar
  13. 13.
    Royle, G., Conder, M., McKay, B., Dobscanyi, P.: Cubic symmetric graphs (The Foster Census): (2001)
  14. 14.
    Sheehan, J.: Graphs with exactly one hamiltonian circuit. J. Graph Theory 1, 37–43 (1977)CrossRefzbMATHMathSciNetGoogle Scholar
  15. 15.
    TSPLIB. Hamiltonian cycle problem (HCP). (2008)
  16. 16.
    Weisstein, E.W.: Generalized Petersen Graph (From MathWorld-A Wolfram Web Resource).
  17. 17.
    Wormald, N.: Models of random regular graphs. In: Surveys in Combinatorics, pp. 239–298. Cambridge University press, Cambridge (1999)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg and Mathematical Optimization Society 2013

Authors and Affiliations

  • Pouya Baniasadi
    • 1
  • Vladimir Ejov
    • 1
  • Jerzy A. Filar
    • 1
  • Michael Haythorpe
    • 1
    Email author
  • Serguei Rossomakhine
    • 1
  1. 1.Flinders UniversityBedford ParkAustralia

Personalised recommendations