[−][src]Trait btree_dag::Adjacent
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_dag::{BTreeDag, AddVertex, AddEdge, Adjacent}; 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")); assert!(dag.adjacent(String::from("origin"), String::from("destination")).unwrap()); // Note: the dag is directed, and the definition of adjacent // can be phrased, if there exists a relationship from x to y. Therefore // A and B adjacent implies B and A cannot be adjacent. let err: Error = dag.add_edge(String::from("destination"), String::from("origin")).unwrap_err(); assert_eq!(err, Error::EdgeExistsError)