pub trait MutableGraph: Graph {
// Required methods
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;
// Provided methods
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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.