pub struct WeightedGraph<T, W> { /* private fields */ }Expand description
Weighted graph representation
Implementations§
Source§impl<T: Clone + Eq + Hash, W: Clone + PartialOrd> WeightedGraph<T, W>
impl<T: Clone + Eq + Hash, W: Clone + PartialOrd> WeightedGraph<T, W>
Sourcepub fn add_vertex(&mut self, vertex: T) -> usize
pub fn add_vertex(&mut self, vertex: T) -> usize
Add a vertex to the graph
Sourcepub fn add_edge(&mut self, from: &T, to: &T, weight: W) -> UtilsResult<()>
pub fn add_edge(&mut self, from: &T, to: &T, weight: W) -> UtilsResult<()>
Add a weighted edge between two vertices
Sourcepub fn minimum_spanning_tree(&self) -> UtilsResult<Vec<(usize, usize, W)>>
pub fn minimum_spanning_tree(&self) -> UtilsResult<Vec<(usize, usize, W)>>
Get the minimum spanning tree using Kruskal’s algorithm
Trait Implementations§
Source§impl<T: Clone, W: Clone> Clone for WeightedGraph<T, W>
impl<T: Clone, W: Clone> Clone for WeightedGraph<T, W>
Source§fn clone(&self) -> WeightedGraph<T, W>
fn clone(&self) -> WeightedGraph<T, W>
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 moreAuto Trait Implementations§
impl<T, W> Freeze for WeightedGraph<T, W>
impl<T, W> RefUnwindSafe for WeightedGraph<T, W>where
T: RefUnwindSafe,
W: RefUnwindSafe,
impl<T, W> Send for WeightedGraph<T, W>
impl<T, W> Sync for WeightedGraph<T, W>
impl<T, W> Unpin for WeightedGraph<T, W>
impl<T, W> UnwindSafe for WeightedGraph<T, W>where
T: UnwindSafe,
W: 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more