yields True if the graph g is Hamiltonian, and False otherwise.


  • A graph is Hamiltonian if it has a cycle that traverses each vertex exactly once.


open allclose all

Basic Examples  (2)

Test whether a graph is Hamiltonian:

Not all graphs have a Hamiltonian cycle:

Scope  (6)

HamiltonianGraphQ works with undirected graphs:

Directed graphs:


Mixed graphs:

HamiltonianGraphQ gives False for expressions that are not graphs:

HamiltonianGraphQ works with large graphs:

Applications  (2)

Test whether the Icosian game [MathWorld] has a solution:

A Hamiltonian cycle:

Test whether there is a sequence of moves by a knight chess piece that visits each square of an chessboard exactly once:

Properties & Relations  (4)

A Hamiltonian cycle can be found using FindHamiltonianCycle:

Skeleton graphs of platonic solids are Hamiltonian:

The line graph of a Hamiltonian graph is Hamiltonian:

An Eulerian graph is not always Hamiltonian:

The line graph of an Eulerian graph is Hamiltonian:

Introduced in 2010