[][src]Trait btree_graph::RemoveVertex

pub trait RemoveVertex<V, E> where
    E: Ord
{ type Error; pub fn remove_vertex(&mut self, x: V) -> Result<(), Self::Error>; }

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

Associated Types

Loading content...

Required methods

pub fn remove_vertex(&mut self, x: V) -> Result<(), Self::Error>[src]

Loading content...

Implementors

impl<V, E> RemoveVertex<V, E> for BTreeGraph<V, E> where
    V: Ord + Clone,
    E: Ord + Clone
[src]

When you remove a vertex, you should ensure there are no dangling edges.

type Error = Error

Loading content...