[−][src]Trait generic_graph::VariableVertexes
This trait adds to a Directed graph the methods to add and remove edges
Required methods
fn add_vertex(&mut self, vertex: T) -> Option<T>
If a vertex with an equal key is already present, the vertex is updated (not the key) and the old vertex is returned ad Some(old_vertex). If not present None is returned.
fn remove_vertex(&mut self, key: K) -> Option<T>
If the removed vertex was present it's removed and returned as Some(vertex). Otherwise None is returned
Implementors
impl<K: Hash + Eq + Clone, V, W: Add + Sub + Eq + Ord + Copy> VariableVertexes<SimpleVertex<K, V>, DirectedEdge<K, W>, K, V, W, CompoundKey<K>> for AdjacencyGraph<K, V, W>
[src]
AdjacencyGraph
uses HashMaps to store vertexes, allowing fast insertion and removal of the latter
fn add_vertex(
&mut self,
vertex: SimpleVertex<K, V>
) -> Option<SimpleVertex<K, V>>
[src]
&mut self,
vertex: SimpleVertex<K, V>
) -> Option<SimpleVertex<K, V>>
This method adds (or, if present, updates maintaining its edges) a vertex and returns None ore Some(old_vertex)
Examples
use generic_graph::adjacency_list::AdjacencyGraph; use generic_graph::{SimpleVertex, VariableVertexes}; let mut graph = AdjacencyGraph::<i32, &str, i32>::new(); assert_eq!(None, graph.add_vertex(SimpleVertex::new(1, "a"))); assert_eq!(None, graph.add_vertex(SimpleVertex::new(2, "b"))); assert_eq!(Some(SimpleVertex::new(1, "a")), graph.add_vertex(SimpleVertex::new(1, "c")))
fn remove_vertex(&mut self, key: K) -> Option<SimpleVertex<K, V>>
[src]
This method removes a vertex and its edges from the graph and returns None ore Some(old_vertex)
Examples
use generic_graph::adjacency_list::AdjacencyGraph; use generic_graph::{SimpleVertex, VariableVertexes}; let mut graph = AdjacencyGraph::<i32, &str, i32>::new(); graph.add_vertex(SimpleVertex::new(1, "a")); graph.add_vertex(SimpleVertex::new(2, "b")); assert_eq!(None, graph.remove_vertex(0)); assert_eq!(Some(SimpleVertex::new(1, "a")), graph.remove_vertex(1)); assert_eq!(Some(SimpleVertex::new(2, "b")), graph.remove_vertex(2)); assert_eq!(None, graph.remove_vertex(1));