Skip to main content

UnionFind

Trait UnionFind 

Source
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);
}

Required Methods§

Source

fn union(&self, u: NI, v: NI)

Joins the set of id1 with the set of id2.

Source

fn find(&self, u: NI) -> NI

Find the set of id.

Source

fn len(&self) -> usize

Returns the number of elements in the union find, also referred to as its ‘length’.

Source

fn compress(&self)

Compress the data if possible. After that operation each index stores the final set id.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<NI: Idx> UnionFind<NI> for Afforest<NI>

Source§

impl<NI: Idx> UnionFind<NI> for DisjointSetStruct<NI>