Euler Paths and Circuits

An Euler path uses every edge of a graph exactly once. An Euler circuit is an Euler path that starts and ends at the same vertex. A connected graph has an Euler circuit exactly when every vertex has even degree, and an Euler path that is not a circuit exactly when it has exactly two vertices of odd degree.

Before this lesson: Graph Theory Basics and Bipartite Graphs

The idea

Can you trace a figure without lifting your pencil and without going over any line twice? Can a mail carrier walk every street exactly once? These are questions about Euler paths: routes that use each edge once.

Vertices may repeat in such a route; only edges may not. Each time the route passes through a vertex, it uses one edge to arrive and another to leave. So edges at a middle vertex get used in pairs, and that is why even and odd degrees decide everything.

Euler path and circuit definitions

A trail is a walk that never uses the same edge twice. An Euler path is a trail that uses every edge of the graph. An Euler circuit is an Euler path that ends where it started. These ideas work for multigraphs too, where two vertices can be joined by more than one edge.

Euler’s theorem

Let G be a connected graph (ignoring vertices with no edges).

  • G has an Euler circuit if and only if every vertex has even degree.
  • G has an Euler path that is not a circuit if and only if exactly two vertices have odd degree. The path must start at one of them and end at the other.
  • If G has more than two vertices of odd degree, it has no Euler path at all.

Why. Every time a trail passes through a vertex, it uses two of its edges. A vertex that is not the start or the end is only passed through, so its degree is even. In a circuit the start and end are the same vertex, which also uses its edges in pairs. In a path that is not a circuit, the start and the end each use one extra edge, so exactly those two have odd degree. By the handshaking lemma, odd vertices always come in pairs, so 0 and 2 are the only possible counts for an Euler path. The other direction (even degrees guarantee a circuit) follows from the method below.

The bridges of Königsberg

In 1736, Leonhard Euler asked whether a walk through the city of Königsberg could cross each of its seven bridges exactly once. He made each land area a vertex and each bridge an edge. This is where graph theory began.

A multigraph for the seven bridges of Königsberg. Vertex A, the central island, has degree 5; vertices B (north bank), C (south bank) and D (east island) each have degree 3. A is joined to B by two edges, to C by two edges and to D by one edge; B and C are each joined to D by one edge.
All four land areas have odd degree (5, 3, 3, 3), so no walk can cross every bridge exactly once.

Fleury’s algorithm

  1. Check the degrees. Start at an odd vertex if there are two; start anywhere if all degrees are even.
  2. At each step, choose an unused edge from the current vertex. Do not choose a bridge (an edge whose removal cuts the remaining edges into separate pieces) unless it is the only choice.
  3. Move along the edge and erase it.
  4. Repeat until every edge is used.

Euler path and circuit examples

Example 1: The Königsberg bridges

Use the figure to decide whether Königsberg has an Euler path or circuit.

\deg(A) = 2 + 2 + 1

A has two bridges to B, two to C and one to D.

\deg(A) = 5

Add.

\deg(B) = 2 + 1 = 3

B has two bridges to A and one to D.

\deg(C) = 2 + 1 = 3

C has two bridges to A and one to D.

\deg(D) = 1 + 1 + 1 = 3

D has one bridge each to A, B and C.

4 \text{ odd vertices}

All four degrees are odd, and an Euler path allows at most 2.

Answer: there is no Euler path and no Euler circuit. No walk crosses every bridge exactly once.

Example 2: An Euler circuit

Graph G is a “bowtie”: edges AB, BC, CA, CD, DE and EC (two triangles sharing vertex C). Find an Euler circuit if one exists.

\deg(A) = \deg(B) = 2

A and B each lie on two edges.

\deg(D) = \deg(E) = 2

D and E each lie on two edges.

\deg(C) = 4

C lies on CA, CB, CD and CE.

\text{all even, connected}

Euler’s theorem says an Euler circuit exists.

A, B, C, D, E, C, A

Go around one triangle to C, around the other back to C, then home.

AB, BC, CD, DE, EC, CA

Check: all 6 edges, each used once.

Answer: A, B, C, D, E, C, A is an Euler circuit. Vertex C is visited twice, which is allowed.

Example 3: An Euler path but no circuit

A “house” graph has a square A, B, C, D (A and B on top) and a roof vertex E, with edges AB, BC, CD, DA, AE and EB. Find an Euler path.

