pub struct StreamingTriangleCounter { /* private fields */ }Expand description
Streaming triangle counter using a sliding adjacency window.
For each new edge (u, v) the algorithm counts common neighbours already
present in the current window, giving an exact count for edges within the
window and an approximate count when the stream overflows it.
For small graphs (total edges ≤ window_size) this is an exact counter.
§References
Buriol et al., “Counting Triangles in Data Streams”, PODS 2006.
Implementations§
Source§impl StreamingTriangleCounter
impl StreamingTriangleCounter
Sourcepub fn new(config: StreamConfig) -> Self
pub fn new(config: StreamConfig) -> Self
Create a new counter 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 from the stream.
New triangles formed by (u, v) together with any common neighbour w
already present in the adjacency sketch are counted. When the reservoir
is full the oldest edge is evicted and removed from the sketch.
Sourcepub fn estimate_triangles(&self) -> f64
pub fn estimate_triangles(&self) -> f64
Return the current triangle estimate.
Sourcepub fn process_stream(&mut self, stream: &mut GraphStream) -> f64
pub fn process_stream(&mut self, stream: &mut GraphStream) -> f64
Drive the counter over an entire GraphStream, returning the final estimate.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for StreamingTriangleCounter
impl RefUnwindSafe for StreamingTriangleCounter
impl Send for StreamingTriangleCounter
impl Sync for StreamingTriangleCounter
impl Unpin for StreamingTriangleCounter
impl UnsafeUnpin for StreamingTriangleCounter
impl UnwindSafe for StreamingTriangleCounter
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
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>
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>
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