Mathematica 9 is now available
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.
Mathematica > Mathematics and Algorithms > Graphs & Networks > Graph Predicates and Properties > HamiltonianGraphQ >
Mathematica > Visualization and Graphics > Graphs & Networks > Graph Predicates and Properties > HamiltonianGraphQ >

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
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team
Format:   HTML  |  CDF