Struct pulau_rs::UnionFind

source ·
pub struct UnionFind<'a, A, T, const N: usize>where
    T: VertexType + 'a,
    A: AlgorithmContainer,
{ /* private fields */ }
Expand description

UnionFind data structure

This data structure stores a collection of disjoint (non-overlapping) sets.

UnionFind is parameterized by the following

Example

use pulau_rs::{UnionFind, QuickFind, QuickUnion};
fn make_uf_quickfind() {
    // construct with quickfind algorithm with fixed size 10
    let mut uf = UnionFind::<QuickFind, u32, 10>::default();
}

fn make_uf_quickunion() {
    // construct with weighted quickunion with path compression algorithm with fixed size 10
    let mut uf = UnionFind::<QuickUnion, u32, 10>::default();
}

Size Guarantees

Size of UnionFind depends on whether the algorithm you have chosen is weighted

Assuming no padding, If it’s weighted then, size of UnionFind is T * N + size_of(usize) * N

Else it will be T * N

If you are using borrowed buffers, then the size will be the core::mem::size_of::<usize>() * 2 if it’s weighted, else it will just be core::mem::size_of::<usize>()

Implementations§

Checks whether 2 nodes are connected to each other

Finds a node

Unions 2 node. If those 2 nodes are already part of the same component then this does nothing

Gets the representative slice

Gets the heuristic slice

Trait Implementations§

Returns the “default value” for a type. Read more
Returns the “default value” for a type. Read more
Returns the “default value” for a type. Read more
Returns the “default value” for a type. Read more
Returns the “default value” for a type. Read more
Returns the “default value” for a type. Read more
Returns the “default value” for a type. Read more
Returns the “default value” for a type. Read more
Returns the “default value” for a type. Read more
Returns the “default value” for a type. Read more
Returns the “default value” for a type. Read more
Returns the “default value” for a type. Read more
Returns the “default value” for a type. Read more
Returns the “default value” for a type. Read more
Returns the “default value” for a type. Read more
Returns the “default value” for a type. Read more
Returns the “default value” for a type. Read more
Returns the “default value” for a type. Read more
Returns the “default value” for a type. Read more
Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.