Discrete MathematicsGraphs, Paths and Circuits5 of 6
Graphs, Paths and Circuits · 5
Euler Paths and Circuits
When we look at a network of streets, bridges, or lines in a drawing, we want to know whether we can trace every single edge in one continuous walk without ever retracing our steps.
The Seven Bridges of Königsberg
Turning the map into a graph strips away the shapes of the islands and leaves only the vertices and the edges connecting them, which lets us state the two versions of the puzzle for any graph:
Euler path:a walk that crosses every edgeexactly onceEuler circuit:an Euler path that ends backat its starting vertex
1
Counting Degrees to Test for a Route
Before trying to trace a route by trial and error, we want to tell right away whether an Euler circuit or an Euler path is even possible, and which vertices must serve as the start and end.
Why Odd Degrees Trap You
Remember two degree facts as you count:
A loop attached to a vertex leaves on one end (OUT) and enters on the other (IN), so each loop adds 2 to that vertex's degree.
By the Handshake Lemma, every edge has 2 ends, so the sum of all degrees is 2×(number of edges), which is an even number. That means odd-degree vertices always come in pairs (0,2,4,…).
For any connected graph, the number of odd-degree vertices decides the puzzle completely:
0 odd vertices (all even):Euler circuit(start and end at any vertex)Exactly 2 odd vertices:Euler path only(start at one odd vertex,end at the other)4 or more odd vertices:Neither(impossible without repeating edges)
Here is how that degree count settles both the Königsberg bridge puzzle and the house drawing.
Text solution
Count the degrees on the Königsberg graphEach bridge touching a landmass adds 1 to its degree, with parallel bridges counted separately.
deg(N)=3,deg(S)=3,deg(B)=3,deg(A)=5
Check the number of odd vertices for KönigsbergA single walk has only one start and one end, so it can handle at most 2 odd vertices.
Odd vertices=4⟹no Euler circuit and no Euler path
Compare with the house graphThe roof peak has degree 2, the two middle corners each have degree 4, and only the two bottom corners have odd degree.
Degrees: 2,4,4,3,3⟹exactly 2 odd vertices
So the Königsberg bridge walk is impossible from every starting point, whereas the house drawing has an Euler path as long as you start at one bottom corner and finish at the other.
In both the house graph and the square-with-an-X, every pass through a vertex pairs an arrival edge (IN) with a departure edge (OUT). That leaves one unmatched OUT at the start and one unmatched IN at the traveler's current vertex. Those two pair up whenever the walk returns to the start. At an odd-degree vertex other than the start, once the walk has used every edge there, its last visit was an arrival with no edge left to leave on, so that vertex has to be the end.
Every pass through a vertex pairs one IN edge with one OUT edge, so any odd-degree vertex that isn't the start or end traps the walk on its final IN edge.
2
Building an Euler Circuit: Hierholzer's Splicing Method
Counting degrees tells us that a connected graph with all even degrees has an Euler circuit, but if we just walk at random we can close our loop back at the start too early and leave part of the graph untouched. We want a step-by-step way to pull every leftover edge into one complete circuit.
Hierholzer's Splicing Method
Text solution
Trace an initial closed loop from AWalk along edges until returning to A leaves no unused exit at A, covering 3 of the 10 edges.
A→B→C→A
Trace Detour 1 from B and splice it inPick vertex B on the current route, follow its unused edges around the middle triangle back to B, and replace B with that loop.
A→detour at BB→D→F→B→C→A
Trace Detour 2 from C and splice it inFollow the remaining 4 unused edges starting from C back to C, and replace C with that loop.
A→B→D→F→B→detour at CC→D→E→F→C→A
So splicing the two detours into our initial loop brings all 10 edges into a single Euler circuit starting and ending at A.
3
Tracing in One Pass: Fleury's Method
Splicing works by going back to insert detours into an earlier loop, which is convenient on paper or in code. When we want to trace the entire route in one continuous pass from start to finish without going back to insert detours, we need a rule that prevents us from stranding any part of the graph behind us.
Fleury's Method: Avoiding Bridges
Text solution
Start at an odd vertex and walk while erasing non-bridgesBegin at odd vertex A(deg(A)=3) and erase each crossed edge as you go until reaching C.
A→B→D→A→C(edges AB,BD,DA,AC erased)
Avoid the bridge of the remaining graph at CAmong the remaining edges CB,CE,ED,DC, crossing CB now would isolate B and strand the unused roof triangle C–E–D–C.
bridge of remaining graphCB⟹save CB for last
Trace the non-bridge cycle first, then cross the bridgeWalk around the roof triangle back to C, and finally take CB when it is the only edge left.
A→B→D→A→C→E→D→C→B
So saving the bridge CB until no other choice remains lets the walk cover all 8 edges in a single continuous pass from odd A to odd B.
Because each crossed edge is erased behind the traveler, crossing a bridge of the remaining graph leaves no unused path back across it, so any unused edges on the side you left are stranded behind you. Saving bridges for last keeps the remaining unused edges connected to the traveler all the way to the end.
As each edge you cross is erased, crossing a bridge too early strands a piece of the remaining edges behind you, while saving bridges for last keeps them connected to the end.
4
Repeating Edges: The Snowplow Problem
Both Hierholzer's and Fleury's methods require a graph with 0 or 2 odd vertices, but a snowplow or garbage truck on a neighborhood grid with 4 or more odd intersections still has to cover every street and return to its garage. Our goal is to make every vertex even by repeating the smallest possible number of street blocks.
Repeating Edges: The Snowplow Problem
Text solution
Duplicate a path between two odd verticesAdding a second copy of each street along the 2-block path W1→X→W2 adds 1 edge to each odd endpoint and 2 edges to the corner X in between.
deg(W1)+1=even,deg(X)+2=even,deg(W2)+1=even
Compare the total repeated blocks for two of the three pairings of the 4 odd verticesAdd the shortest path lengths between the paired odd intersections across town versus on the same side.
Pair (W1,E1) and (W2,E2):5+5=10 repeated blocksPair (W1,W2) and (E1,E2):2+2=4 repeated blocks
So pairing W1 with W2 and E1 with E2 turns all four odd intersections even while requiring the snowplow to re-drive only 4 blocks instead of 10.
Duplicating the streets along a path between two odd intersections adds 1 edge to each odd endpoint (turning both even) and 2 edges to every intersection in between along the path (keeping them even). Pairing nearby odd intersections repeats far fewer blocks than pairing distant ones.
Repeating a path between two odd intersections turns both endpoints even and keeps every intersection in between even, so any pairing of the odd intersections gives an Euler circuit.
Key concepts
Before counting degrees on any graph, first check that the graph is connected (ignoring any isolated vertices with no edges). If the edges sit in two separate pieces, such as two disconnected triangles where every vertex has degree 2, no single walk can ever cross from one piece to the other.
Once you know the graph is connected, count the degree of each vertex, remembering that a loop adds 2 to its vertex's degree and that odd vertices always come in pairs (∑deg(v)=2×edges):
0 odd vertices (all even)
An Euler circuit exists (and counts as an Euler path too); you can start at any vertex and you will finish at that same vertex.
Exactly 2 odd vertices
An Euler path exists, but no circuit; the walk must start at one odd vertex (using its extra edge to leave, like deg(A)=3 in the house graph) and end at the other odd vertex (using its extra edge to arrive last, like deg(B)=3).
4 or more odd vertices
No Euler path or circuit exists without repeating edges (like Königsberg with degrees 3,3,3,5). Only duplicate edges when your goal requires it. If a connected graph already has 0 odd vertices (for a circuit) or 2 odd vertices (for a path), no edge needs to be repeated.
When a route exists, pick your tracing method by how you want to build the walk:
Hierholzer's Splicing Method
builds the route in stages: trace a closed loop until you have no unused exit at your starting vertex, pick a vertex on your route that still has unused edges, trace a detour loop through the unused edges back to that vertex, and splice the detour in place of that vertex (turning A→B→C→A into A→B→D→F→B→C→A).
Fleury's Method
traces the route in one continuous pass: erase each edge as you cross it, and never cross a bridge of the remaining unused graph (like CB at C when B has no other edges left) unless you have no other choice.
Snowplow / Eulerization
fixes a graph with odd vertices when you must cover every edge and return to the start: test the pairings of the odd vertices, pick the pairing whose shortest connecting paths sum to the fewest edges, and duplicate every edge along those paths.
5
Practice
1
A connected graph on vertices A,B,C,D,E has edges AB,BC,CD,DA,AC,CE,DE, plus a loop attached to E. Does this graph have an Euler circuit, an Euler path that is not a circuit, or neither? If a route exists, which vertices can be the start and end?
Count how many edge ends touch each vertex, paying careful attention to how many ends the loop contributes at E.
Count the degree of each vertex from the 7 non-loop edges and the loop at E:
deg(A)=3,deg(B)=2,deg(C)=4,deg(D)=3,deg(E)=2+2=4
(Watch out: the likeliest slip is counting the loop at E as adding 1 to deg(E) instead of 2, which gives deg(E)=3 and three odd vertices A,D,E. That count is impossible by the Handshake Lemma, and leads to the wrong answer "neither.")
Because the graph is connected and has exactly 2 odd vertices (A and D), it has an Euler path that is not a circuit, which must start at A and end at D, or start at D and end at A.
2
In the Königsberg bridge graph, landmasses N,S, and B each have degree 3 and the center island A has degree 5. (a) If the city builds one new bridge between N and S, does the town now have an Euler path or an Euler circuit, and where must the walk start and end? (b) What is the minimum number of new bridges needed to create an Euler circuit, and where could they be placed?
Each new bridge adds 1 to the degree of its two endpoint landmasses; check which landmasses remain odd after each addition.
(a) Adding an edge between N and S increases both of their degrees by 1:
deg(N)=4,deg(S)=4,deg(A)=5,deg(B)=3
(Watch out: a common slip is assuming the walk starts at N and ends at S where the new bridge was built; instead, the new bridge makes N and S even pass-through vertices and leaves A and B as the odd endpoints.)
With 2 odd vertices left, the town has an Euler path (not a circuit) that must start at A and end at B, or start at B and end at A.
(b) Every vertex must become even for an Euler circuit, and each new bridge changes the odd/even parity of at most 2 vertices. (Watch out: 1 new bridge only fixes 2 of the 4 odd vertices, giving an Euler path rather than an Euler circuit.) Fixing all 4 odd vertices requires a minimum of 2 new bridges, for example, one bridge between N and S and one bridge between A and B (making the degrees 4,4,6,4).
3
A connected graph on vertices A,B,C,D,E,F has 8 edges: AB,BC,CD,DA,BE,EF,FD,DB. Every vertex has even degree (deg(A)=deg(C)=deg(E)=deg(F)=2 and deg(B)=deg(D)=4). You start at A and trace A→B→C→D→A, getting trapped at A after only 4 edges. Use Hierholzer's Splicing Method to find a detour loop in the unused edges and splice it into your initial route to get a full Euler circuit.
Find a vertex on A→B→C→D→A that touches the 4 unused edges BE,EF,FD,DB, trace a closed loop through those 4 edges starting and ending at that vertex, and substitute that loop for the vertex.
The 4 unused edges BE,EF,FD,DB meet the initial route at B (and D). Starting a detour at B along the unused edges gives the closed loop:
B→E→F→D→B
(Watch out: don't tack the detour onto the end of the initial walk as A→B→C→D→A→B→E→F→D→B, which crosses edge AB a second time to get from A back to B; the detour must replace B right where the initial walk visits it.)
Splicing this detour in place of B in A→B→C→D→A gives the 8-edge Euler circuit:
A→B→E→F→D→B→C→D→A
4
A connected graph on vertices A,B,C,D,E,F has the 8 edges AF,FB,BA,AC,BC,CD,DE,EC. Its only odd vertices are A and B (each of degree 3). Using Fleury's Method, you start at A and walk A→F→B→A→C, erasing those 4 edges as you go. At C, the remaining unused edges are CB,CD,DE,EC. Which edge at C does Fleury's Method forbid taking next, why, and how should the walk finish?
Look at what happens to the remaining graph on {B,C,D,E} if you erase CB versus if you erase CD or CE.
At C, the remaining unused edges form the triangle C–D–E–C plus the single edge CB.
(Watch out: it is tempting to take CB next because CB belonged to the triangle A–B–C–A in the original graph, but erasing BA and AC earlier destroyed that cycle and turned CB into a bridge of the remaining graph.)
Fleury's Method forbids taking CB next because CB is a bridge of the remaining graph: erasing CB would trap the walk at B (which has no other remaining edges) and strand the unused triangle C–D–E–C behind you. Instead, walk around the triangle first and save CB for last, finishing via C→D→E→C→B (or C→E→D→C→B).
5
A snowplow must plow every street in a connected grid and return to its garage. Every intersection has even degree except four odd intersections P,Q,R,S. The shortest distances between them are: P to Q is 3 blocks, R to S is 4 blocks, P to R is 2 blocks, Q to S is 3 blocks, P to S is 5 blocks, and Q to R is 4 blocks. Which pairing of the four odd intersections minimizes the number of blocks plowed twice, how many repeated blocks does it require, and why do the intersections in between along those repeated paths stay even?
List all three ways to split {P,Q,R,S} into two separate pairs and sum the distances for each pairing.
Compare all three pairings of the four odd intersections:
(P,Q) and (R,S):(P,R) and (Q,S):(P,S) and (Q,R):3+4=7 blocks2+3=5 blocks5+4=9 blocks
(Watch out: don't just take the first pairing (P,Q) and (R,S) to get 7 blocks, and don't reuse an intersection in two pairs like PR=2 and PQ=3. Reusing P adds +2 to P, leaving both P and S odd.)
The best pairing is (P,R) and (Q,S), which requires 5 repeated blocks, and every intersection in between along the duplicated paths stays even because it gains 2 extra edges (one IN and one OUT), adding 2 to its even degree.
6
(a) A student claims that any 6-vertex graph in which every vertex has degree 2 must have an Euler circuit. Is this true? Explain or give a counterexample. (b) Another student claims to have drawn a connected graph with 8 vertices, seven of degree 4 and one of degree 3, that has an Euler path starting and ending at different vertices. Explain why no such graph can exist.
For (a), check the condition required before the degree test applies; for (b), add up the degrees of all 8 vertices.
(a) (Watch out: checking only "all degrees are even" gives the wrong answer "True" by overlooking connectedness.)False: the graph must also be connected; for example, two separate triangles A–B–C–A and D–E–F–D have 6 vertices all of degree 2, but no Euler circuit exists because no walk can get from one triangle to the other.
(b) (Watch out: a walk cannot start at the degree-3 vertex and end at one of the degree-4 vertices, because ending at a vertex uses one final unmatched IN edge, which would force that ending vertex to have odd degree too.) By the Handshake Lemma, the sum of all degrees in any graph must be even, so odd vertices always come in pairs; here the degrees sum to 7×4+3=31 (odd), so no such graph can exist.