\deg(A) = 3,\ \deg(B) = 3

A lies on AB, DA, AE; B lies on AB, BC, EB.

\deg(C) = \deg(D) = \deg(E) = 2

The other three vertices have even degree.

\text{start at A, end at B}

Exactly two odd vertices: the path must run between them.

A, D, C, B, A, E, B

Go down and around the square, back to A, then over the roof.

AD, DC, CB, BA, AE, EB

Check: all 6 edges, each once.

Answer: A, D, C, B, A, E, B is an Euler path. There is no Euler circuit, because A and B have odd degree.

Example 4: Fleury’s algorithm and bridges

Graph G has two triangles, ABC and DEF, joined by the edge CD. Use Fleury’s algorithm to find an Euler path.

\deg(C) = 3,\ \deg(D) = 3

C and D are the only odd vertices, so start at C.

C \to A

From C, CD is a bridge; choose CA instead.

A \to B \to C

Only one edge leaves each of A and B.

C \to D

Now CD is the only unused edge at C, so take it.

D \to E \to F \to D

Finish the second triangle.

C, A, B, C, D, E, F, D

Check: 7 edges (CA, AB, BC, CD, DE, EF, FD), each used once.

Answer: C, A, B, C, D, E, F, D. Crossing CD first would have finished the right triangle at D and stranded the left one.

Example 5: Plowing every street (word problem)

A town has intersections 1 to 5 and streets 12, 23, 34, 45, 51, 13 and 14. Can a snowplow clear every street exactly once and return to where it started? If not, where must a route that clears each street once begin and end?

\deg(1) = 4

Street ends at 1: 12, 51, 13, 14.

\deg(2) = 2,\ \deg(5) = 2

2 is on 12 and 23; 5 is on 45 and 51.

\deg(3) = 3,\ \deg(4) = 3

3 is on 23, 34, 13; 4 is on 34, 45, 14.

2 \text{ odd vertices}

No Euler circuit, but an Euler path from 3 to 4.

3, 2, 1, 5, 4, 1, 3, 4

One such route.

23, 12, 15, 54, 41, 13, 34

Check: all 7 streets, each once.

Answer: no round trip clears every street exactly once. A one-way route must start at intersection 3 and end at 4 (or the reverse), such as 3, 2, 1, 5, 4, 1, 3, 4.

Common mistakes

MistakeExample of the errorFix
Mixing up edges and vertices“An Euler path visits every vertex once.”An Euler path uses every edge once; vertices may repeat. Visiting every vertex once is a Hamilton path, the next lesson’s topic.
Forgetting that the graph must be connected“Two separate triangles have all even degrees, so they have an Euler circuit.”The edges must all lie in one connected piece.
Starting at the wrong vertexStarting the house graph’s path at CWith two odd vertices, start at one of them and end at the other.
Counting multiple edges once“Königsberg’s island has degree 3.”Count every bridge: 2 + 2 + 1 = 5.
Thinking the route cannot revisit a vertex“The bowtie has no circuit because C is used twice.”Repeating vertices is fine; only edges cannot repeat.
Crossing a bridge too earlyTaking CD first in Example 4Fleury’s algorithm crosses a bridge only when no other edge is left.

Related ideas

Directed graphs

A connected directed graph has an Euler circuit exactly when every vertex has in-degree equal to out-degree. It has an Euler path that is not a circuit when one vertex has one more edge out than in (the start), one has one more in than out (the end), and all others are balanced.

Hierholzer’s algorithm

For large graphs, computers use Hierholzer’s algorithm: walk from any vertex until you return to it, then start a new loop from a vertex on your route that still has unused edges, and splice it in. It runs in time proportional to the number of edges.

The route inspection problem

If a graph has odd vertices, a route that covers every edge and returns home must repeat some edges. The route inspection (Chinese postman) problem finds the cheapest edges to repeat by pairing up the odd vertices. In Example 5, the plow could clear all streets and return by also driving street 34 a second time.

