A connectivity record can stay mathematically identical while the data structure storing it changes during a query. Union-find, also called a disjoint-set structure, makes that distinction explicit. Its parent pointers represent membership in groups; they are not necessarily edges in the network that produced those groups. For robotics software that accumulates connectivity relationships, confusing those two meanings can turn an internal optimization into an incorrect claim about a physical or logical route.
Define the maintained information
Let eight invented record identifiers A through H begin in separate sets. A partition puts each identifier in exactly one nonempty set. The find operation returns a representative of its set, while union combines the sets containing two supplied identifiers. This example models undirected connectivity under additions. It does not assert that the supplied connections exist on a deployed robot.
Represent each set as a rooted tree. Every identifier stores one parent, and a root points to itself. Following parents from an identifier eventually reaches its representative. Equality of representatives answers whether two identifiers belong to the same set. It does not reveal how many original edges separate them.
Cornell's original notes describe parent forests, rank-based union, and compression. Princeton's course slides distinguish compression from path halving. The eight-record trace below is independently constructed; it is not an execution trace from either source's code or figures.
Build a forest with stated tie rules
Initialize every rank to zero. On a union of distinct roots, attach the lower-rank root beneath the higher-rank root. If their ranks are equal, choose the alphabetically earlier root as parent and increase that root's rank by one. This tie rule makes the example reproducible. A different consistent choice can represent the same partition.
First process the connections A-B, C-D, E-F, and G-H. The roots become A, C, E, and G, each of rank one. The nonroot pointers are B to A, D to C, F to E, and H to G. There are four sets.
Next process B-D. Their roots are A and C. The equal-rank rule attaches C beneath A and raises A's rank to two. D still points to C, so finding D now follows D, C, A. The set is {A,B,C,D}, even though not every member directly points to A.
Process F-H in the same way. G becomes a child of E, whose rank becomes two. H still points to G. Finally process A-E. Attach E beneath A and increase A's rank to three. All eight identifiers now share one set, after seven successful merges.
At this instant the parent mapping, in A-through-H order, is [A,A,A,C,A,E,E,G]. In particular, H reaches the root through H, G, E, A. A query on the same set does not need to establish those connections again.
Compression changes representation
Perform a full-compression find on H. After locating root A, redirect every nonroot identifier on that search path to A. H, G, and E then point directly to A. The parent array becomes [A,A,A,C,A,E,A,A].
The partition has not changed. Before and after the query, all eight identifiers are connected according to the accumulated relations. Only later parent traversals become shorter. F still points through E, and D still points through C, because neither was on the compressed H path.
If find is then applied to every identifier, all nonroots can point directly to A. The actual tree height becomes one, but A's stored rank remains three. Rank is maintained by the union rule as an upper bound used for balancing; compression does not require it to remain the current geometric height. Recomputing rank as the visible height would mix two different invariants.
A redundant union needs no merge
After these operations, union(D,H) finds the same root for both endpoints. It must leave the number of sets at one. Incrementing rank or decrementing the set count again would be incorrect. Its internal finds may still compress paths, so no new merge does not imply that no parent pointer changes.
The count starts at eight and falls only when two previously distinct sets combine. This supplies a simple independent check on a sequence of operations. Seven successful unions produce one set regardless of how many redundant relationship records are subsequently presented.
Parent paths are not network paths
The input relation B-D caused the algorithm to connect root C beneath root A. No A-C input edge was required. Likewise, compression created H-to-A internally without adding an H-A network edge. Following those parent links as if they described a traversable route would invent connections not supplied by the graph.
Retain the original edges separately if a later task needs a route, a path length, or evidence explaining connectivity. A disjoint-set representative can also change during later unions. Applications needing a stable component label must define and maintain that label separately rather than treating the current root as a permanent external identifier.
Deletion requires more information
In the seven-edge construction, removing the original A-E connection separates {A,B,C,D} from {E,F,G,H}. The ordinary union-find state cannot undo that merge. Adding B-F before the removal would instead preserve connectivity through another edge, yet both graphs would have the same one-set partition before deletion.
Thus the partition alone is insufficient to decide the effect of deleting an edge. Rebuild connectivity from retained edges, or choose an algorithm designed for the required update model. Rank balancing and compression accelerate repeated membership queries; they do not add route reconstruction or fully dynamic connectivity semantics to the structure.
Sources checked October 24, 2026:
https://www.cs.cornell.edu/courses/cs3110/2014sp/lectures/12/disjoint-set-forests.html
https://www.cs.princeton.edu/courses/archive/fall21/cos226/lectures/15UnionFind.pdf
Concept illustration: A small desktop robot beside a laptop showing a generic workflow provides robotics context for this analytical model. The image does not depict the article's numerical example, a verified experiment, a product specification, or deployment evidence.