pub trait AddEdge<V, E> {
type Error;
// Required method
fn add_edge(
&mut self,
x: V,
y: V,
e: E,
) -> Result<Option<(V, V)>, Self::Error>;
}Expand description
AddEdge add an edge from the vertex x to the vertex y, if it is not there.
§Example
use btree_graph::{BTreeGraph, AddVertex, AddEdge, Edges};
let mut graph: BTreeGraph<String, usize> = BTreeGraph::new();
graph.add_vertex(String::from("origin"));
graph.add_vertex(String::from("destination"));
let old_edge_value: Option<(String, String)> = graph.add_edge(String::from("origin"), String::from("destination"), 10).unwrap();
assert!(old_edge_value.is_none());
assert_eq!(graph.edges().len(), 1)