I know that one can detect cycles in direct graphs using DFS and BFS. I want to know whether we can detect cycles in directed graphs using Union-Find or not? I
A disjoint set with only path compression implemented is like this: // In cpp. int Find(int x) { return f[x] == x ? x : f[x] = Find(f[x]); } int Union(int a, i