pub trait DirectedWeightedGraph<'g, N, W>where
N: 'g + Eq,
W: 'g,{
type AllWeightedEdges: Iterator<Item = (&'g N, &'g N, &'g W)>;
type AllWeightedEdgesMut: Iterator<Item = (&'g N, &'g N, &'g mut W)>;
// Required methods
fn all_edges(&'g self) -> Self::AllWeightedEdges;
fn all_edges_mut(&'g mut self) -> Self::AllWeightedEdgesMut;
fn add_edge(&'g mut self, _: N, _: N, _: W) -> Option<(N, N, W)>;
fn remove_edge(&'g mut self, _: &N, _: &N) -> Option<(N, N, W)>;
// Provided methods
fn has_edge(&'g self, source: &N, sink: &N) -> bool { ... }
fn edge_weight(&'g self, source: &N, sink: &N) -> Option<&W> { ... }
fn edge_weight_mut(&'g mut self, source: &N, sink: &N) -> Option<&mut W> { ... }
}Expand description
A directed graph with edge weights. The efficiency of the different operations is highly dependent on the backend used.
Required Associated Types§
Required Methods§
Sourcefn all_edges(&'g self) -> Self::AllWeightedEdges
fn all_edges(&'g self) -> Self::AllWeightedEdges
Returns an iterator over all the edges in this graph.
Sourcefn all_edges_mut(&'g mut self) -> Self::AllWeightedEdgesMut
fn all_edges_mut(&'g mut self) -> Self::AllWeightedEdgesMut
Returns an iterator over all the ediges in this graph, with mutable access to the weight.
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl<'g, N, W> DirectedWeightedGraph<'g, N, W> for Vec<(N, N, W)>where
N: Eq + 'g,
W: 'g,
impl<'g, N, W> DirectedWeightedGraph<'g, N, W> for Vec<(N, N, W)>where
N: Eq + 'g,
W: 'g,
Source§fn add_edge(&'g mut self, source: N, sink: N, weight: W) -> Option<(N, N, W)>
fn add_edge(&'g mut self, source: N, sink: N, weight: W) -> Option<(N, N, W)>
Adds an edge to the graph.
§Complexity
This implementation runs in O(|E|) time. Running in linear time would risk this graph of becoming a multigraph, where there can be multiple edges between the same nodes.