Imagine you have many dots. You want to draw a line. The line must touch every dot. You can only touch each dot one time. 
Imagine you have many dots. You want to draw a line. 
The line must touch every dot. You can only touch each dot one time. This is a big puzzle. It is called a Hamiltonian path.
Sometimes you must start and end at certain dots. A cycle is a path that ends where it began. These puzzles are very hard for computers to solve. Some people even use DNA to try to solve them. Finding the right path is a great challenge!
Imagine you have a map of dots and lines. You want to find a way to travel. You must visit every single dot on the map. You can only visit each dot one time. This is called a Hamiltonian path. 
If you end your trip at the same dot where you started, it is called a Hamiltonian cycle. These puzzles are very hard for computers to solve. We call them NP-complete problems. This means they are among the toughest puzzles in math.
One way to solve them is a brute force search. This means checking every single possible path. This takes a very long time as you add more dots. Some people try new ways to solve them. For example, Leonard Adleman showed how to use DNA. He used chemical reactions to find a path. Other people have even tried using light and cables.
These puzzles help us in the real world. They can help computers move data across a chip. They can also help make 3D computer graphics faster. In graphics, finding a path helps order triangles correctly. This makes the computer work much faster.
Imagine you have a map made of dots and lines. The dots are called vertices, and the lines are called edges. A Hamiltonian path is a special way to travel through this map. You must visit every single dot exactly one time. If you find a path that ends at the same dot where you started, it is called a Hamiltonian cycle. 
There are many ways to try and solve these puzzles. One way is called a brute force search. This means checking every single possible path one by one. This is very slow because the number of paths grows huge very quickly. Other people use different methods to find answers. Frank Rubin used a search that divides edges into three groups. He looked at edges that must be in the path and those that cannot. This helps make the search smaller and faster. 
Mathematicians have found many clever ways to work with these paths. Bellman, Held, and Karp used a method called dynamic programming. This way uses information from smaller paths to solve bigger ones. Andreas Björklund used a different approach called a Monte Carlo algorithm. He used math to turn the problem into a simpler counting task. This can work even on very large graphs. 
Because these problems are so hard, scientists look for new tools. Leonard Adleman showed that a DNA computer could solve them. This uses chemical reactions to find a path through the dots. It uses many DNA molecules to do the work. Other scientists have even suggested using light and optical cables. This would use light to travel through a structure like a map. 
These puzzles are not just for fun; they help our technology work. They can be used in computer chips to move data packets. This helps parts of a computer talk to each other without getting stuck. They also help make 3D computer graphics look great. In graphics, computers use triangles to build images. If a computer finds a Hamiltonian path through these triangles, it can render them much faster. 
The Hamiltonian path problem is a central topic in graph theory and complexity theory. In graph theory, a graph is a collection of dots called vertices connected by lines called edges. A Hamiltonian path is a specific route through a graph that visits every single vertex exactly once. If the path ends at the same vertex where it began, it is called a Hamiltonian cycle. 
To understand how these problems relate, mathematicians use a process called reduction. You can turn a Hamiltonian path problem into a Hamiltonian cycle problem by adding a new universal vertex, $x$, to the graph. This new vertex connects to every other vertex in the original graph. This shows that finding a path is not significantly slower than finding a cycle in the worst case. Conversely, a Hamiltonian cycle problem can be converted into a path problem. This is done by adding two terminal vertices, $s$ and $t$, to specific parts of the graph. These methods allow researchers to use the same logic to solve different versions of the puzzle.
Finding these paths is notoriously difficult for computers. The problem belongs to a class known as NP-complete problems. This status was documented by Richard Karp in his list of 21 NP-complete problems and in the work of Michael Garey and David S. Johnson. Being NP-complete means that finding a solution is hard, but verifying a suggested solution is easy. A verifier can take a proposed path, called a certificate, and check it in polynomial time. The verifier simply confirms that every vertex appears exactly once, that the path starts and ends at the correct spots, and that every step follows an existing edge in the graph.
Several algorithms exist to tackle this complexity. A brute force approach tries every possible sequence of vertices, but this is extremely slow. For a graph with $n$ vertices, there are $n!$ (n factorial) possible sequences. To improve speed, Frank Rubin developed a search procedure that classifies edges into three types: those that must be in the path, those that cannot be, and undecided edges. Another method, dynamic programming, was developed by Bellman, Held, and Karp. This method uses the time complexity $O(n^2 2^n)$ and works by building solutions for larger sets of vertices using information from smaller ones. 
More advanced mathematical techniques offer even faster results for certain graphs. Andreas Björklund used the inclusion-exclusion principle to create a Monte Carlo algorithm. This method can solve the Hamiltonian cycle problem in $O(1.657^n)$ time for arbitrary graphs, and even faster at $O(1.415^n)$ for bipartite graphs. For graphs where each vertex has a maximum degree of three, backtracking searches can find a cycle in $O(1.251^n)$ time. Because the problem is NP-complete, it can also be mapped to the 3-SAT problem, which is a famous problem in logic and computer science.
Because standard computers struggle with these tasks, scientists have explored unconventional computing models. Leonard Adleman demonstrated that a DNA computer could solve the Hamiltonian path problem. This method uses the massive parallelism of chemical reactions to find a path in a number of steps linear to the number of vertices. However, it requires a factorial number of DNA molecules to function. Another proposal involves an optical solution using light, cables, and beam splitters. While interesting, this approach requires an amount of energy that grows exponentially with the number of nodes.
These mathematical concepts have very practical uses in modern technology. In computer engineering, they are used in Networks on Chip (NoC). These networks allow different parts of a processor to communicate. Using Hamiltonian paths in multicast routing can ensure that data packets move efficiently without causing deadlocks. 
🖼️ Images & Media (1)
More to explore
✨ What else?
Related topics you might enjoy
🔬 Go deeper
More advanced topics to explore
🪜 Step back
Simpler topics to build understanding
What is Nepedia?
A free, ad-free encyclopedia for children. Every article is written at five reading levels, so the same page works for a five-year-old and a fifteen-year-old — use the level switcher above to see this one change. No account needed to read.