[][src]Trait btree_dag::AddEdge

pub trait AddEdge<T> {
    type Error;
    fn add_edge(&mut self, x: T, y: T) -> Result<(), Self::Error>;
}

AddEdge add an edge from the vertex x to the vertex y, if it is not there.

Example

extern crate alloc;
use alloc::collections::btree_set::BTreeSet;
use btree_dag::{BTreeDag, AddVertex, AddEdge, GetVertexValue};
use btree_dag::error::Error;
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"));

let x_value: &BTreeSet<String> = dag.get_vertex_value(String::from("origin")).unwrap();
assert!(x_value.contains(&String::from("destination")));

assert!(dag.get_vertex_value(String::from("destination")).unwrap().is_empty());

Associated Types

Loading content...

Required methods

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

Loading content...

Implementors

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

When you add an edge, you should make sure that the x, and y vertices exist.

type Error = Error

Loading content...