Calculator form
Use an edge list or adjacency matrix. Large screens show three input columns, smaller screens collapse to two and then one.
Example data table
This example graph contains a Hamiltonian cycle and is already preloaded in the form.
| Example | Vertex labels | Type | Edges | Expected cycle |
|---|---|---|---|---|
| Five-vertex sample | A, B, C, D, E | Undirected | A-B, B-C, C-D, D-E, E-A, A-C, B-D | A → B → C → D → E → A |
Formula used
A Hamiltonian cycle is a closed tour that visits every vertex exactly once before returning to the start. The solver checks whether an ordering of vertices satisfies this graph condition:
Supporting formulas used for diagnostics:
- Undirected degree: deg(v) = Σ a(v,j)
- Directed out-degree: out(v) = Σ a(v,j)
- Directed in-degree: in(v) = Σ a(j,v)
- Undirected density: 2m / (n(n − 1))
- Directed density: m / (n(n − 1))
The Dirac and Ore checks shown in results are sufficient conditions for undirected simple graphs. They can confirm existence, but they are not required for a cycle to exist.
How to use this calculator
- Choose the number of vertices and define labels.
- Select whether the graph is directed or undirected.
- Pick edge-list input or adjacency-matrix input.
- Enter a start vertex to anchor the search.
- Choose whether to stop at the first cycle or collect several.
- Set a search cap if you want to control computation cost.
- Press Solve graph to place the result below the header and above the form.
- Review the cycle output, matrix, checks, and Plotly graph.
- Use the export buttons to download a CSV or PDF report.
Frequently asked questions
1) What does this calculator decide?
It checks whether the graph contains a Hamiltonian cycle, meaning one closed route visits every vertex exactly once before returning to the start.
2) Does a Hamiltonian path count?
No. A Hamiltonian path visits every vertex once, but it does not need to return to its starting vertex. This tool specifically tests the cycle version.
3) Why is the start vertex required?
The start vertex anchors the search and avoids many duplicate cycle rotations. It does not change whether a Hamiltonian cycle exists in the graph.
4) Why can the tool reject a graph immediately?
Some rules make a cycle impossible. For example, a disconnected undirected graph or a vertex with degree below two cannot contain a Hamiltonian cycle.
5) What are Dirac and Ore checks?
They are classic sufficient conditions for undirected simple graphs. When satisfied, they guarantee a Hamiltonian cycle. When not satisfied, a cycle may still exist.
6) Why is there a search step cap?
Hamiltonian-cycle search is computationally expensive. The step cap keeps the solver responsive when graphs grow or when many candidate routes must be explored.
7) Can I use directed graphs?
Yes. The tool supports directed edges and checks in-degree, out-degree, and strong connectivity before running the backtracking search.
8) What do the exports include?
The CSV and PDF downloads include the status, graph settings, counts, density, search details, and every stored Hamiltonian cycle currently shown on the page.