← Lessons

quiz vs the machine

Platinum1880

Algorithms

Hamiltonian Path Hardness

Visiting every node once looks similar to Eulerian but is far harder.

5 min read · advanced · beat Platinum to climb

A deceptively similar question

A Hamiltonian path visits every node exactly once, in contrast to the Eulerian path that visits every edge once. The two questions look like twins, yet one has a clean degree test and the other does not. Deciding whether a Hamiltonian path exists is a hard problem with no known efficient test.

Why no simple rule works

For the Eulerian case, a local property, the parity of each node's degree, fully decides the answer. Hamiltonicity is global: a single missing connection far away can ruin every attempt, and no local count captures that. There is no known shortcut better than searching through arrangements.

The complexity verdict

Deciding the existence of a Hamiltonian path is NP complete. We can quickly verify a proposed path by checking it touches each node once, but finding one in the first place is believed to require time that grows faster than any polynomial as graphs enlarge.

Living with hardness

In practice people use clever pruning, special graph structure, or accept approximate answers. The contrast with the easy Eulerian test is a classic lesson that tiny changes in a question can flip it from trivial to intractable.

Key idea

Finding a Hamiltonian path visiting every node once is NP complete, unlike the Eulerian edge path, because the constraint is global with no simple local test.

Check yourself

Answer to earn rating on the learn ladder.

1. What does a Hamiltonian path require?

2. Why is Hamiltonicity harder than the Eulerian property?