WOLFRAM

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

Details

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

Examples

open allclose all

Basic Examples  (2)Summary of the most common use cases

Test whether a graph is Hamiltonian:

Out[1]=1
Out[2]=2

Not all graphs have a Hamiltonian cycle:

Out[1]=1
Out[2]=2

Scope  (6)Survey of the scope of standard use cases

HamiltonianGraphQ works with undirected graphs:

Out[1]=1

Directed graphs:

Out[1]=1

Multigraphs:

Out[1]=1

Mixed graphs:

Out[1]=1

HamiltonianGraphQ gives False for expressions that are not graphs:

Out[1]=1

HamiltonianGraphQ works with large graphs:

Out[2]=2

Applications  (2)Sample problems that can be solved with this function

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

Out[1]=1
Out[2]=2

A Hamiltonian cycle:

Out[5]=5

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

Out[2]=2

Properties & Relations  (4)Properties of the function, and connections to other functions

A Hamiltonian cycle can be found using FindHamiltonianCycle:

Out[1]=1
Out[2]=2

Skeleton graphs of platonic solids are Hamiltonian:

Out[1]=1
Out[2]=2
Out[3]=3

The line graph of a Hamiltonian graph is Hamiltonian:

Out[1]=1
Out[2]=2

An Eulerian graph is not always Hamiltonian:

Out[1]=1
Out[2]=2
Out[3]=3

The line graph of an Eulerian graph is Hamiltonian:

Out[4]=4
Wolfram Research (2010), HamiltonianGraphQ, Wolfram Language function, https://reference.wolfram.com/language/ref/HamiltonianGraphQ.html.
Wolfram Research (2010), HamiltonianGraphQ, Wolfram Language function, https://reference.wolfram.com/language/ref/HamiltonianGraphQ.html.

Text

Wolfram Research (2010), HamiltonianGraphQ, Wolfram Language function, https://reference.wolfram.com/language/ref/HamiltonianGraphQ.html.

Wolfram Research (2010), HamiltonianGraphQ, Wolfram Language function, https://reference.wolfram.com/language/ref/HamiltonianGraphQ.html.

CMS

Wolfram Language. 2010. "HamiltonianGraphQ." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/HamiltonianGraphQ.html.

Wolfram Language. 2010. "HamiltonianGraphQ." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/HamiltonianGraphQ.html.

APA

Wolfram Language. (2010). HamiltonianGraphQ. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/HamiltonianGraphQ.html

Wolfram Language. (2010). HamiltonianGraphQ. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/HamiltonianGraphQ.html

BibTeX

@misc{reference.wolfram_2025_hamiltoniangraphq, author="Wolfram Research", title="{HamiltonianGraphQ}", year="2010", howpublished="\url{https://reference.wolfram.com/language/ref/HamiltonianGraphQ.html}", note=[Accessed: 26-March-2025 ]}

@misc{reference.wolfram_2025_hamiltoniangraphq, author="Wolfram Research", title="{HamiltonianGraphQ}", year="2010", howpublished="\url{https://reference.wolfram.com/language/ref/HamiltonianGraphQ.html}", note=[Accessed: 26-March-2025 ]}

BibLaTeX

@online{reference.wolfram_2025_hamiltoniangraphq, organization={Wolfram Research}, title={HamiltonianGraphQ}, year={2010}, url={https://reference.wolfram.com/language/ref/HamiltonianGraphQ.html}, note=[Accessed: 26-March-2025 ]}

@online{reference.wolfram_2025_hamiltoniangraphq, organization={Wolfram Research}, title={HamiltonianGraphQ}, year={2010}, url={https://reference.wolfram.com/language/ref/HamiltonianGraphQ.html}, note=[Accessed: 26-March-2025 ]}