


For the given graph:

The required path exists in the given graph as we can start from 1 and follow the path 1 -> 0 -> 2 -> 1. This path visits all edges exactly once. Hence, the answer is YES.
The first line of the input contains an integer, 'T,’ denoting the number of test cases.
The first line of each test case contains two integers ‘N’ and ‘E’ denoting the number of vertices and edges.
The next ‘E’ lines have two integers denoting an edge between them.
For each test case, print ‘YES’ if the path with given condition is possible,else print ‘NO’.
Print the output of each test case in a separate line.
You do not need to print anything. It has already been taken care of. Just implement the given function.
1 <= T <= 10
2 <= N <= 1000.
1 <= E <= min(N*(N-1)/2, 5000).
0 <= u,v < ‘N’
Time limit: 1 sec
In this approach, we will Euler Circuit Detection to find either an Euler circuit is present in the graph or not.
In graph theory, Euler Circuit is defined as a path that starts and ends at the same vertex and traverse all edges of the graph exactly once.
An undirected graph has an Eulerian cycle if the following two conditions are true.
i) All vertices with non-zero degrees are connected.
ii) All vertices must have an even degree.
All vertices must have an even degree because to complete a cycle because for each incoming edge there must be an outgoing edge as we had to use each edge only once.
We will first store the graph in an adjacency list manner and then check the degrees of all vertices. If we found any vertex with an odd degree, the answer will be ‘FALSE’.After that, we will check either all the subgraphs having some edges are connected or not using depth-first traversal. If they are connected, both the conditions are satisfied, return ‘TRUE’.Else , return ‘FALSE’.