Trait VariableEdges

Source
pub trait VariableEdges<T, E, K, V, W, C>: DirectedGraph<T, E, K, V, W, C>
where K: Hash + Eq + Clone, C: Hash + Eq + Clone, W: Add + Sub + Eq + Ord + Copy, T: Vertex<K, V>, E: Edge<K, W, C>,
{ // Required methods fn add_edge(&mut self, edge: E) -> Result<Option<E>, EdgeSide>; fn remove_edge(&mut self, pair: (&K, &K)) -> Option<E>; }
Expand description

This trait adds to a Directed graph the methods to add and remove edges

Required Methods§

Source

fn add_edge(&mut self, edge: E) -> Result<Option<E>, EdgeSide>

If an edge with an equal key is already present, the edge is updated (not the key) and the old edge is returned ad Ok(Some(old_edge)). If not present OK(None) is returned.

If one or both of the concerned vertexes are missing an error will be returned containing an enum specifying which side is missing

Source

fn remove_edge(&mut self, pair: (&K, &K)) -> Option<E>

If the removed edge was present it’s removed and returned as Some(edge). Otherwise None is returned

Implementors§

Source§

impl<K: Hash + Eq + Clone, V, W: Add + Sub + Eq + Ord + Copy> VariableEdges<SimpleVertex<K, V>, DirectedEdge<K, W>, K, V, W, CompoundKey<K>> for AdjacencyGraph<K, V, W>

AdjacencyGraph uses HashMaps to store edges, allowing fast insertion and removal of the latter