pub struct StreamingUnionFind { /* private fields */ }Expand description
Online connected-components via path-compressed, union-by-rank Union-Find.
As edges arrive from the stream the structure is updated in O(α(n)) amortised time per edge (inverse Ackermann).
Implementations§
Source§impl StreamingUnionFind
impl StreamingUnionFind
Sourcepub fn find(&mut self, x: usize) -> usize
pub fn find(&mut self, x: usize) -> usize
Find the representative of x with full path compression (iterative).
Sourcepub fn process_edge(&mut self, u: usize, v: usize)
pub fn process_edge(&mut self, u: usize, v: usize)
Process edge (u, v) — union the two components.
Sourcepub fn n_components(&self) -> usize
pub fn n_components(&self) -> usize
Return the number of distinct connected components.
Sourcepub fn component_id(&mut self, x: usize) -> usize
pub fn component_id(&mut self, x: usize) -> usize
Return the canonical component identifier for x.
Trait Implementations§
Source§impl Debug for StreamingUnionFind
impl Debug for StreamingUnionFind
Source§impl Default for StreamingUnionFind
impl Default for StreamingUnionFind
Source§fn default() -> StreamingUnionFind
fn default() -> StreamingUnionFind
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for StreamingUnionFind
impl RefUnwindSafe for StreamingUnionFind
impl Send for StreamingUnionFind
impl Sync for StreamingUnionFind
impl Unpin for StreamingUnionFind
impl UnsafeUnpin for StreamingUnionFind
impl UnwindSafe for StreamingUnionFind
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more