pub trait UnionFind<NI> {
// Required methods
fn union(&self, u: NI, v: NI);
fn find(&self, u: NI) -> NI;
fn len(&self) -> usize;
fn compress(&self);
}
Joins the set of id1
with the set of id2
.
Returns the number of elements in the union find,
also referred to as its ‘length’.
Compress the data if possible.
After that operation each index stores the final set id.