Struct ReversibleColoring

Source
pub struct ReversibleColoring<S: Set + ?Sized> { /* private fields */ }
Expand description

A reversible ordered coloring.

Implementations§

Source§

impl<S: Set + ?Sized> ReversibleColoring<S>

Source

pub fn new(set: &S) -> Self

Creates a new reversible coloring.

Source

pub fn from_coloring(set: &S, coloring: Coloring<S>) -> Self

Source

pub fn color_index_of(&self, item: &S::Item) -> Option<usize>

Source

pub fn as_permutation(&self) -> Option<&S::Map<usize>>

Returns the permutation represented by this coloring, if any.

If the coloring discrete then it defines a mapping p : x -> self.reverse(x) that is a permutation of the partitioned set. In that case, Some(p) is returned. Otherwise, if the coloring is not discrete, None is returned.

Source

pub fn individualize(&mut self, item: &S::Item) -> bool

Refine the coloring such that item is in its own cell of size 1.

Returns true if the individualization succeeded, or false if item was already individualized.

Source

pub fn deindividualize(&mut self, item: &S::Item) -> bool

Source

pub fn is_finer_or_equal_to(&self, other: &Self) -> bool

Checks if self is a finer than or equal to other, assuming they target the same set.

Source

pub fn refine<F, C: Ord>(&mut self, f: F) -> bool
where F: Fn(&S::Item) -> C,

Source

pub fn refine_with<F, C: Ord>( &mut self, refined_colors: &mut Vec<usize>, f: F, ) -> bool
where F: Fn(&S::Item) -> C,

Refine this coloring using the given sub-coloring.

The refined_colors array will be expended to include the newly added colors indexes. Colors that have not been refined are not added to the array, even if their index changes. If the array already contains old color indexes, they will be updated in place to the new color index.

Source

pub fn make_equitable<'i, F, I>(&mut self, set: &S, neighbors: F)
where F: Fn(&S::Item) -> I, I: IntoIterator<Item = &'i S::Item>, S::Item: 'i,

Source

pub fn make_equitable_with<'i, F, I>( &mut self, stack: &mut Vec<usize>, map: &mut S::Map<usize>, neighbors: F, )
where F: Fn(&S::Item) -> I, I: IntoIterator<Item = &'i S::Item>, S::Item: 'i,

Make this coloring equitable.

The stack is empty when this function returns. The map must be initialized so that each element is mapped (the value does not matter).

Methods from Deref<Target = Coloring<S>>§

Source

pub fn color_index_of(&self, item: &S::Item) -> Option<usize>

Source

pub fn colors(&self) -> Colors<'_, S>

Source

pub fn len(&self) -> usize

Returns the number of colors in the coloring.

Source

pub fn is_empty(&self) -> bool

Source

pub fn is_unit(&self) -> bool

Checks if the coloring is a unit coloring.

Source

pub fn is_discrete(&self) -> bool

Source

pub fn color_start(&self, i: usize) -> Option<usize>

Source

pub fn get(&self, i: usize) -> Option<&[S::Item]>

Returns the ith cell of the coloring, partitioning the given input set.

Trait Implementations§

Source§

impl<S: Set + ?Sized> Clone for ReversibleColoring<S>
where S::Map<usize>: Clone,

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<S: Set + ?Sized> Debug for ReversibleColoring<S>
where S::Item: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<S: Set + ?Sized> Deref for ReversibleColoring<S>

Source§

type Target = Coloring<S>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<S: Set + ?Sized> PartialEq for ReversibleColoring<S>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

const fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<S: Set + ?Sized> Eq for ReversibleColoring<S>

Auto Trait Implementations§

§

impl<S> Freeze for ReversibleColoring<S>
where <S as Set>::Map<usize>: Freeze, S: ?Sized,

§

impl<S> RefUnwindSafe for ReversibleColoring<S>
where <S as Set>::Map<usize>: RefUnwindSafe, <S as Set>::Item: RefUnwindSafe, S: ?Sized,

§

impl<S> Send for ReversibleColoring<S>
where <S as Set>::Map<usize>: Send, <S as Set>::Item: Send, S: ?Sized,

§

impl<S> Sync for ReversibleColoring<S>
where <S as Set>::Map<usize>: Sync, <S as Set>::Item: Sync, S: ?Sized,

§

impl<S> Unpin for ReversibleColoring<S>
where <S as Set>::Map<usize>: Unpin, <S as Set>::Item: Unpin, S: ?Sized,

§

impl<S> UnwindSafe for ReversibleColoring<S>
where <S as Set>::Map<usize>: UnwindSafe, <S as Set>::Item: UnwindSafe, S: ?Sized,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.