VOOZH about

URL: https://www.geeksforgeeks.org/dsa/euler-circuit-directed-graph/

⇱ Euler Circuit in a Directed Graph - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Euler Circuit in a Directed Graph

Last Updated : 23 Jul, 2025

Eulerian Path is a path in graph that visits every edge exactly once. Eulerian Circuit is an Eulerian Path which starts and ends on the same vertex. 

A graph is said to be eulerian if it has a eulerian cycle. We have discussed eulerian circuit for an undirected graph. In this post, the same is discussed for a directed graph.

For example, the following graph has eulerian cycle as {1, 0, 3, 4, 0, 2, 1} 

👁 SCC


How to check if a directed graph is eulerian? 

A directed graph has an eulerian cycle if following conditions are true

  1. All vertices with nonzero degree belong to a single strongly connected component
  2. In degree is equal to the out degree for every vertex.

We can detect singly connected component using Kosaraju’s DFS based simple algorithm

To compare in degree and out-degree, we need to store in degree and out-degree of every vertex. Out degree can be obtained by the size of an adjacency list. In degree can be stored by creating an array of size equal to the number of vertices. 

Following implementations of above approach. 


Output
Given directed graph is eulerian n

 Time complexity of the above implementation is O(V + E) as Kosaraju’s algorithm takes O(V + E) time. After running Kosaraju’s algorithm we traverse all vertices and compare in degree with out degree which takes O(V) time. 

Auxiliary Space : O(V), since an extra visited array of size V is required.

See following as an application of this. 
Find if the given array of strings can be chained to form a circle.

Comment