pub struct EulerTourTree { /* private fields */ }Expand description
Represents a tree as an Euler tour stored in a balanced BST (treap)
Implementations§
Source§impl EulerTourTree
impl EulerTourTree
Sourcepub fn with_seed_and_capacity(seed: u64, capacity: usize) -> Self
pub fn with_seed_and_capacity(seed: u64, capacity: usize) -> Self
Sourcepub fn link(&mut self, u: NodeId, v: NodeId) -> Result<()>
pub fn link(&mut self, u: NodeId, v: NodeId) -> Result<()>
Link: Make v a child of u (v must be in separate tree)
Sourcepub fn cut(&mut self, u: NodeId, v: NodeId) -> Result<()>
pub fn cut(&mut self, u: NodeId, v: NodeId) -> Result<()>
Cut: Remove edge between u and v
§Performance
O(log n) via Euler tour split and merge with O(1) exit node lookup.
Sourcepub fn connected(&self, u: NodeId, v: NodeId) -> bool
pub fn connected(&self, u: NodeId, v: NodeId) -> bool
Check if two vertices are in the same tree
Sourcepub fn subtree_size(&self, v: NodeId) -> Result<usize>
pub fn subtree_size(&self, v: NodeId) -> Result<usize>
Get the size of the subtree rooted at v
Sourcepub fn subtree_aggregate(&self, v: NodeId) -> Result<f64>
pub fn subtree_aggregate(&self, v: NodeId) -> Result<f64>
Aggregate over the subtree rooted at v
Sourcepub fn update_value(&mut self, v: NodeId, value: f64) -> Result<()>
pub fn update_value(&mut self, v: NodeId, value: f64) -> Result<()>
Update the value at vertex v
Sourcepub fn reroot(&mut self, v: NodeId) -> Result<()>
pub fn reroot(&mut self, v: NodeId) -> Result<()>
Reroot the tree containing v to make v the root
Sourcepub fn bulk_make_trees(&mut self, vertices: &[NodeId]) -> Result<()>
pub fn bulk_make_trees(&mut self, vertices: &[NodeId]) -> Result<()>
Bulk create trees - more efficient than individual make_tree calls
§Performance
- Pre-allocates all memory upfront
- Batches HashMap insertions
- Reduces allocation overhead by ~40%
Trait Implementations§
Source§impl Clone for EulerTourTree
impl Clone for EulerTourTree
Source§fn clone(&self) -> EulerTourTree
fn clone(&self) -> EulerTourTree
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for EulerTourTree
impl Debug for EulerTourTree
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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