FLEURY’S ALGORITM
TEACHER : MAREK MAJEWSKI
By ABAS ABBASLI
BRIEF DESCRIPTION ABOUT FLEURY’S ALGORITHM
• Fleury's algorithm is an elegant but inefficient algorithm which dates to 1883. Consider a
graph known to have all edges in the same component and at most two vertices of odd
degree. The algorithm starts at a vertex of odd degree, or, if the graph has none, it starts
with an arbitrarily chosen vertex. At each step it chooses the next edge in the path to be
one whose deletion would not disconnect the graph, unless there is no such edge, in
which case it picks the remaining edge left at the current vertex. It then moves to the other
endpoint of that edge and deletes the edge. At the end of the algorithm there are no
edges left, and the sequence from which the edges were chosen forms an Eulerian cycle if
the graph has no vertices of odd degree, or an Eulerian trail if there are exactly two
vertices of odd degree.
EULER GRAPH
• A graph is called Eulerian if it has an Eulerian Cycle and called Semi-Eulerian if it
has an Eulerian Path.
• An Eulerian cycle (path) is a sub_graph
Ge = (V;Ee) of G = (V;E)
• which passes exactly once through each edge of G.
• G must thus be connected and all vertices V are visited (perhaps more than once).
We then says that G is Eulerian
EULER CIRCUIT & EULER
PATH
• How we will find a route that covers all the edges of the graph while revisiting the
least possible number of edges (deadhead travel)?
• In real-world problems, The cost is proportional to the amount of travel.
• Total cost of a route
= cost of traveling original edges in the graph
+ cost of deadhead travel
THE BRIDGES OF KONIGSBERG PROBLEM
• Seven bridges of Konigsberg problem, was first solved by Euler in the eighteenth
century. The problem was rather simple. The town of Konigsberg consists of two
islands and seven bridges. Is it possible, by beginning anywhere and ending
anywhere, to walk through the town by crossing all seven bridges but not crossing
any bridge twice?
FLEURY’S ALGORITHM
• Finds an Euler circuit in a connected graph with no odd vertices.
• Finds an Euler path in a connected graph with two odd vertices.
• The idea behind the algorithm: Don’t burn your bridges behind you.
• Fleury’salgorithmforfindinganEulertourinthegraphspecifiedbythegiven
adjacencymatrix.
• Input:TheadjacencymatrixAofagraph.
• Output:AnEulertour(eitheropenoracircuit)ifoneexists,andthenullobject
Noneotherwise
FLEURY’S ALGORITHM
• Let G be an Eulerian graph.
• STEP 1: Choose any vertex v of G and set current vertex equal to v and
• current trail equal to the empty sequence of edges.
• STEP 2: Select any edge e incident with the current vertex but choosing a
• bridge only if there is no alternative.
• STEP 3: Add e to the current trail and set the current vertex equal to the
• vertex at the ‘other end’ of e. [If e is a loop, the current vertex will not
• move.]
• STEP 4: Delete e from the graph. Delete any isolated vertices.
• Repeat steps 2 – 4 until all edges have been deleted from G. The final
• current trail is an Eulerian trail in G
• Every time we traverse another edge, we erase it from
• copy 1 but mark (red) and level it with the
• appropriate number on copy 2.
• Copy 1 gets smaller and copy 2 gets redder.
• Copy 1 helps us decide where to go next; copy 2
• helps us reconstruct our trip.
Fleury’s Theorem
Step 1: Travel from F to C
Could have also travel
from F to D
Step 2: Travel from C to D
Could have also travel
to A or to E
• Step 3: Travel from D to A
• Could have also travel
• to B but not to F – DF is a bridge!
Step 4: Travel from A to C
Could have also travel
to E but not to B – AB is a bridge!
Step 5: Travel from C to E
There is no choice!
FLEURY’S ALGORITHM
FOR FINDING EULER CIRCUIT
• First make sure that the graph is connected and all the vertices have even degree.
• Pick any vertex as the stating point
• When you have a choice, always choose to travel along an edge that is not a bridge of
the yet-to-betraveled part of the graph
• Label the edges in the order in which we travel them
• When we cannot travel any more, stop. we are done.
Let’s begin by choosing edge AB
Circuit so far : AB
Find an euler circuit algorithm.start at vertex a
FIND AN EULER CIRCUIT
ALGORITHM.START AT VERTEX A
AB is deleted .Let’s choose edge BE
Circuit so far : ABE
FIND AN EULER CIRCUIT
ALGORITHM.START AT VERTEX A
AB and BE are deleted.Notice we can not choose edge EA because this this would separate graph
Int two disconnected sets of edges . Choose edge ED
Circuit so far : ABED
FIND AN EULER CIRCUIT ALGORITHM.START AT VERTEX A
AB and BE are deleted.Notice we can not choose
edge EA .Notice if we did choose EA , the Graph is
separated. This violates Fleury’s Algorithm
FIND AN EULER CIRCUIT
ALGORITHM.START AT VERTEX A
AB and BE are deleted.Notice we can not choose edge
EA because this this would separate graph
Int two disconnected sets of edges . Choose edge ED
Circuit so far : ABED
FIND AN EULER CIRCUIT
ALGORITHM.START AT VERTEX A
AB,BE and ED are deleted.Notice there is only one option
for the next several choices . Choose edge DC , then CB ,
then BE , and then EA
Circuit so far : ABEDCBEA
FIND AN EULER CIRCUIT
ALGORITHM.START AT VERTEX A
AB,BE , ED , DC , CB , BE and EA are deleted.Now
we can choose AF or AG . Let’s choose AF
Circuit so far : ABEDCBEAF
FIND AN EULER CIRCUIT
ALGORITHM.START AT VERTEX A
AB,BE , ED , DC , CB , BE ,EA and AF are deleted. Again we have only one choice
from here . WE choose FG and GA so we are done.
Circuit so far : ABEDCBEAFGA
FIND AN EULER CIRCUIT
ALGORITHM.START AT VERTEX A
AB,BE , ED , DC , CB , BE ,EA ,AF and FG are deleted.The EULER circuit is complete
Circuit : ABEDCBEAFGA
APPLICATIONS
• Chinese postman problem
• Communicating networks
• Tourist guide
Fleurys abas  abbasli_

