This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

HamiltonianGraphQ

HamiltonianGraphQ[g]
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.
Test whether a graph is Hamiltonian:
Not all graphs have a Hamiltonian cycle:
Test whether a graph is Hamiltonian:
In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
 
Not all graphs have a Hamiltonian cycle:
In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
HamiltonianGraphQ works with undirected graphs:
HamiltonianGraphQ gives False for expressions that are not graphs:
Works with large graphs:
New in 8