Untitled
unknown
python
3 years ago
323 B
6
Indexable
def dfs_cycle(node,parent): vis[node] = True for i in adj[node]: if i == parent or i == node:return True# self loop i to i elif vis[i] == False and dfs_cycle(i,parent):return True return False for i in range(N): if vis[i] == False and dfs_cycle(i,i):return False return True
Editor is loading...