Fleurys abas abbasli_

  • 1.
    FLEURY’S ALGORITM TEACHER :MAREK MAJEWSKI By ABAS ABBASLI
  • 2.
    BRIEF DESCRIPTION ABOUTFLEURY’S ALGORITHM • Fleury's algorithm is an elegant but inefficient algorithm which dates to 1883. Consider a graph known to have all edges in the same component and at most two vertices of odd degree. The algorithm starts at a vertex of odd degree, or, if the graph has none, it starts with an arbitrarily chosen vertex. At each step it chooses the next edge in the path to be one whose deletion would not disconnect the graph, unless there is no such edge, in which case it picks the remaining edge left at the current vertex. It then moves to the other endpoint of that edge and deletes the edge. At the end of the algorithm there are no edges left, and the sequence from which the edges were chosen forms an Eulerian cycle if the graph has no vertices of odd degree, or an Eulerian trail if there are exactly two vertices of odd degree.
  • 3.
    EULER GRAPH • Agraph is called Eulerian if it has an Eulerian Cycle and called Semi-Eulerian if it has an Eulerian Path. • An Eulerian cycle (path) is a sub_graph Ge = (V;Ee) of G = (V;E) • which passes exactly once through each edge of G. • G must thus be connected and all vertices V are visited (perhaps more than once). We then says that G is Eulerian
  • 4.
    EULER CIRCUIT &EULER PATH • How we will find a route that covers all the edges of the graph while revisiting the least possible number of edges (deadhead travel)? • In real-world problems, The cost is proportional to the amount of travel. • Total cost of a route = cost of traveling original edges in the graph + cost of deadhead travel
  • 5.
    THE BRIDGES OFKONIGSBERG PROBLEM • Seven bridges of Konigsberg problem, was first solved by Euler in the eighteenth century. The problem was rather simple. The town of Konigsberg consists of two islands and seven bridges. Is it possible, by beginning anywhere and ending anywhere, to walk through the town by crossing all seven bridges but not crossing any bridge twice?
  • 6.
    FLEURY’S ALGORITHM • Findsan Euler circuit in a connected graph with no odd vertices. • Finds an Euler path in a connected graph with two odd vertices. • The idea behind the algorithm: Don’t burn your bridges behind you.
  • 7.
  • 8.
    FLEURY’S ALGORITHM • LetG be an Eulerian graph. • STEP 1: Choose any vertex v of G and set current vertex equal to v and • current trail equal to the empty sequence of edges. • STEP 2: Select any edge e incident with the current vertex but choosing a • bridge only if there is no alternative. • STEP 3: Add e to the current trail and set the current vertex equal to the • vertex at the ‘other end’ of e. [If e is a loop, the current vertex will not • move.] • STEP 4: Delete e from the graph. Delete any isolated vertices. • Repeat steps 2 – 4 until all edges have been deleted from G. The final • current trail is an Eulerian trail in G
  • 9.
    • Every timewe traverse another edge, we erase it from • copy 1 but mark (red) and level it with the • appropriate number on copy 2. • Copy 1 gets smaller and copy 2 gets redder. • Copy 1 helps us decide where to go next; copy 2 • helps us reconstruct our trip. Fleury’s Theorem
  • 10.
    Step 1: Travelfrom F to C Could have also travel from F to D
  • 11.
    Step 2: Travelfrom C to D Could have also travel to A or to E
  • 12.
    • Step 3:Travel from D to A • Could have also travel • to B but not to F – DF is a bridge!
  • 13.
    Step 4: Travelfrom A to C Could have also travel to E but not to B – AB is a bridge!
  • 14.
    Step 5: Travelfrom C to E There is no choice!
  • 16.
    FLEURY’S ALGORITHM FOR FINDINGEULER CIRCUIT • First make sure that the graph is connected and all the vertices have even degree. • Pick any vertex as the stating point • When you have a choice, always choose to travel along an edge that is not a bridge of the yet-to-betraveled part of the graph • Label the edges in the order in which we travel them • When we cannot travel any more, stop. we are done.
  • 17.
    Let’s begin bychoosing edge AB Circuit so far : AB Find an euler circuit algorithm.start at vertex a
  • 18.
    FIND AN EULERCIRCUIT ALGORITHM.START AT VERTEX A AB is deleted .Let’s choose edge BE Circuit so far : ABE
  • 19.
    FIND AN EULERCIRCUIT ALGORITHM.START AT VERTEX A AB and BE are deleted.Notice we can not choose edge EA because this this would separate graph Int two disconnected sets of edges . Choose edge ED Circuit so far : ABED
  • 20.
    FIND AN EULERCIRCUIT ALGORITHM.START AT VERTEX A AB and BE are deleted.Notice we can not choose edge EA .Notice if we did choose EA , the Graph is separated. This violates Fleury’s Algorithm
  • 21.
    FIND AN EULERCIRCUIT ALGORITHM.START AT VERTEX A AB and BE are deleted.Notice we can not choose edge EA because this this would separate graph Int two disconnected sets of edges . Choose edge ED Circuit so far : ABED
  • 22.
    FIND AN EULERCIRCUIT ALGORITHM.START AT VERTEX A AB,BE and ED are deleted.Notice there is only one option for the next several choices . Choose edge DC , then CB , then BE , and then EA Circuit so far : ABEDCBEA
  • 23.
    FIND AN EULERCIRCUIT ALGORITHM.START AT VERTEX A AB,BE , ED , DC , CB , BE and EA are deleted.Now we can choose AF or AG . Let’s choose AF Circuit so far : ABEDCBEAF
  • 24.
    FIND AN EULERCIRCUIT ALGORITHM.START AT VERTEX A AB,BE , ED , DC , CB , BE ,EA and AF are deleted. Again we have only one choice from here . WE choose FG and GA so we are done. Circuit so far : ABEDCBEAFGA
  • 25.
    FIND AN EULERCIRCUIT ALGORITHM.START AT VERTEX A AB,BE , ED , DC , CB , BE ,EA ,AF and FG are deleted.The EULER circuit is complete Circuit : ABEDCBEAFGA
  • 26.
    APPLICATIONS • Chinese postmanproblem • Communicating networks • Tourist guide