Classic Theory

Eulerian Paths and Circuits

Can you cross every bridge in a city exactly once and return home? In 1736, Euler turned that puzzle into a theorem — and founded graph theory in the process.

9 Min Read Updated: June 2026 Intermediate Level
LGT
Learn Graph Theory Team
Expert Operations Research Engineers

1. What Is an Eulerian Trail?

An Eulerian trail (also called an Euler path) is a route through a graph that uses every edge exactly once. You may pass through the same vertex many times, but you are never allowed to travel along the same edge twice.

It answers a surprisingly practical question: given a network of roads, pipes, or cables, can I traverse all of them without ever repeating a connection?

2. Euler Trail vs Euler Circuit

The two terms are closely related but not identical:

Every Eulerian circuit is also an Eulerian trail, but the reverse is not true. Which one a graph supports depends entirely on the degrees of its vertices.

3. The Seven Bridges of Königsberg

The Prussian city of Königsberg was split by a river into four landmasses, joined by seven bridges. Citizens wondered whether they could take a walk that crossed every bridge exactly once and returned to the start.

In 1736, Leonhard Euler proved that no such walk exists. He modeled each landmass as a vertex and each bridge as an edge, then observed something decisive: every time you enter a landmass over one bridge, you must leave it over another, so every "pass-through" vertex needs an even number of bridges. All four of Königsberg's vertices had an odd number of bridges, making the walk impossible. This proof is widely regarded as the birth of graph theory. (See our history of graph theory.)

4. The Degree Rule: When Does One Exist?

The degree of a vertex is the number of edges touching it. Euler's insight gives simple, exact rules for a connected graph:

The graph must also be connected. Otherwise, just count the odd-degree vertices and you have your answer.

Walk the Graph Yourself

Build a network, then watch an algorithm trace an Eulerian trail edge by edge — and see exactly why odd-degree vertices break it.

Launch the Visualizer

5. Finding One: Fleury's and Hierholzer's Algorithms

Once you know a trail exists, two classic algorithms construct it:

Fleury's Algorithm

Walk the graph one edge at a time, and never cross a bridge (an edge whose removal would disconnect the graph) unless you have no other choice. It is easy to understand, but constantly checking for bridges makes it relatively slow.

Hierholzer's Algorithm

The efficient choice, running in O(E) time. Follow edges to form a closed loop, then repeatedly find a vertex on your current path that still has unused edges and splice in another loop there. When no unused edges remain, the loops merge into a single Eulerian circuit.

6. Euler vs Hamiltonian Paths

These two are constantly confused, but they are completely different problems:

The twist is computational: deciding whether an Eulerian trail exists is easy (just count odd degrees), while deciding whether a Hamiltonian path exists is NP-complete — among the hardest problems in computer science. The Traveling Salesperson Problem is a famous Hamiltonian-style challenge.

7. Real-World Applications

Frequently Asked Questions

What is the difference between an Euler path and an Euler circuit?

An Euler path (trail) uses every edge exactly once and can start and end at different vertices. An Euler circuit also uses every edge exactly once but must start and end at the same vertex.

How do I know if a graph has an Eulerian trail?

For a connected graph, an Eulerian circuit exists if every vertex has even degree, and an open Eulerian trail exists if exactly two vertices have odd degree. If more than two vertices have odd degree, no Eulerian trail exists.

What is the difference between an Eulerian and a Hamiltonian path?

An Eulerian path visits every edge once, while a Hamiltonian path visits every vertex once. Checking for an Eulerian path is easy, but checking for a Hamiltonian path is NP-complete.

Why is the Seven Bridges of Königsberg problem impossible?

All four landmasses were touched by an odd number of bridges. An Eulerian trail allows at most two odd-degree vertices, so crossing every bridge exactly once is impossible.

Further Exploration

Trace Every Edge

Reading about Euler trails is one thing — watching one unfold across a graph makes the degree rule click. Draw your own graphs and find their Eulerian paths interactively.

Open the Visualizer