pub trait MutableGraph: Graph {
    fn new() -> Self;
    fn with_capacity(n: usize) -> Self;
    fn add_vertex(&mut self, u: &Vertex) -> bool;
    fn remove_vertex(&mut self, u: &Vertex) -> bool;
    fn add_edge(&mut self, u: &Vertex, v: &Vertex) -> bool;
    fn remove_edge(&mut self, u: &Vertex, v: &Vertex) -> bool;

    fn add_vertices(&mut self, vertices: impl Iterator<Item = Vertex>) -> u32 { ... }
    fn add_edges(&mut self, edges: impl Iterator<Item = Edge>) -> u32 { ... }
    fn remove_loops(&mut self) -> usize { ... }
    fn remove_isolates(&mut self) -> usize { ... }
}
Expand description

Trait for mutable graphs.

Required Methods

Creates an emtpy mutable graph.

Creates a mutable graph with a hint on how many vertices it will probably contain.

Adds the vertex u to the graph.

Returns true if the vertex was added and false if it was already contained in the graph.

Removes the vertex u from the graph.

Returns true if the vertex was removed and false if it was not contained in the graph.

Adds the edge uv to the graph.

Returns true if the edge was added and false if it was already contained in the graph.

Removes the edge uv from the graph.

Returns true if the edge was removed and false if it was not contained in the graph.

Provided Methods

Adds a collection of vertices to the graph.

Returns the number of vertices added this way.

Adds a collection of edges to the graph.

Returns the number of edges added this way.

Removes all loops from the graph.

Returns the number of loops removed.

Removes all isolate vertices, that is, vertices without any neighbours.

Returns the number of isolates removed.

Implementors