pub struct StreamingDegreeEstimator { /* private fields */ }Expand description
Streaming degree estimator backed by a count-min sketch.
Each call to process_edge increments the sketch cell for both endpoints.
The sketch uses d independent hash functions, each with width w determined
by n_sketch_bits (w = min(2^n_sketch_bits, 2^16) to keep memory bounded).
Degree queries return the minimum over all d rows.
§Space
O(d × w) counters where d = 4 and w = 2^min(n_sketch_bits, 16).
Implementations§
Source§impl StreamingDegreeEstimator
impl StreamingDegreeEstimator
Sourcepub fn new(config: StreamConfig) -> Self
pub fn new(config: StreamConfig) -> Self
Create a new estimator with the given configuration.
Sourcepub fn process_edge(&mut self, u: usize, v: usize)
pub fn process_edge(&mut self, u: usize, v: usize)
Process a single edge (u, v) — increments degree counters for both endpoints.
Sourcepub fn estimate_degree(&self, vertex: usize) -> u32
pub fn estimate_degree(&self, vertex: usize) -> u32
Estimate the degree of vertex — returns the minimum counter across rows.
Sourcepub fn approximate_degree_distribution(&self, n_vertices: usize) -> Vec<u32>
pub fn approximate_degree_distribution(&self, n_vertices: usize) -> Vec<u32>
Return estimated degrees for each vertex id in 0..n_vertices.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for StreamingDegreeEstimator
impl RefUnwindSafe for StreamingDegreeEstimator
impl Send for StreamingDegreeEstimator
impl Sync for StreamingDegreeEstimator
impl Unpin for StreamingDegreeEstimator
impl UnsafeUnpin for StreamingDegreeEstimator
impl UnwindSafe for StreamingDegreeEstimator
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