pub struct GraphGrowth {
pub part_count: usize,
}Expand description
Graph Growth algorithm
A topologic algorithm that generates a partition from a topologic mesh. Given a number k of parts, the algorithm selects k nodes randomly and assigns them to a different part. Then, at each iteration, each part is expanded to neighbor nodes that are not yet assigned to a part
§Example
use coupe::Partition as _;
use coupe::Point2D;
use sprs::CsMat;
// +--+--+--+
// | | | |
// +--+--+--+
let weights = [1.0; 8];
let mut partition = [0; 8];
let mut adjacency = CsMat::empty(sprs::CSR, 8);
adjacency.reserve_outer_dim(8);
eprintln!("shape: {:?}", adjacency.shape());
adjacency.insert(0, 1, 1.);
adjacency.insert(1, 2, 1.);
adjacency.insert(2, 3, 1.);
adjacency.insert(4, 5, 1.);
adjacency.insert(5, 6, 1.);
adjacency.insert(6, 7, 1.);
adjacency.insert(0, 4, 1.);
adjacency.insert(1, 5, 1.);
adjacency.insert(2, 6, 1.);
adjacency.insert(3, 7, 1.);
// symmetry
adjacency.insert(1, 0, 1.);
adjacency.insert(2, 1, 1.);
adjacency.insert(3, 2, 1.);
adjacency.insert(5, 4, 1.);
adjacency.insert(6, 5, 1.);
adjacency.insert(7, 6, 1.);
adjacency.insert(4, 0, 1.);
adjacency.insert(5, 1, 1.);
adjacency.insert(6, 2, 1.);
adjacency.insert(7, 3, 1.);
coupe::GraphGrowth { part_count: 2 }
.partition(&mut partition, (adjacency.view(), &weights))
.unwrap();Fields§
§part_count: usizeTrait Implementations§
Source§impl Clone for GraphGrowth
impl Clone for GraphGrowth
Source§fn clone(&self) -> GraphGrowth
fn clone(&self) -> GraphGrowth
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for GraphGrowth
impl Debug for GraphGrowth
Source§impl<'a, W> Partition<(CsMatBase<f64, usize, &'a [usize], &'a [usize], &'a [f64]>, W)> for GraphGrowth
impl<'a, W> Partition<(CsMatBase<f64, usize, &'a [usize], &'a [usize], &'a [f64]>, W)> for GraphGrowth
Source§type Error = Infallible
type Error = Infallible
Error details, should the algorithm fail to run.
impl Copy for GraphGrowth
Auto Trait Implementations§
impl Freeze for GraphGrowth
impl RefUnwindSafe for GraphGrowth
impl Send for GraphGrowth
impl Sync for GraphGrowth
impl Unpin for GraphGrowth
impl UnwindSafe for GraphGrowth
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.