This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
 GRAPH UTILITIES PACKAGE SYMBOL

# FindHamiltonianCycle

 FindHamiltonianCycle[g] attempts to find a Hamiltonian cycle.
• FindHamiltonianCycle[g] returns an empty list if no Hamiltonian cycle is found.
• considers the input graph as undirected.
• uses heuristic algorithms to find a Hamiltonian cycle, therefore, there is no guarantee that a Hamiltonian cycle will be found even if one exists.
This defines a small graph and finds a Hamiltonian cycle of the graph:
This plots the graph and highlights the cycle in red:
Needs["GraphUtilities`"]
This defines a small graph and finds a Hamiltonian cycle of the graph:
 Out[3]=
 Out[4]=
This plots the graph and highlights the cycle in red:
 Out[5]=
 Options   (2)
This limits the maximum number of iterations to try to find a Hamiltonian cycle:
This specifies a random seed different from the default to try to find a Hamiltonian cycle:
 Applications   (1)
This finds all possible Hamiltonian cycles in the graph consisting of bordering countries in South America:
This shows the first of these two cycles; the second is just a reversal of the first:
uses heuristic algorithms. Unlike HamiltonianCycles, it is not guaranteed to find a Hamiltonian cycle even when one exists. But for large graphs, can sometimes be faster at finding one cycle.
This defines a graph of 500 vertices, and uses these two functions to find a Hamiltonian cycle:
uses heuristic algorithms, which are not guaranteed to find a Hamiltonian cycle even when one exists: