pub struct WeightedGraph { /* private fields */ }Expand description
Undirected weighted graph with self-loop weights.
adj holds each edge in both directions and never contains
self entries; self-loop weight (internal edges after aggregation) lives
separately in loops.
Implementations§
Source§impl WeightedGraph
impl WeightedGraph
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Number of nodes.
Sourcepub fn from_edges(
n: usize,
edges: impl IntoIterator<Item = (usize, usize, f64)>,
) -> Self
pub fn from_edges( n: usize, edges: impl IntoIterator<Item = (usize, usize, f64)>, ) -> Self
Builds a graph from (u, v, weight) undirected edges, aggregating
parallel edges. Edges with non-finite or non-positive weight and edges
referencing unknown nodes are ignored. A self edge contributes to the
node’s self-loop weight.
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