[][src]Trait btree_graph::RemoveEdge

pub trait RemoveEdge<V, E> {
    type Error;
    pub fn remove_edge(&mut self, x: E) -> Result<(), Self::Error>;
}

RemoveEdge removes the edge from the vertex x to the vertex y, if it is there. If the edge does not exist, an error will be raised.

Example

use btree_graph::{BTreeGraph, AddVertex, AddEdge, Edges, RemoveEdge, GetVertexValue};
let mut graph: BTreeGraph<String, usize> = BTreeGraph::new();
graph.add_vertex(String::from("origin"));
graph.add_vertex(String::from("destination"));
graph.add_edge(String::from("origin"), String::from("destination"), 10);

assert_eq!(graph.edges().len(), 1);

graph.remove_edge(10);

assert_eq!(graph.edges().len(), 0);

// Note: deletion of edges cascade i.e. the edge is also deleted from any incident
// vertices' adjacency lists.
assert_eq!(graph.get_vertex_value(String::from("origin")).unwrap().len(), 0);

Associated Types

Loading content...

Required methods

pub fn remove_edge(&mut self, x: E) -> Result<(), Self::Error>[src]

Loading content...

Implementors

impl<V, E> RemoveEdge<V, E> for BTreeGraph<V, E> where
    V: Ord + Clone,
    E: Ord + Clone
[src]

When an edge is removed, you should find the incident vertex and ensure the edge is removed from the vertex's adjacency list.

type Error = Error

Loading content...