This is extracted from GeeksforGeeks.
Eulerian Path is a path in graph that visits every edge exactly once.
Eulerian Cycle is an Eulerian Path which starts and ends on the same vertex.
A graph is called
Eulerian if it has an
Eulerian Cycle and called
Semi-Eulerian if it has an
An undirected graph has Eulerian Cycle if following two conditions are true.
All vertices with non-zero degree are connected. We don’t care about vertices with zero degree because the don’t belong to Eulerian Cycle or Path (we only consider all edges).
All vertices have even degree.
Same as condition 1 for Eulerian Cycle.
If zero or two vertices have odd degree and all other vertices have even degree. Note that only one vertices with odd degree is not possible in an undirected graph (sum of all degrees is always even in an undirected graph).
# Python program to check if a given graph is Eulerian or not