pub struct DoulionTriangleCounter { /* private fields */ }Expand description
Approximate streaming triangle counter using edge sampling (Doulion algorithm).
The Doulion algorithm samples each edge with probability p and counts
triangles in the sampled subgraph. The triangle count is then scaled by 1/p^3
to estimate the total.
§Reference
Tsourakakis et al., “Doulion: Counting Triangles in Massive Graphs with a Coin”, KDD 2009.
Implementations§
Source§impl DoulionTriangleCounter
impl DoulionTriangleCounter
Sourcepub fn new(sample_prob: f64, seed: u64) -> Result<Self>
pub fn new(sample_prob: f64, seed: u64) -> Result<Self>
Create a new Doulion triangle counter with given sampling probability.
Lower sample_prob uses less memory but gives less accurate estimates.
A value of 0.1 is reasonable for graphs with millions of edges.
Sourcepub fn process_edge(&mut self, src: usize, dst: usize)
pub fn process_edge(&mut self, src: usize, dst: usize)
Process a new edge from the stream.
With probability p, the edge is sampled. If both endpoints are already
in the sample, we check for triangles formed.
Sourcepub fn estimated_triangles(&self) -> f64
pub fn estimated_triangles(&self) -> f64
Get the estimated total number of triangles.
Sourcepub fn sampled_triangles(&self) -> usize
pub fn sampled_triangles(&self) -> usize
Get the number of sampled triangles (unscaled).
Sourcepub fn stats(&self) -> TriangleCounterStats
pub fn stats(&self) -> TriangleCounterStats
Get statistics about the counter.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DoulionTriangleCounter
impl RefUnwindSafe for DoulionTriangleCounter
impl Send for DoulionTriangleCounter
impl Sync for DoulionTriangleCounter
impl Unpin for DoulionTriangleCounter
impl UnsafeUnpin for DoulionTriangleCounter
impl UnwindSafe for DoulionTriangleCounter
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