Disjoint-set data structure (union–find data structure)

Basics

A disjoint-set data structure, also called a union–find data structure, is a data structure that keeps track of a set of elements partitioned into a number of disjoint (non-overlapping) subsets. It provides near-constant-time operations (bounded by the inverse Ackermann function $\alpha(n)$, which is less than 5 for any practical input size n; read more about Ackermann function) for adding new sets, merging sets and finding if two elements are in the same disjoint subset.

Question: how can we use these functions to turn a graph into a disjoint-set data structure?

Practical uses

Implementation: tree based