[][src]Trait btree_dag::RemoveVertex

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

RemoveVertex removes the vertex x, if it is there.

Example

extern crate alloc;
use alloc::collections::btree_set::BTreeSet;
use btree_dag::{BTreeDag, AddVertex, AddEdge, RemoveVertex, GetVertexValue, Vertices};
let mut dag: BTreeDag<String> = BTreeDag::new();
dag.add_vertex(String::from("origin"));
dag.add_vertex(String::from("destination"));
dag.add_edge(String::from("origin"), String::from("destination"));


dag.remove_vertex(String::from("destination"));
assert_eq!(dag.vertices().len(), 1);

// Note: removing a vertex will also cascade delete any incident edges.
assert_eq!(dag.get_vertex_value(String::from("origin")).unwrap().len(), 0);

Associated Types

Loading content...

Required methods

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

Loading content...

Implementors

impl<T> RemoveVertex<T> for BTreeDag<T> where
    T: Ord + Clone
[src]

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

type Error = Error

Loading content...