A Python implementation of the disjoint set (union-find) data structure, featuring path compression and union by rank/size. Current version 0.9.0, requires Python >=3.10. The library is stable with occasional updates.
pip install disjoint-setVerified import paths — ran on the pinned version, not inferred.
Quickstart: create a DisjointSet, use union and find.
Explicitly call 'ds.find(x)' for each element before unions, or use 'ds.add(x)' if available (not in this library).
Always call find after union to compress paths immediately for subsequent operations.
Install using 'pip install disjoint-set' and import as 'from disjoint_set import DisjointSet'.
Instantiate without arguments: ds = DisjointSet(); then add elements via find/union.
Use 'find' to implicitly add an element: ds.find(x).
No dependency data recorded yet.