pub struct EulerTourTree { /* private fields */ }Expand description
Euler Tour Tree for maintaining dynamic connectivity
Supports O(log n) link, cut, and connectivity queries
Implementations§
Source§impl EulerTourTree
impl EulerTourTree
Sourcepub fn add_vertex(&mut self, v: u32)
pub fn add_vertex(&mut self, v: u32)
Add a vertex (if not already present)
Sourcepub fn link(&mut self, u: u32, v: u32) -> Result<(), DynamicMinCutError>
pub fn link(&mut self, u: u32, v: u32) -> Result<(), DynamicMinCutError>
Link two vertices with an edge
Time: O(log n) amortized via splay operations
Sourcepub fn cut(&mut self, u: u32, v: u32) -> Result<(), DynamicMinCutError>
pub fn cut(&mut self, u: u32, v: u32) -> Result<(), DynamicMinCutError>
Cut an edge between two vertices
Time: O(log n) amortized
Sourcepub fn connected(&self, u: u32, v: u32) -> bool
pub fn connected(&self, u: u32, v: u32) -> bool
Check if two vertices are connected
Time: O(log n) - find roots and compare
Sourcepub fn component_size(&self, v: u32) -> usize
pub fn component_size(&self, v: u32) -> usize
Get component size containing vertex v
Time: O(log n)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EulerTourTree
impl RefUnwindSafe for EulerTourTree
impl Send for EulerTourTree
impl Sync for EulerTourTree
impl Unpin for EulerTourTree
impl UnwindSafe for EulerTourTree
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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