Efficient data structure for tracking disjoint sets, used for cycle detection and connected components.