Detect cycle in an undirected graph
Given an undirected graph, how to check if there is a cycle in the graph
Solution:
- There are two ways to solve this
- Using DFS O(V+E) or
- Using Disjoint Set with Union-Find algorithm O(ElogV)
Latest Source Code:
Github: LoopDetectorInUndirectedGraph.java
Output: