pub struct StreamingPartitioner { /* private fields */ }Expand description
A stateful online streaming partitioner.
Nodes arrive one at a time (with their adjacency list as observed so far).
Each call to assign_vertex makes an
irrevocable assignment based on already-assigned neighbors.
§Example
use scirs2_graph::partitioning::{StreamingPartitioner, StreamingPartitionConfig, StreamingPartitionAlgorithm};
let config = StreamingPartitionConfig { n_parts: 3, ..Default::default() };
let mut sp = StreamingPartitioner::new(10, config);
// Assign node 0 with no neighbors yet
let part = sp.assign_vertex(0, &[]);
assert!(part < 3);Implementations§
Source§impl StreamingPartitioner
impl StreamingPartitioner
Sourcepub fn new(n_nodes: usize, config: StreamingPartitionConfig) -> Self
pub fn new(n_nodes: usize, config: StreamingPartitionConfig) -> Self
Create a new streaming partitioner for n_nodes nodes.
Sourcepub fn assign_vertex(&mut self, v: usize, neighbors: &[(usize, f64)]) -> usize
pub fn assign_vertex(&mut self, v: usize, neighbors: &[(usize, f64)]) -> usize
Assign vertex v to a partition given its (already-known) neighbors.
Only neighbors whose partition is already determined influence the score. Returns the assigned partition ID.
Sourcepub fn current_partition(&self) -> &[Option<usize>]
pub fn current_partition(&self) -> &[Option<usize>]
Return the current partition assignments (None = not yet assigned).
Auto Trait Implementations§
impl Freeze for StreamingPartitioner
impl RefUnwindSafe for StreamingPartitioner
impl Send for StreamingPartitioner
impl Sync for StreamingPartitioner
impl Unpin for StreamingPartitioner
impl UnsafeUnpin for StreamingPartitioner
impl UnwindSafe for StreamingPartitioner
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