pub struct WeightedGraph {
pub n: usize,
pub edges: Vec<Vec<(usize, f64)>>,
}Expand description
Weighted graph stored as adjacency list of (neighbor, weight) pairs.
Fields§
§n: usize§edges: Vec<Vec<(usize, f64)>>Implementations§
Source§impl WeightedGraph
impl WeightedGraph
pub fn new(n: usize) -> Self
pub fn add_edge(&mut self, u: usize, v: usize, w: f64) -> GraphalgResult<()>
pub fn add_undirected_edge( &mut self, u: usize, v: usize, w: f64, ) -> GraphalgResult<()>
pub fn num_edges(&self) -> usize
pub fn neighbors(&self, u: usize) -> GraphalgResult<&[(usize, f64)]>
Trait Implementations§
Source§impl Clone for WeightedGraph
impl Clone for WeightedGraph
Source§fn clone(&self) -> WeightedGraph
fn clone(&self) -> WeightedGraph
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 moreAuto Trait Implementations§
impl Freeze for WeightedGraph
impl RefUnwindSafe for WeightedGraph
impl Send for WeightedGraph
impl Sync for WeightedGraph
impl Unpin for WeightedGraph
impl UnsafeUnpin for WeightedGraph
impl UnwindSafe for WeightedGraph
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