pub struct CostMatrix<C> { /* private fields */ }Expand description
Dense row-major costs between source and target items.
Implementations§
Source§impl<C> CostMatrix<C>
impl<C> CostMatrix<C>
Sourcepub fn new(
rows: usize,
columns: usize,
values: Vec<C>,
) -> Result<Self, GraphError>
pub fn new( rows: usize, columns: usize, values: Vec<C>, ) -> Result<Self, GraphError>
Builds a rows by columns matrix from row-major values.
Sourcepub fn from_optional(
rows: usize,
columns: usize,
values: Vec<Option<C>>,
) -> Result<Self, GraphError>
pub fn from_optional( rows: usize, columns: usize, values: Vec<Option<C>>, ) -> Result<Self, GraphError>
Builds a matrix whose None entries are forbidden assignment edges.
Sourcepub fn get(&self, source: usize, target: usize) -> Option<&C>
pub fn get(&self, source: usize, target: usize) -> Option<&C>
Returns the allowed cost at (source, target).
Returns None for both forbidden and out-of-range edges. Use
CostMatrix::is_forbidden when that distinction matters.
Sourcepub fn forbid(
&mut self,
source: usize,
target: usize,
) -> Result<Option<C>, GraphError>
pub fn forbid( &mut self, source: usize, target: usize, ) -> Result<Option<C>, GraphError>
Marks an in-range edge forbidden and returns its previous cost.
Sourcepub fn allow(
&mut self,
source: usize,
target: usize,
cost: C,
) -> Result<(), GraphError>
pub fn allow( &mut self, source: usize, target: usize, cost: C, ) -> Result<(), GraphError>
Sets or restores an in-range edge cost.
Sourcepub fn is_forbidden(
&self,
source: usize,
target: usize,
) -> Result<bool, GraphError>
pub fn is_forbidden( &self, source: usize, target: usize, ) -> Result<bool, GraphError>
Whether an in-range edge is explicitly forbidden.
Trait Implementations§
Source§impl<C: Clone> Clone for CostMatrix<C>
impl<C: Clone> Clone for CostMatrix<C>
Source§fn clone(&self) -> CostMatrix<C>
fn clone(&self) -> CostMatrix<C>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<C: Debug> Debug for CostMatrix<C>
impl<C: Debug> Debug for CostMatrix<C>
impl<C: Eq> Eq for CostMatrix<C>
Source§impl<C: PartialEq> PartialEq for CostMatrix<C>
impl<C: PartialEq> PartialEq for CostMatrix<C>
impl<C: PartialEq> StructuralPartialEq for CostMatrix<C>
Auto Trait Implementations§
impl<C> Freeze for CostMatrix<C>
impl<C> RefUnwindSafe for CostMatrix<C>where
C: RefUnwindSafe,
impl<C> Send for CostMatrix<C>where
C: Send,
impl<C> Sync for CostMatrix<C>where
C: Sync,
impl<C> Unpin for CostMatrix<C>where
C: Unpin,
impl<C> UnsafeUnpin for CostMatrix<C>
impl<C> UnwindSafe for CostMatrix<C>where
C: UnwindSafe,
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