Practice problems

  1. A connected graph has degrees 2, 2, 4, 4 and 2. Does it have an Euler circuit, an Euler path that is not a circuit, or neither?
  2. A connected graph has degrees 3, 3, 2, 2 and 2. Does it have an Euler circuit, an Euler path that is not a circuit, or neither?
  3. Does the complete graph K_4 have an Euler path?
  4. Does K_5 have an Euler circuit? Does K_6?
  5. Does the complete bipartite graph K_{2,4} have an Euler circuit?
  6. Graph G has edges AB, BC, CD, DA and AC. Find an Euler path.
  7. A graph is two separate triangles. Every degree is 2. Does it have an Euler circuit?
  8. Königsberg later gained an eighth bridge, between B and C. Does the new graph have an Euler path? Where must it start and end?
  9. Find an Euler circuit of K_{2,4} with sides {u, v} and {1, 2, 3, 4}.
  10. A small museum has rooms R1, R2 and R3 and doors O–R1, O–R3, R1–R2, R2–R3 and R1–R3, where O is the outside. Can a visitor go through every door exactly once, starting and ending outside?
Show answers

1.

\text{all even}

Every degree is 2 or 4, and the graph is connected.

Answer: an Euler circuit

2.

\deg = 3, 3

Exactly two vertices have odd degree.

Answer: an Euler path that is not a circuit, between the two degree-3 vertices

3.

\deg(v) = 3

Each vertex of K_4 has degree 3.

4 \text{ odd vertices}

More than two odd vertices.

Answer: no

4.

\deg(v) = 4 \text{ in } K_5

All even, and K_5 is connected.

\deg(v) = 5 \text{ in } K_6

All six vertices are odd.

Answer: K_5 has an Euler circuit; K_6 does not (it has no Euler path either)

5.

\deg(u) = 4,\ \deg(w) = 2

Vertices on the 2-side have degree 4; on the 4-side, degree 2.

\text{all even, connected}

Euler’s theorem applies.

Answer: yes

6.

\deg(A) = 3,\ \deg(C) = 3

A is on AB, DA, AC; C is on BC, CD, AC.

\deg(B) = \deg(D) = 2

The other two are even.

A, B, C, D, A, C

Start at odd A, end at odd C.

AB, BC, CD, DA, AC

Check: all 5 edges, each once.

Answer: A, B, C, D, A, C

7.

\text{not connected}

No trail can move from one triangle to the other.

Answer: no

8.

\deg(B) = 3 + 1 = 4

The new bridge adds 1 to B.

\deg(C) = 3 + 1 = 4

It also adds 1 to C.

\deg(A) = 5,\ \deg(D) = 3

A and D are unchanged.

2 \text{ odd vertices}

Exactly two odd vertices: A and D.

Answer: yes; it must start at A and end at D, or the reverse

9.

u, 1, v, 2, u

Go from u to v and back through 1 and 2.

u, 3, v, 4, u

Repeat through 3 and 4.

u, 1, v, 2, u, 3, v, 4, u

Join the two loops at u.

u1, 1v, v2, 2u, u3, 3v, v4, 4u

Check: all 8 edges, each once.

Answer: u, 1, v, 2, u, 3, v, 4, u

10.

\deg(O) = 2,\ \deg(R2) = 2

O has doors to R1 and R3; R2 to R1 and R3.

\deg(R1) = 3,\ \deg(R3) = 3

R1 has doors to O, R2, R3; so does R3 (O, R2, R1).

2 \text{ odd vertices}

A route through every door once must start at R1 or R3.

Answer: no; such a route exists only from R1 to R3 (or the reverse), for example R1, O, R3, R2, R1, R3

Euler paths and circuits FAQ

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

Both use every edge exactly once. An Euler circuit ends at its starting vertex; an Euler path that is not a circuit ends somewhere else.

How do you know if a graph has an Euler circuit?

The graph must be connected, and every vertex must have even degree. If both are true, an Euler circuit exists.

Where does an Euler path start?

If exactly two vertices have odd degree, the path must start at one of them and end at the other. If all degrees are even, you can start anywhere and end where you began.

Why is the Königsberg bridge problem impossible?

All four land areas touch an odd number of bridges. An Euler path allows at most two vertices of odd degree, so no walk crosses every bridge exactly once.

Summary

  • An Euler path uses every edge exactly once; an Euler circuit also returns to its start.
  • A connected graph has an Euler circuit exactly when every degree is even.
  • It has an Euler path that is not a circuit exactly when it has two odd vertices, and the path runs between them.
  • With more than two odd vertices, no Euler path exists.
  • Fleury’s algorithm builds the route, crossing a bridge only when nothing else is left.

Previous lesson: Bipartite Graphs

Next lesson: Hamilton Paths and Circuits

Back to the Discrete Math Index