From 4f8ebbbf20a5f682f6dd8539316663570c85bc20 Mon Sep 17 00:00:00 2001 From: jayant agarwal <94584986+jayant-01@users.noreply.github.com> Date: Sat, 1 Oct 2022 11:43:03 +0530 Subject: [PATCH] Update Cycle in Directed Graph.py --- Cycle in Directed Graph.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Cycle in Directed Graph.py b/Cycle in Directed Graph.py index a6fce21..876adde 100644 --- a/Cycle in Directed Graph.py +++ b/Cycle in Directed Graph.py @@ -4,11 +4,14 @@ sys.setrecursionlimit(1000000) from collections import defaultdict class Graph: + @staticmethod def __init__(self,v): self.d=defaultdict(list) self.V=v + @staticmethod def addedge(self,u,v): self.d[u].append(v) + @staticmethod def cycleditact(self,s,visited,restack): visited[s]=True restack[s]=True @@ -20,6 +23,7 @@ def cycleditact(self,s,visited,restack): return True restack[s]=False return False + @staticmethod def cycle(self): visited=[False for i in range(self.V+1)] restack=[False for i in range(self.V+1)] @@ -32,6 +36,7 @@ class Solution: # @param A : integer # @param B : list of list of integers # @return an integer + @staticmethod def solve(self, A, B): g=Graph(A) for p in B: