Objective: Given a graph, check if the graph contains a cycle using disjoint set.

Note: Disjoint-set data structure, also called a union–find data structure or merge–find set.

Example:

Earlier in Detect Cycle in Undirected Graph using DFS we discussed about how to find cycle in graph using DFS. In this article we will discuss how to find cycle using disjoint-set.

If you find anything incorrect or you feel that there is any better approach to solve the above problem, please write comment.
__________________________________________________