Skip to main content
Logo image

Section 4.5 Euler Paths and Circuits

Investigate!
An Euler path, in a graph or multigraph, is a walk through the graph which uses every edge exactly once. An Euler circuit is an Euler path which starts and stops at the same vertex. Our goal is to find a quick way to check whether a graph (or multigraph) has an Euler path or circuit.
  1. Which of the graphs below have Euler paths? Which have Euler circuits?
    A graph with six vertices.  Four vertices form a square, with another vertex centered inside the square, and the last vertex centered above the square.  Edges connect the corners of the square, and connect each corner to the center vertex.  The top two vertices of the square is adjacent to the vertex above the square.
    A graph with five vertices: four arranged in a square with the last one at the center of the square.  Edges connect neighboring vertices of the square, and the center vertex is adjacent to each vertex of the square.
    A graph with seven vertices.  Four vertices form the corners of a square, the remaining three are in a middle row, with one to the left, one in the center, and one to the right of the square.  Edges form the sides of the square.  Each vertex in the square is adjacent to the two middle-row vertices closest to it.
    Three vertices aligned in a vertical column left of a single vertex on the right.  Edges connect the vertex on the right to each vertex on the left.  Among the vertices on the left, two arced edges connect the bottom vertex to the center vertex, and two more connect the center vertex to the top vertex.
  2. List the degrees of each vertex of the graphs above. Is there a connection between degrees and the existence of Euler paths and circuits?
  3. Is it possible for a graph with a degree 1 vertex to have an Euler circuit? If so, draw one. If not, explain why not. What about an Euler path?
  4. What if every vertex of the graph has degree 2. Is there an Euler path? An Euler circuit? Draw some graphs.
  5. Below is part of a graph. Even though you can only see some of the vertices, can you deduce whether the graph will have an Euler path or circuit?
    Three vertices.  The center vertex is adjacent to the two on either side of it.  Each vertex has three dashed edges emanating downward (to illustrate that they go somewhere, but their other endpoints are not shown).
If we start at a vertex and trace along edges to get to other vertices, we create a walk through the graph. More precisely, a walk in a graph is a sequence of vertices such that every vertex in the sequence is adjacent to the vertices before and after it in the sequence. If the walk travels along every edge exactly once, then the walk is called an Euler path (or Euler walk). If, in addition, the starting and ending vertices are the same (so you trace along every edge exactly once and end up where you started), then the walk is called an Euler circuit (or Euler tour). Of course if a graph is not connected, there is no hope of finding such a path or circuit. For the rest of this section, assume all the graphs discussed are connected.
The bridges of Königsberg problem is really a question about the existence of Euler paths. There will be a route that crosses every bridge exactly once if and only if the graph below has an Euler path:
Three vertices aligned in a vertical column left of a single vertex on the right.  Edges connect the vertex on the right to each vertex on the left.  Among the vertices on the left, two arced edges connect the bottom vertex to the center vertex, and two more connect the center vertex to the top vertex.
This graph is small enough that we could actually check every possible walk that does not reuse edges, and in doing so convince ourselves that there is no Euler path (let alone an Euler circuit). On small graphs which do have an Euler path, it is usually not difficult to find one. Our goal is to find a quick way to check whether a graph has an Euler path or circuit, even if the graph is quite large.
One way to guarantee that a graph does not have an Euler circuit is to include a “spike,” a vertex of degree 1.
Three vertices in a triangle (with edges connecting them), plus a 4th vertex labeled a adjacent to one of the others.
The vertex \(a\) has degree 1, and if you try to make an Euler circuit, you see that you will get stuck at the vertex. It is a dead end. That is, unless you start there. But then there is no way to return, so there is no hope of finding an Euler circuit. There is however an Euler path. It starts at the vertex \(a\text{,}\) then loops around the triangle. You will end at the vertex of degree 3.
You run into a similar problem whenever you have a vertex of any odd degree. If you start at such a vertex, you will not be able to end there (after traversing every edge exactly once). After using one edge to leave the starting vertex, you will be left with an even number of edges emanating from the vertex. Half of these could be used for returning to the vertex, the other half for leaving. So you return, then leave. Return, then leave. The only way to use up all the edges is to use the last one by leaving the vertex. On the other hand, if you have a vertex with odd degree that you do not start a path at, then you will eventually get stuck at that vertex. The path will use pairs of edges incident to the vertex to arrive and leave again. Eventually all but one of these edges will be used up, leaving only an edge to arrive by, and none to leave again.
What all this says is that if a graph has an Euler path and two vertices with odd degree, then the Euler path must start at one of the odd degree vertices and end at the other. In such a situation, every other vertex must have an even degree since we need an equal number of edges to get to those vertices as to leave them. How could we have an Euler circuit? The graph could not have any odd degree vertex as an Euler path would have to start there or end there, but not both. Thus for a graph to have an Euler circuit, all vertices must have even degree.
The converse is also true: if all the vertices of a graph have even degree, then the graph has an Euler circuit, and if there are exactly two vertices with odd degree, the graph has an Euler path. To prove this is a little tricky, but the basic idea is that you will never get stuck because there is an “outbound” edge for every “inbound” edge at every vertex. If you try to make an Euler path and miss some edges, you will always be able to “splice in” a circuit using the edges you previously missed.

