pub struct Fragmentation { /* private fields */ }Expand description
The Fragmentation algorithm data structure
Implementations§
Source§impl Fragmentation
impl Fragmentation
Sourcepub fn new(config: FragmentationConfig) -> Self
pub fn new(config: FragmentationConfig) -> Self
Create new fragmentation structure
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create with default config
Sourcepub fn insert_edge(&mut self, u: VertexId, v: VertexId, weight: Weight)
pub fn insert_edge(&mut self, u: VertexId, v: VertexId, weight: Weight)
Insert an edge into the graph
Sourcepub fn delete_edge(&mut self, u: VertexId, v: VertexId)
pub fn delete_edge(&mut self, u: VertexId, v: VertexId)
Delete an edge from the graph
Sourcepub fn fragment(&mut self) -> Vec<u64>
pub fn fragment(&mut self) -> Vec<u64>
Run the fragmentation algorithm to decompose the graph
This implements the recursive decomposition from the paper.
Sourcepub fn trim(&self, vertices: &[VertexId]) -> TrimResult
pub fn trim(&self, vertices: &[VertexId]) -> TrimResult
Trim subroutine: Find a boundary-sparse cut
Algorithm (per Theorem 5.1):
- Start with high-degree vertices
- Greedily expand the set
- Stop when boundary becomes sparse relative to volume
Sourcepub fn is_expander(&self, fragment_id: u64) -> bool
pub fn is_expander(&self, fragment_id: u64) -> bool
Check if a fragment is a φ-expander
A graph is a φ-expander if every cut (S, S̄) has: |∂S| ≥ φ · min(vol(S), vol(S̄))
Sourcepub fn get_fragment(&self, id: u64) -> Option<&Fragment>
pub fn get_fragment(&self, id: u64) -> Option<&Fragment>
Get a fragment by ID
Sourcepub fn get_vertex_fragment(&self, v: VertexId) -> Option<&Fragment>
pub fn get_vertex_fragment(&self, v: VertexId) -> Option<&Fragment>
Get fragment containing a vertex
Sourcepub fn leaf_fragments(&self) -> Vec<&Fragment>
pub fn leaf_fragments(&self) -> Vec<&Fragment>
Get all leaf fragments (no children)
Sourcepub fn num_fragments(&self) -> usize
pub fn num_fragments(&self) -> usize
Get total number of fragments
Trait Implementations§
Source§impl Debug for Fragmentation
impl Debug for Fragmentation
Auto Trait Implementations§
impl Freeze for Fragmentation
impl RefUnwindSafe for Fragmentation
impl Send for Fragmentation
impl Sync for Fragmentation
impl Unpin for Fragmentation
impl UnwindSafe for Fragmentation
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