pub struct ArcSwap {
pub max_imbalance: Option<f64>,
}
Expand description
Arc-swap
A multi-threaded variant of Fiduccia-Mattheyses, which moves vertices from one part to the other as long as the move reduces the cutset.
In contrast to the original algorithm, it is not greedy and thus does more, smaller moves. It also does not need to build up a gain table, which greatly speeds up the execution time.
Example
use coupe::Partition as _;
use coupe::Grid;
// swap
// 0 1 0 1
// +--+--+--+
// | | | |
// +--+--+--+
// 0 0 1 1
let width = std::num::NonZeroUsize::new(4).unwrap();
let height = std::num::NonZeroUsize::new(2).unwrap();
let grid = Grid::new_2d(width, height);
let weights = [1.0; 8];
let mut partition = [0, 0, 1, 1, 0, 1, 0, 1];
coupe::ArcSwap { max_imbalance: Some(0.25) }
.partition(&mut partition, (grid, &weights))?;
Fields§
§max_imbalance: Option<f64>
Restrict moves made by ArcSwap such that the imbalance of the output partition is smaller than this value.
- if
Some(value)
, ArcSwap reduces the edge cut as much as possible while keeping imbalance belowvalue
. - if
None
, ArcSwap does not increase the imbalance of the input partition (same behavior asSome(imbalance(input_partition))
).
Trait Implementations§
source§impl<'a, T, W> Partition<(T, &'a [W])> for ArcSwapwhere
W: AsWeight,
T: Topology<i64> + Sync,
impl<'a, T, W> Partition<(T, &'a [W])> for ArcSwapwhere W: AsWeight, T: Topology<i64> + Sync,
impl Copy for ArcSwap
Auto Trait Implementations§
impl RefUnwindSafe for ArcSwap
impl Send for ArcSwap
impl Sync for ArcSwap
impl Unpin for ArcSwap
impl UnwindSafe for ArcSwap
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§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 more§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).§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.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.