Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Looking for algorithm finding euler path

I'm looking for an algorithm to find an Euler path in a graph.

I've seen a good one a couple of weeks ago but I can't find it now, I remember there was tagging edges, something with even/odd connections...

Do you know a similar, simple and straightforward algorithm?

like image 240
user2489034 Avatar asked Jul 04 '13 09:07

user2489034


People also ask

Which algorithm is used for finding Euler circuit?

Fleury's Algorithm is used to display the Euler path or Euler circuit from a given graph. In this algorithm, starting from one edge, it tries to move other adjacent vertices by removing the previous vertices. Using this trick, the graph becomes simpler in each step to find the Euler path or circuit.

How do you use Fleury's algorithm to find possible Euler paths?

FLEURY'S ALGORITHM If Euler's Theorem indicates the existence of an Euler path or Euler circuit, one can be found using the following procedure: If the graph has exactly two odd vertices choose one of these odd vertices as the starting point of an Euler path. If the graph has no odd vertices it has an Euler circuit.

What is Eulerian algorithm?

An Eulerian cycle, Eulerian circuit or Euler tour in an undirected graph is a cycle that uses each edge exactly once. If such a cycle exists, the graph is called Eulerian or unicursal. The term "Eulerian graph" is also sometimes used in a weaker sense to denote a graph where every vertex has even degree.


1 Answers

From Graph-Magics.com, for an undirected graph, this will give you the tour in reverse order, i.e. from the end vertex to the start vertex:

  1. Start with an empty stack and an empty circuit (eulerian path).
    • If all vertices have even degree: choose any of them. This will be the current vertex.
    • If there are exactly 2 vertices having an odd degree: choose one of them. This will be the current vertex.
    • Otherwise no Euler circuit or path exists.

Repeat step 2 until the current vertex has no more neighbors and the stack is empty.

  1. If current vertex has no neighbors:
    • Add it to circuit,
    • Remove the last vertex from the stack and set it as the current one.

Otherwise:

  • Add the vertex to the stack,
  • Take any of its neighbors, remove the edge between selected neighbor and that vertex, and set that neighbor as the current vertex.
like image 148
MJW Avatar answered Oct 09 '22 06:10

MJW