Trait graphbench::graph::MutableGraph
source · [−]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
sourcefn with_capacity(n: usize) -> Self
fn with_capacity(n: usize) -> Self
Creates a mutable graph with a hint on how many vertices it will probably contain.
sourcefn add_vertex(&mut self, u: &Vertex) -> bool
fn add_vertex(&mut self, u: &Vertex) -> bool
Adds the vertex u
to the graph.
Returns true
if the vertex was added and false
if it was already contained in the graph.
sourcefn remove_vertex(&mut self, u: &Vertex) -> bool
fn remove_vertex(&mut self, u: &Vertex) -> bool
Removes the vertex u
from the graph.
Returns true
if the vertex was removed and false
if it was not contained in the graph.
sourcefn add_edge(&mut self, u: &Vertex, v: &Vertex) -> bool
fn add_edge(&mut self, u: &Vertex, v: &Vertex) -> bool
Adds the edge uv
to the graph.
Returns true
if the edge was added and false
if it was already contained in the graph.
sourcefn remove_edge(&mut self, u: &Vertex, v: &Vertex) -> bool
fn remove_edge(&mut self, u: &Vertex, v: &Vertex) -> bool
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
sourcefn add_vertices(&mut self, vertices: impl Iterator<Item = Vertex>) -> u32
fn add_vertices(&mut self, vertices: impl Iterator<Item = Vertex>) -> u32
Adds a collection of vertices
to the graph.
Returns the number of vertices added this way.
sourcefn add_edges(&mut self, edges: impl Iterator<Item = Edge>) -> u32
fn add_edges(&mut self, edges: impl Iterator<Item = Edge>) -> u32
Adds a collection of edges
to the graph.
Returns the number of edges added this way.
sourcefn remove_loops(&mut self) -> usize
fn remove_loops(&mut self) -> usize
Removes all loops from the graph.
Returns the number of loops removed.
sourcefn remove_isolates(&mut self) -> usize
fn remove_isolates(&mut self) -> usize
Removes all isolate vertices, that is, vertices without any neighbours.
Returns the number of isolates removed.