Untitled
unknown
python
a year ago
323 B
1
Indexable
Never
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