UPI Study › Courses › Discrete Mathematics › Free lessons › Lesson 9.6 Free with a free account
Fleury's Algorithm
Discrete Mathematics · Chapter 9: Graph Theory: Foundations and Euler PathsSection 9.6 · lesson 64 of 878 min · free with a free account
Free preview
Create a free account to keep watching
It takes a minute and costs nothing. Your free account unlocks all of Chapter 1 and 3 more lessons of Discrete Mathematics.
Lesson complete
Earn the 4 college credits for Discrete Mathematics
Enrolling adds a quiz after each lesson, the graded work and the official transcript. Recommended for credit by NCCRS.
Next lesson: Euler's Theorems: Degrees, Paths, and Circuits →← Euler Paths and CircuitsNext lesson: Euler's Theorems: Degrees, Paths, and Circuits →
In this lesson
Building an Euler path edge by edge - without burning bridges.
- State Fleury's algorithm step by step
- Define a bridge and apply the bridge rule
- Trace the algorithm to a complete Euler path
- Compare it with Hierholzer's algorithm
Transcript
Everything said in the video, section by section (1,210 words). Read along, or search it.
Graph Theory: Foundations and Euler Paths
Fleury's Algorithm
Section nine point five told us when an Euler path or circuit exists. This section shows how to actually build one. Fleury's algorithm constructs the route one edge at a time. Its entire correctness rests on a single rule, often summed up as don't burn your bridges.
The Opening Problem
A Drone Inspecting Power Lines
A municipal utility operates a drone that inspects overhead power lines. To save flight time and battery, it should cross every line segment in a district exactly once, never doubling back over one it's already inspected. Section nine point five settled when that's possible. A connected graph has an Euler circuit when every degree is even, and an Euler path when exactly two degrees are odd. But that answers whether a route exists, not how to build one. An operator who knows a route exists still needs a concrete flight plan. Fleury's algorithm answers that. It's a step-by-step greedy procedure that constructs the route edge by edge. The one subtlety is choosing, at each vertex, which unused edge to take next. The wrong choice can strand the route, with unreachable edges still unused.
Algorithm 9.6.1
Fleury's Algorithm
The algorithm assumes the graph is connected, and already satisfies the criterion from section nine point five. It doesn't recheck that. Step one, choose a start. With two odd-degree vertices, start at either one, and the route will finish at the other. With none, start anywhere, and the route will return. Step two, look at the unused edges at the current vertex. Call the graph of not-yet-used edges H. Step three, choose. If only one unused edge remains, take it. If several remain, don't choose a bridge of H, unless every option is a bridge. Step four, traverse the edge. Mark it used, move to its other end, and remove it from H. Then repeat until every edge is used, and report the route. All the steps except step three are bookkeeping.
Definition 9.6.1
Bridges
So what is a bridge? An edge of a graph is a bridge, or cut-edge, if removing it increases the number of connected components. Equivalently, a bridge lies on no cycle. An edge that isn't a bridge always lies on some cycle, so an alternate route between its ends survives when it's removed. The word currently matters. An edge that isn't a bridge in the original graph can become one later, once enough of the edges around it have been used up. So Fleury's algorithm rechecks bridge status against the remaining graph H, at every single step, not just once at the start.
Lemma 9.6.1
Don't Burn Bridges Unless Necessary
Here's why the rule is necessary. Suppose the edge from u to v is a bridge of H. Removing it splits H, leaving u in one piece and v in another. If unused edges still remain in u's piece, and the algorithm crosses the bridge anyway, the route is now in v's piece. And since the bridge has been used, no remaining edge leads back. The edges left behind can never be reached, and the algorithm can't finish. Choosing a non-bridge instead, whenever one exists, keeps the current piece connected, so every remaining edge stays reachable. That makes the rule a genuine necessity, not a convenient heuristic. A graph with a valid route can still get stuck, because of one earlier greedy choice.
Worked Example 9.6.1
A Fiber-Maintenance Loop
Here's a complete trace. A small fiber-optic maintenance loop has seven junction boxes. A, B, and C form one triangle. D, E, and F form another. And the two triangles are joined only through a path from C, to M, to D. C and D each have degree three. Every other vertex has degree two. So there are exactly two odd-degree vertices. That means an Euler path exists between C and D, but not a circuit. Start at C.
The Trace
Only 2 Real Decisions
At C, all eight edges are unused. The options are C A, B C, and C M. Removing C A leaves A reachable through B, so it isn't a bridge. The same goes for B C. But removing C M cuts the triangle off from everything else. It's a bridge. Two non-bridge options exist, so C M must be avoided. Choose C A. From A, the only unused edge is A B. From B, the only one is B C. Both are forced. Back at C, only C M remains. It's a bridge, but it's the only option. That's the unless necessary clause. Cross it, then M D, which is forced too. At D, two options remain, D E and F D. Neither is a bridge in the remaining triangle, so either is valid. Choose D E. Then E F and F D are forced, ending at D. Only two steps involved a real decision. Every other step was forced.
Figure 1
The Route, Edge by Edge
Here's the whole route, with edges numbered in the order they're used. The two red edges, C to M and M to D, are the only links between the triangles. They're bridges from the very start. The route is C, A, B, C, M, D, E, F, D. It finishes the left triangle before committing to the one-way crossing. And it ends at D, the other odd-degree vertex, exactly as section nine point five predicts.
Listing 1
The Bridge Rule in Code
The code mirrors the trace directly. While edges remain, it looks at the current vertex's neighbors, in sorted order for a deterministic tie-break. If there's only one, the move is forced. Otherwise, it keeps only the choices that aren't bridges, and takes the first. It uses a bridge only when forced. The bridge test temporarily removes the edge, checks with a breadth-first search whether its two ends can still reach each other, and then restores it. Running it on the fiber graph prints C, A, B, C, M, D, E, F, D. It reproduces the hand trace exactly.
Table 2
Fleury Versus Hierholzer
Fleury's algorithm isn't the only way. Hierholzer's algorithm solves the same problem differently. Fleury extends a single route greedily, checking bridge status at each choice. Hierholzer builds small closed circuits, and then splices them together into one. Fleury needs a reachability search at every vertex with a choice. So a straightforward implementation takes time roughly proportional to the number of edges squared. Hierholzer needs no bridge checks, and runs in time roughly proportional to the number of edges. Fleury's strength is transparency. Its logic is easy to trace by hand. Hierholzer is faster, and it's what graph software typically uses on large graphs.
Takeaways
Anchor the Route, Then Cross
To summarize. Fleury's algorithm builds an explicit Euler path or circuit, one edge at a time, for a graph that already meets the degree criterion. When there's a choice, it never crosses a bridge of the remaining graph, unless every option is a bridge. Bridge status is rechecked at every step, since edges can become bridges as the route uses up their neighbors. And crossing a bridge too early can strand edges, even though a valid route exists. Here's something to think about. At the very first step, the trace chose C A. Suppose it had chosen B C instead. Would the path change, and how? More importantly, does Fleury's algorithm ever guarantee a unique Euler path? Or only that some valid path will be found? What does that say about calling its output the Euler path, rather than an Euler path? And why does step three only ever rule out bridges, and never choose between non-bridges?
About Discrete Mathematics at UPI Study
Discrete Mathematics (Math 230) is a self-paced online course of 87 video lessons in 13 chapters, from logic and proof to counting, probability, graph theory and trees. It carries a NCCRS credit recommendation for 4 semester credits.
Every lesson transcript is free on pages like this one, and the videos are free with a free UPI Study account. Enrolling adds a practice quiz after each lesson, the graded work and final exam that earn the credit, lifetime access, and an official transcript on completion. UPI Study has helped over 130,000 students with college credits. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
Enroll now → Course details Download the syllabus Every course with PRO →
Why take it here
Why students take Discrete Mathematics with UPI Study
Where the credit goes
Universities that work with NCCRS
Discrete Mathematics carries a NCCRS credit recommendation. These universities work with NCCRS; some are UPI Study's signed partners. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
Thomas Edison State UniversitySigned partner
University of the PeopleSigned partner
Charter Oak State CollegeSigned partner
Strayer UniversitySigned partner
Columbia Southern UniversitySigned partner
Indiana TechSigned partner
Penn StateWorks with NCCRS
Southern New Hampshire UniversityWorks with NCCRS
SUNYWorks with NCCRS
+many more cooperating universitiesFind my college →Find my college → Not listed? Ask Athena in the corner of this page, or book a 15-minute call.
FAQ
Questions students ask us
About Fleury's Algorithm
What is Fleury's algorithm for finding an Euler path or circuit?
What is a bridge in a graph, and what is the bridge rule?
How do you trace Fleury's algorithm on a graph with two triangles joined by a path?
How does Fleury's algorithm differ from Hierholzer's algorithm?
About the Discrete Mathematics course
How many college credits is Discrete Mathematics?
How much does Discrete Mathematics cost and what is included?
Which universities accept UPI Study credits?
How long does Discrete Mathematics take?
How are the exams done?
How do my credits reach my college?
Ready for the full course? Earn 4 credits in Discrete Mathematics.
87 video lessons, a quiz after each one, and the graded work that earns the credit. Recommended for credit by NCCRS.
4 credits · NCCRSEnroll →