The disjoint-set data structure, also known as union-find, is useful for quickly testing whether nodes in a graph are connected or not.
Let’s say, you have a set of N elements which are partitioned into further subsets, and you have to keep track of connectivity of each element in a particular subset or connectivity of subsets with each other. To do this operation efficiently, you can use Union-Find Data Structure.