Euler Paths and Circuits.

  • A graph has an Euler circuit if and only if the degree of every vertex is even.
  • A graph has an Euler path if and only if there are at most two vertices with odd degree.
Since the bridges of Königsberg graph has all four vertices with odd degree, there is no Euler path through the graph. Thus there is no way for the townspeople to cross every bridge exactly once.

Subsection Hamilton Paths

Suppose you wanted to tour Königsberg in such a way that you visit each land mass (the two islands and both banks) exactly once. This can be done. In graph theory terms, we are asking whether there is a path which visits every vertex exactly once. Such a path is called a Hamilton path (or Hamiltonian path). We could also consider Hamilton cycles, which are Hamilton paths which start and stop at the same vertex.

Example 4.5.1.

Determine whether the graphs below have a Hamilton path.
The Petersen graph: ten vertices arranged in two rings of five each.  Each outer vertex is adjacent to the two outer vertices closest to it, forming a pentagon, and to the inner vertex closest to it.  Each inner vertex is adjacent to the two inner vertices not neighboring it, forming a 5-ponted star.
A graph with ten vertices.  Five vertices form a copy of K5, the complete graph in which each vertex is adjacent to the other four.  The remaining five vertices are each adjacent to only one of the five vertices in the copy of K5.
Solution.
The graph on the left has a Hamilton path (many different ones, actually), as shown here:
The Petersen graph with a highlighted path visiting every vertex exactly once.  The path starts at the top outer vertex, proceeds down and two the left to the bottom-left outer vertex, then to the top-left outer vertex, then in and across to the top-right outer vertex, and finally down to the bottom-left outer vertex and up to the bottom-left inner vertex.
The graph on the right does not have a Hamilton path. You would need to visit each of the “outside” vertices, but as soon as you visit one, you get stuck. Note that this graph does not have an Euler path, although there are graphs with Euler paths but no Hamilton paths.
It appears that finding Hamilton paths would be easier because graphs often have more edges than vertices, so there are fewer requirements to be met. However, nobody knows whether this is true. There is no known simple test for whether a graph has a Hamilton path. For small graphs this is not a problem, but as the size of the graph grows, it gets harder and harder to check wither there is a Hamilton path. In fact, this is an example of a question which as far as we know is too difficult for computers to solve; it is an example of a problem which is NP-complete.

Exercises Exercises

1.

You and your friends want to tour the southwest by car. You will visit the nine states below, with the following rather odd rule: you must cross each border between neighboring states exactly once (so, for example, you must cross the Colorado-Utah border exactly once). Can you do it? If so, does it matter where you start your road trip? What fact about graph theory solves this problem?
A map of the United States, with Southwest states highlighted.
Solution.
This is a question about finding Euler paths. Draw a graph with a vertex in each state, and connect vertices if their states share a border. Exactly two vertices will have odd degree: the vertices for Nevada and Utah. Thus you must start your road trip at in one of those states and end it in the other.

2.

Which of the following graphs contain an Euler path? Which contain an Euler circuit?
  1. \(\displaystyle K_4\)
  2. \(K_5\text{.}\)
  3. \(\displaystyle K_{5,7}\)
  4. \(\displaystyle K_{2,7}\)
  5. \(\displaystyle C_7\)
  6. \(\displaystyle P_7\)
Solution.
  1. \(K_4\) does not have an Euler path or circuit.
  2. \(K_5\) has an Euler circuit (so also an Euler path).
  3. \(K_{5,7}\) does not have an Euler path or circuit.
  4. \(K_{2,7}\) has an Euler path but not an Euler circuit.
  5. \(C_7\) has an Euler circuit (it is a circuit graph!)
  6. \(P_7\) has an Euler path but no Euler circuit.

3.

