EulerTourTree

Struct EulerTourTree 

Source
pub struct EulerTourTree { /* private fields */ }
Expand description

Represents a tree as an Euler tour stored in a balanced BST (treap)

Implementations§

Source§

impl EulerTourTree

Source

pub fn new() -> Self

Create a new empty Euler Tour Tree

Source

pub fn with_seed(seed: u64) -> Self

Create with a seed for reproducibility

§Performance

Pre-allocates with reasonable default capacity

Source

pub fn with_seed_and_capacity(seed: u64, capacity: usize) -> Self

Create with seed and capacity hint

§Performance

Pre-allocates memory to avoid reallocation

Source

pub fn make_tree(&mut self, v: NodeId) -> Result<()>

Create a singleton tree with one vertex

Link: Make v a child of u (v must be in separate tree)

Source

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.

Source

pub fn connected(&self, u: NodeId, v: NodeId) -> bool

Check if two vertices are in the same tree

Source

pub fn find_root(&self, v: NodeId) -> Result<NodeId>

Find the root of the tree containing v

Source

pub fn tree_size(&self, v: NodeId) -> Result<usize>

Get the size of the tree containing v

Source

pub fn subtree_size(&self, v: NodeId) -> Result<usize>

Get the size of the subtree rooted at v

Source

pub fn subtree_aggregate(&self, v: NodeId) -> Result<f64>

Aggregate over the subtree rooted at v

Source

pub fn update_value(&mut self, v: NodeId, value: f64) -> Result<()>

Update the value at vertex v

Source

pub fn reroot(&mut self, v: NodeId) -> Result<()>

Reroot the tree containing v to make v the root

Source

pub fn len(&self) -> usize

Get the number of vertices

Source

pub fn is_empty(&self) -> bool

Check if empty

Source

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%
Source

pub fn bulk_update_values(&mut self, updates: &[(NodeId, f64)]) -> Result<()>

Bulk update values with lazy propagation

§Performance
  • Uses lazy propagation to defer actual updates
  • Batches pull_up operations
  • ~3x faster than individual updates for large batches

Bulk link operations

§Performance
  • Validates all edges first to fail fast
  • Batches root mapping updates

Trait Implementations§

Source§

impl Clone for EulerTourTree

Source§

fn clone(&self) -> EulerTourTree

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EulerTourTree

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for EulerTourTree

Source§

fn default() -> Self

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

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V