Hamiltonian Cycle Calculator

Build graphs, validate routes, and uncover cycles. Compare degrees, inspect density, and test search settings. Export findings, view charts, and study example networks easily.

Calculator form

Use an edge list or adjacency matrix. Large screens show three input columns, smaller screens collapse to two and then one.

Enter comma-separated labels such as A,B,C,D,E.
Use a label or a 1-based position.
Use one edge per line, such as A-B, A B, A,B, or A->B.
Enter 0 and 1 values only. Separate entries with spaces or commas.

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:

Find a permutation (v₁, v₂, ..., vₙ) such that (vᵢ, vᵢ₊₁) ∈ E for i = 1 to n-1 and (vₙ, v₁) ∈ E.

Supporting formulas used for diagnostics:

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

  1. Choose the number of vertices and define labels.
  2. Select whether the graph is directed or undirected.
  3. Pick edge-list input or adjacency-matrix input.
  4. Enter a start vertex to anchor the search.
  5. Choose whether to stop at the first cycle or collect several.
  6. Set a search cap if you want to control computation cost.
  7. Press Solve graph to place the result below the header and above the form.
  8. Review the cycle output, matrix, checks, and Plotly graph.
  9. 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.

Related Calculators

boolean algebra calculatorset operations calculatorbinary multiplication calculatorcode word generatorfibonacci sequence calculatorbinary subtraction calculatorbinary tree calculatorkarnaugh map calculatorbinary number calculatordivisibility calculator

Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.