pub trait RemoveVertex<V, E>where
E: Ord,{
type Error;
// Required method
fn remove_vertex(&mut self, x: V) -> Result<(), Self::Error>;
}Expand description
RemoveVertex removes the vertex x, if it is there. If the vertex does not exist,
an error is raised.
§Example
extern crate alloc;
use alloc::collections::btree_set::BTreeSet;
use btree_graph::{BTreeGraph, AddVertex, AddEdge, Edges, RemoveVertex, GetVertexValue, Vertices};
let mut graph: BTreeGraph<String, usize> = BTreeGraph::new();
graph.add_vertex(String::from("origin"));
graph.add_vertex(String::from("destination"));
graph.add_edge(String::from("origin"), String::from("destination"), 10);
graph.remove_vertex(String::from("destination"));
assert_eq!(graph.vertices().len(), 1);
// Note: removing a vertex will also cascade delete any incident edges, which will then
// cascade delete any edges from the origin existing vertices' adjacency list.
assert_eq!(graph.edges().len(), 0);
assert_eq!(graph.get_vertex_value(String::from("origin")).unwrap().len(), 0);