Trait DirectedWeightedGraph

Source
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§

Source

type AllWeightedEdges: Iterator<Item = (&'g N, &'g N, &'g W)>

An iterator that iterates over all edges.

Source

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§

Source

fn all_edges(&'g self) -> Self::AllWeightedEdges

Returns an iterator over all the edges in this graph.

Source

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.

Source

fn add_edge(&'g mut self, _: N, _: N, _: W) -> Option<(N, N, W)>

Adds an edge to this graph.

Source

fn remove_edge(&'g mut self, _: &N, _: &N) -> Option<(N, N, W)>

Removes an edge from the graph.

Provided Methods§

Source

fn has_edge(&'g self, source: &N, sink: &N) -> bool

Checks if a graph has an edge or not.

§Complexity

The default implementation runs in O(|E|) time.

Source

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|).

Source

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.

Implementations on Foreign Types§

Source§

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)>

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.

Source§

type AllWeightedEdges = AllWeightedEdges<'g, N, W>

Source§

type AllWeightedEdgesMut = AllWeightedEdgesMut<'g, N, W>

Source§

fn all_edges(&'g self) -> Self::AllWeightedEdges

Source§

fn all_edges_mut(&'g mut self) -> Self::AllWeightedEdgesMut

Source§

fn remove_edge(&'g mut self, source: &N, sink: &N) -> Option<(N, N, W)>

Implementors§

Source§

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,

Source§

type AllWeightedEdges = Map<<M as Map<'m, (N, N), W>>::Iter, fn((&'m (N, N), &'m W)) -> (&'m N, &'m N, &'m W)>

Source§

type AllWeightedEdgesMut = Map<<M as Map<'m, (N, N), W>>::IterMut, fn((&'m (N, N), &'m mut W)) -> (&'m N, &'m N, &'m mut W)>