[][src]Trait btree_network::AddEdge

pub trait AddEdge<T> {
    type Error;
    pub 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_network::{BTreeNetwork, AddVertex, AddEdge, GetVertexValue};
let mut network: BTreeNetwork<String> = BTreeNetwork::new();
network.add_vertex(String::from("origin"));
network.add_vertex(String::from("destination"));
network.add_edge(String::from("origin"), String::from("destination"));

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

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

Associated Types

Loading content...

Required methods

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

Loading content...

Implementors

impl<T> AddEdge<T> for BTreeNetwork<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...