Skip to main content
Log in

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

  • Full Length Paper
  • Published:
Mathematical Programming Computation Aims and scope Submit manuscript

Abstract

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.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Institutional subscriptions

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Fig. 5
Fig. 6
Fig. 7
Fig. 8
Fig. 9
Fig. 10
Fig. 11
Fig. 12
Fig. 13
Fig. 14

Similar content being viewed by others

Notes

  1. The name stems from Sir William Hamilton’s investigations of such cycles on the dodecahedron graph around 1856, however Leonhard Euler studied the famous “knight’s tour” on a chessboard as early as 1759.

  2. An effective implementation of L–K, for example Helsgaun’s LKH [8] could be such an algorithm.

  3. It should be noted that modern implementations of Lin–Kernighan view sequential exchanges in a more refined sense, which permits them to construct the required 7-opt transformation.

  4. Of course, this is guaranteed by the algorithm, but was checked nonetheless to confirm our implementation was accurate.

References

  1. Applegate, D.L., Bixby, R.B., Chavátal, V., Cook, W.J.: Concorde TSP Solver. http://www.tsp.gatech.edu/concorde/index.html (2003)

  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)

  3. Baniasadi, P., Clancy, K., Ejov, V., Filar, J.A., Haythorpe, M., Rossomakhine, S.: Snakes and Ladders Heuristic-Web Interface. http://fhcp.edu.au/slhweb/ (2012)

  4. Bouwer, I.Z., Chernoff, W.W., Monson, B., Star, Z.: The Foster Census. Charles Babbage Research Center, Winnipeg (1988)

    MATH  Google Scholar 

  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)

  6. Flood, M.M.: The Traveling Salesman Problem. Oper. Res. 4, 61–75 (1956)

    Article  MathSciNet  Google Scholar 

  7. Gutin, G., Punnen, A.P.: Traveling Salesman Problem and Its Variations. Kluwer Academic Publishers, Boston (2002)

  8. Helsgaun, K.: An effective implementation of Lin-Kernighan traveling salesman heuristic. Eur. J. Oper. Res. 126, 106–130 (2000)

    Article  MATH  MathSciNet  Google Scholar 

  9. Isaacs, R.: Infinite families of nontrivial trivalent graphs which are not Tait colorable. Am. Math. Monthly 82, 221–239 (1975)

    Article  MATH  MathSciNet  Google Scholar 

  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)

  11. Lin, S.: Computer solutions of the traveling salesman problem. Bell Syst. Tech. J. 44, 2245–2269 (1965)

    Article  MATH  Google Scholar 

  12. Lin, S., Kernighan, B.W.: An effective Heuristic algorithm for the traveling salesman problem. Oper. Res. 21, 496–516 (1973)

    Article  MathSciNet  Google Scholar 

  13. Royle, G., Conder, M., McKay, B., Dobscanyi, P.: Cubic symmetric graphs (The Foster Census): http://school.maths.uwa.edu.au/~gordon/remote/foster (2001)

  14. Sheehan, J.: Graphs with exactly one hamiltonian circuit. J. Graph Theory 1, 37–43 (1977)

    Article  MATH  MathSciNet  Google Scholar 

  15. TSPLIB. Hamiltonian cycle problem (HCP). http://comopt.ifi.uni-heidelberg.de/software/TSPLIB95 (2008)

  16. Weisstein, E.W.: Generalized Petersen Graph (From MathWorld-A Wolfram Web Resource). http://mathworld.wolfram.com/generalizedpetersengraph.html

  17. Wormald, N.: Models of random regular graphs. In: Surveys in Combinatorics, pp. 239–298. Cambridge University press, Cambridge (1999)

Download references

Acknowledgments

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.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Michael Haythorpe.

Rights and permissions

Reprints and permissions

About this article

Cite this article

Baniasadi, P., Ejov, V., Filar, J.A. et al. Deterministic “Snakes and Ladders” Heuristic for the Hamiltonian cycle problem. Math. Prog. Comp. 6, 55–75 (2014). https://doi.org/10.1007/s12532-013-0059-2

Download citation

  • Received:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s12532-013-0059-2

Keywords

Mathematics Subject Classification

Navigation