In the first section, we created a graph of the Königsberg bridges and asked whether it was possible to walk across every bridge once. Because Euler first studied this question, these types of paths are named after him.
An Euler path is a path that uses every edge in a graph with no repeats. Being a path, it does not have to return to the starting vertex.
In the graph shown below, there are several Euler paths.
One such path is CABDCB. The path is shown in arrows to the right, with the order of edges numbered.
An Euler circuit is a circuit that uses every edge in a graph with no repeats. Being a circuit, it must start and end at the same vertex.
The graph below has several possible Euler circuits.
Here’s a couple, starting and ending at vertex A: ADEACEFCBA and AECABCFEDA. The second is shown in arrows.
Look back at the example used for Euler paths – does that graph have an Euler circuit? A few tries will tell you no; that graph does not have an Euler circuit. When we were working with shortest paths, we were interested in the optimal path. With Euler paths and circuits, we’re primarily interested in whether an Euler path or circuit exists.
Why do we care if an Euler circuit exists? Think back to our housing development lawn inspector from the beginning of the chapter. The lawn inspector is interested in walking as little as possible. The ideal situation would be a circuit that covers every street with no repeats. That’s an Euler circuit! Luckily, Euler solved the question of whether or not an Euler path or circuit will exist.
A graph will contain an Euler path if it contains at most two vertices of odd degree.
A graph will contain an Euler circuit if all vertices have even degree
In the graph below, vertices A and C have degree 4, since there are 4 edges leading into each vertex. B is degree 2, D is degree 3, and E is degree 1. This graph contains two vertices with odd degree (D and E) and three vertices with even degree (A, B, and C), so Euler’s theorems tell us this graph has an Euler path, but not an Euler circuit.
Is there an Euler circuit on the housing development lawn inspector graph we created earlier in the chapter? All the highlighted vertices have odd degree. Since there are more than two vertices with odd degree, there are no Euler paths or Euler circuits on this graph. Unfortunately our lawn inspector will need to do some backtracking.
When it snows in the same housing development, the snowplow has to plow both sides of every street. For simplicity, we’ll assume the plow is out early enough that it can ignore traffic laws and drive down either side of the street in either direction. This can be visualized in the graph by drawing two edges for each street, representing the two sides of the street.
Notice that every vertex in this graph has even degree, so this graph does have an Euler circuit.
Now we know how to determine if a graph has an Euler circuit, but if it does, how do we find one? While it usually is possible to find an Euler circuit just by pulling out your pencil and trying to find one, the more formal method is Fleury’s algorithm.
- Start at any vertex if finding an Euler circuit. If finding an Euler path, start at one of the two vertices with odd degree.
- Choose any edge leaving your current vertex, provided deleting that edge will not separate the graph into two disconnected sets of edges.
- Add that edge to your circuit, and delete it from the graph.
- Continue until you’re done.
Let’s find an Euler Circuit on this graph using Fleury’s algorithm, starting at vertex A.
Original Graph. Choosing edge AD.
Circuit so far: AD
AD deleted. D is current. Can’t choose DC since that would disconnect graph. Choosing DE
Circuit so far: ADE
E is current. From here, there is only one option, so the rest of the circuit is determined.
Does the graph below have an Euler Circuit? If so, find one.
Yes, all vertices have even degree so this graph has an Euler Circuit. There are several possibilities. One is: ABEGFCDFEDBCA