Trait graph_rs::DirectedWeightedGraph
[−]
[src]
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)>; 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)>; 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> { ... } }
A directed graph with edge weights. The efficiency of the different operations is highly dependent on the backend used.
Associated Types
type AllWeightedEdges: Iterator<Item = (&'g N, &'g N, &'g W)>
An iterator that iterates over all edges.
type AllWeightedEdgesMut: Iterator<Item = (&'g N, &'g N, &'g mut W)>
An iterator that iterates over all edges, giving mutable access to the weight.
Required Methods
fn all_edges(&'g self) -> Self::AllWeightedEdges
Returns an iterator over all the edges in this graph.
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.
fn add_edge(&'g mut self, _: N, _: N, _: W) -> Option<(N, N, W)>
Adds an edge to this graph.
fn remove_edge(&'g mut self, _: &N, _: &N) -> Option<(N, N, W)>
Removes an edge from the graph.
Provided Methods
fn has_edge(&'g self, source: &N, sink: &N) -> bool
fn edge_weight(&'g self, source: &N, sink: &N) -> Option<&W>
Gets a borrow to the weight of the requested edge, if it exist.
Complexity
The default implementation runs in O(|E|).
fn edge_weight_mut(&'g mut self, source: &N, sink: &N) -> Option<&mut W>
Gets a mutable borrow to the weight of the requested edge, if it exist.
Complexity
The default implementation runs in O(|E|) time.
Implementors
impl<'g, N, W> DirectedWeightedGraph<'g, N, W> for Vec<(N, N, W)> where
N: Eq + 'g,
W: 'g, type AllWeightedEdges = AllWeightedEdges<'g, N, W>; type AllWeightedEdgesMut = AllWeightedEdgesMut<'g, N, W>;impl<'m, N, W, M> DirectedWeightedGraph<'m, N, W> for MapGraph<M> where
M: Map<'m, (N, N), W>,
N: 'm + Eq + Clone,
W: 'm, type AllWeightedEdges = Map<M::Iter, fn(_: (&'m (N, N), &'m W)) -> (&'m N, &'m N, &'m W)>; type AllWeightedEdgesMut = Map<M::IterMut, fn(_: (&'m (N, N), &'m mut W)) -> (&'m N, &'m N, &'m mut W)>;