Edward A. Mouse has just finished his brand new house. The floor plan is shown below:
A rectangle subdivided into seven smaller rectangles, with three on top, and four below.  The top-left rectangle has gaps leading to the top-middle and bottom-left rectangles.  The top-middle rectangle also has gaps to the two bottom-middle rectangles and the top-right rectangle.  The top-right rectangle has gaps leading to the bottom-right rectangle and the bottom-middle-right rectangle.  The bottom rectangles have gaps leading to the bottom rectangles adjacent to them.
  1. Edward wants to give a tour of his new pad to a lady-mouse-friend. Is it possible for them to walk through every doorway exactly once? If so, in which rooms must they begin and end the tour? Explain.
  2. Is it possible to tour the house visiting each room exactly once (not necessarily using every doorway)? Explain.
  3. After a few mouse-years, Edward decides to remodel. He would like to add some new doors between the rooms he has. Of course, he cannot add any doors to the exterior of the house. Is it possible for each room to have an odd number of doors? Explain.

4.

For which \(n\) does the graph \(K_n\) contain an Euler circuit? Explain.

5.

For which \(m\) and \(n\) does the graph \(K_{m,n}\) contain an Euler path? An Euler circuit? Explain.

6.

For which \(n\) does \(K_n\) contain a Hamilton path? A Hamilton cycle? Explain.

7.

For which \(m\) and \(n\) does the graph \(K_{m,n}\) contain a Hamilton path? A Hamilton cycle? Explain.
Hint.
This is harder than the previous three questions. Think about which “side” of the graph the Hamilton path would need to be on every other step.

8.

A bridge builder has come to Königsberg and would like to add bridges so that it is possible to travel over every bridge exactly once. How many bridges must be built?
Solution.
If we build one bridge, we can have an Euler path. Two bridges must be built for an Euler circuit.
Three dots aligned in a vertical column left of a single dot on the right.  Lines connect the dot on the right to each dot on the left.  Among the dots on the left, two arced lines connect the bottom dot to the center dot, and two more connect the center dot to the top dot.  An additional dashed edge connects the right dot to the top dot and another dashed edge connects the bottom dot to the middle dot in the vertical column.

9.

Below is a graph representing friendships between a group of students (each vertex is a student and each edge is a friendship). Is it possible for the students to sit around a round table in such a way that every student sits between two friends? What does this question have to do with paths?
A complicated graph containing 9 vertices arranged in a circle.  If we call the vertex at the top of the circle 1, and number them proceeding clockwise, then vertex 1 is adjacent to 2, 4, 6, and 7.  Vertex 2 is also adjacent to 4 and 7.  Vertex 3 is adjacent to 6 and 8.  Vertex 4 is adjacent to 6, 7, 8, and 9.  Vertex 5 is adjacent to 6, 8, and 9.  Vertex 7 is also adjacent to 8.
Hint.
If you read off the names of the students in order, you would need to read each student’s name exactly once, and the last name would need to be of a student who was friends with the first. What sort of a cycle is this?

10.

On the table rest 8 dominoes, as shown below. If you were to line them up in a single row, so that any two sides touching had matching numbers, what would the sum of the two end numbers be?
A domino with two dots and four dots.
A domino with six dots and two dots.
A domino with one dot and three dots.
A domino with four dots and six dots.
A domino with five dots and three dots.
A domino with four dots and three dots.
A domino with six dots and five dots.
A domino with three dots and six dots.
Hint.
Draw a graph with 6 vertices and 8 edges. What sort of path would be appropriate?

11.

Is there anything we can say about whether a graph has a Hamilton path based on the degrees of its vertices?
  1. Suppose a graph has a Hamilton path. What is the maximum number of vertices of degree one the graph can have? Explain why your answer is correct.
  2. Find a graph which does not have a Hamilton path even though no vertex has degree one. Explain why your example works.

12.

Consider the following graph:
A graph with 11 vertices.  Eight of these are arranged in a circle and with eight edges form the border of an octagon.  The other three vertices are in a horizontal row in the center of the octagon.  Edges connect the top and bottom vertices of the octagon to the left and right inner vertices.  The left outer vertex is adjacent to the inner left vertex, and the right outer vertex is adjacent to the inner right vertex.  The remaining four vertices of the octagon are adjacent to the center vertex.
  1. Find a Hamilton path. Can your path be extended to a Hamilton cycle?
  2. Is the graph bipartite? If so, how many vertices are in each “part”?
  3. Use your answer to part (b) to prove that the graph has no Hamilton cycle.
  4. Suppose you have a bipartite graph \(G\) in which one part has at least two more vertices than the other. Prove that \(G\) does not have a Hamilton path.