pub struct PathMatrix<T> { /* private fields */ }Expand description
This matrix is a solution to the APSP problem, calculated by the Floyd-Warshall algorithm. It contains the intermediate nodes on the shortest path between every two nodes.
Implementations§
Source§impl<T> PathMatrix<T>
impl<T> PathMatrix<T>
Sourcepub fn new(n: usize) -> PathMatrix<T>
pub fn new(n: usize) -> PathMatrix<T>
Creates a new PathMatrix with the given dimension (n * n), where no paths were found yet.
That means, no nodes are yet connected in this matrix.
Sourcepub fn get_path_len(&self, i: usize, j: usize) -> usize
pub fn get_path_len(&self, i: usize, j: usize) -> usize
This method returns the value at the given position.
Sourcepub fn get_path(&self, i: usize, j: usize) -> &Path<T>
pub fn get_path(&self, i: usize, j: usize) -> &Path<T>
This method returns the shortest path possible between i and i.
Sourcepub fn get_path_iter<'a>(
&'a self,
i: usize,
j: usize,
) -> impl DoubleEndedIterator<Item = &'a T>
pub fn get_path_iter<'a>( &'a self, i: usize, j: usize, ) -> impl DoubleEndedIterator<Item = &'a T>
This method returns the shortest path possible between i and i as an iterator.
Sourcepub fn does_path_exist(&self, i: usize, j: usize) -> bool
pub fn does_path_exist(&self, i: usize, j: usize) -> bool
If the matrix contains a path between i and j (which means, it has a set length), this returns true.
Sourcepub fn set_path_len(&mut self, i: usize, j: usize, v: usize)
pub fn set_path_len(&mut self, i: usize, j: usize, v: usize)
This method updates the value at the given position.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for PathMatrix<T>
impl<T> RefUnwindSafe for PathMatrix<T>where
T: RefUnwindSafe,
impl<T> Send for PathMatrix<T>where
T: Send,
impl<T> Sync for PathMatrix<T>where
T: Sync,
impl<T> Unpin for PathMatrix<T>
impl<T> UnwindSafe for PathMatrix<T>where
T: 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