[][src]Trait btree_network::Adjacent

pub trait Adjacent<T> {
    type Error;
    pub fn adjacent(&self, x: T, y: T) -> Result<bool, Self::Error>;
}

Adjacent tests whether there is an edge from the vertex x to the vertex y. An error is thrown if either x, or y do not exist. By definition of adjacent there must exist an edge e, with value (x, y) in order for vertices x, and y to be considered adjacent.

Example

use btree_network::{BTreeNetwork, AddVertex, AddEdge, Adjacent};
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"));

assert!(network.adjacent(String::from("origin"), String::from("destination")).unwrap());
// Note: the network is directed, and the definition of adjacent
// can be phrased, if there exists a relationship from x to y. Therefore
// A and B adjacent does not imply B and A are adjacent.
assert!(network.adjacent(String::from("destination"), String::from("origin")).unwrap());

Associated Types

Loading content...

Required methods

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

Loading content...

Implementors

impl<T> Adjacent<T> for BTreeNetwork<T> where
    T: Ord
[src]

type Error = Error

Loading content...