For this Question: Given a directed graph, detect the presence of a cycle in the graph.The first line of input contains two integers N and M which denotes the no of vertices and no of edges in the graph respectively. 
Next M lines contain space-separated integers u and v denoting that there is a directed edge from u to v.

Constraints:
1 <= N, M <= 1000
0 <= u, v <=  N-1, u != v
There are no self loops or multiple edges.The method should return 1 if there is a cycle else it should return 0.Sample Input 1:
4 5
0 1
1 2
2 3
3 0
0 2

Sample Output 1:
Yes

Explanation:
There is a cycle with nodes 0, 1, 2, 3

Sample Input 2:
4 4
0 1
1 2
2 3
0 3

Sample Output 2:
No

Explanation:
There is no cycle in this graph, I have written this Solution Code: from collections import defaultdict
 
class Graph():
    def __init__(self,vertices):
        self.graph = defaultdict(list)
        self.V = vertices
 
    def addEdge(self,u,v):
        self.graph[u].append(v)
 
    def isCyclicUtil(self, v, visited, recStack):
 
        visited[v] = True
        recStack[v] = True
 
        for neighbour in self.graph[v]:
            if visited[neighbour] == False:
                if self.isCyclicUtil(neighbour, visited, recStack) == True:
                    return True
            elif recStack[neighbour] == True:
                return True
 
        recStack[v] = False
        return False
 
    def isCyclic(self):
        visited = [False] * (self.V + 1)
        recStack = [False] * (self.V + 1)
        for node in range(self.V):
            if visited[node] == False:
                if self.isCyclicUtil(node,visited,recStack) == True:
                    return True
        return False
 
V,edges=map(int,input().split())
g = Graph(V)
for i in range(edges):
    u,v=map(int,input().split())
    g.addEdge(u,v)
if g.isCyclic() == 1:
    print ("Yes")
else:
    print ("No"), In this Programming Language: Python, Now tell me if this Code is compilable or not?