0

Based on standard defination, Eulerian Path is a path in graph that visits every edge exactly once.

Now, I am trying to find a Euler path in a directed Graph. I know the algorithm for Euler circuit. Its seems trivial that if a Graph has Euler circuit it has Euler path. source:geeksforgeeks

[image source: geeksforgeeks.org]

So for above directed graph which has a Euler circuit also has Euler path.

Now if i remove an Edge lets say from 4 to 0 it is no more an Euler circuit.

  1. if start my DFS from vertex 0 i still have Euler Path.
  2. if start from vertex 3 i do not have Euler path

So, is it a requirement, that a directed graph has to be in Euler circuit to be an Euler path? I thought, Euler path should be less restrictive then Euler circuit.

Is there any directed graph which can be Euler path but not Euler circuit.

Guy Coder
  • 24,501
  • 8
  • 71
  • 136
minhaz
  • 4,233
  • 3
  • 33
  • 49
  • 1
    "Is there any directed graph which can be Euler path but not Euler circuit." - You answered that yourself, just remove any edge from this graph and it will still have a Eulerian path, but no Eulerian cycle. – G. Bach Dec 20 '14 at 21:22

3 Answers3

4

So, is it a requirement, that a directed graph has to be in Euler circuit to be an Euler path?

No

I thought, Euler path should be less restrictive than Euler circuit.

Correct

Is there any directed graph which can be Euler path but not Euler circuit.

Yes

I believe that your confusion is derived from the fact that when you DFS a directed graph starting from different nodes, you might get different results because some nodes might not be accessible when you start from different nodes. This has nothing to do with the definition of Eulerian path/trail. In order to "implement" the search for Eulerian path in a directed graph, you should run DFS from every node - and only if all the results returned False (no Eulerian path was found) then you know for sure that there is no Eulerian path. If there is an Eulerian cycle, there must be a node from which you can start DFS and find an Eulerian path.

Nir Alfasi
  • 53,191
  • 11
  • 86
  • 129
  • @user1990169 you're right, my bad - I went thru it fast and thought that the question is the other way around (if there can be an Eulerian circuit without an Euler path). Fixed. – Nir Alfasi Dec 21 '14 at 21:04
1

Yes there is lots of graphs which can be Euler path but not Euler circuit. just like your graph after removing 4->0.

If a graph has Euler circuit it is easier to find an Euler path, because if you start from every node, you could find an Euler path, because all of them are in the circuit, but if you dont have an Euler circuit you cant start from any node that you wish to find your Euler path. Because just one of the nodes will be start of path and selecting any other node could result in not finding a path.

One simple approach is to run dfs from every node and check if there are Euler path that starts from any of them and that is the worst efficient algorithm, because it has complexity of O( V2 + E * V)

There are multiple good approaches that you can find one of them here. that have complexity of O( V + E ) which is V time better that previous algorithm.

Lrrr
  • 4,755
  • 5
  • 41
  • 63
-1

The requirements for a graph to have an Eulerian circuit/path:

  • Circuit (which also counts as a path): no vertices have odd degree
  • Path (but no circuit): two vertices have odd degree; in this case, the path will begin at one of the odd vertices and end at the other
Azmisov
  • 6,493
  • 7
  • 53
  • 70