pub trait Graph {
// Required methods
fn empty<I, V>(labels: I) -> Self
where I: IntoIterator<Item = V>,
V: AsRef<str>;
fn complete<I, V>(labels: I) -> Self
where I: IntoIterator<Item = V>,
V: AsRef<str>;
fn vertices(&self) -> Set<usize>;
fn has_vertex(&self, x: usize) -> bool;
fn edges(&self) -> Set<(usize, usize)>;
fn has_edge(&self, x: usize, y: usize) -> bool;
fn add_edge(&mut self, x: usize, y: usize) -> bool;
fn del_edge(&mut self, x: usize, y: usize) -> bool;
fn from_adjacency_matrix(
labels: Labels,
adjacency_matrix: Array2<bool>,
) -> Self;
fn to_adjacency_matrix(&self) -> Array2<bool>;
}Expand description
A trait for graphs.
Required Methods§
Sourcefn vertices(&self) -> Set<usize>
fn vertices(&self) -> Set<usize>
Returns the iterator of vertices in the graph.
§Returns
A set representing the vertices in the graph.
Sourcefn has_vertex(&self, x: usize) -> bool
fn has_vertex(&self, x: usize) -> bool
Sourcefn edges(&self) -> Set<(usize, usize)>
fn edges(&self) -> Set<(usize, usize)>
Returns the iterator of edges in the graph.
§Returns
A set of tuples representing the edges in the graph.
Sourcefn from_adjacency_matrix(labels: Labels, adjacency_matrix: Array2<bool>) -> Self
fn from_adjacency_matrix(labels: Labels, adjacency_matrix: Array2<bool>) -> Self
Sourcefn to_adjacency_matrix(&self) -> Array2<bool>
fn to_adjacency_matrix(&self) -> Array2<bool>
Converts the graph to an adjacency matrix.
§Returns
A 2D array representing the adjacency matrix of the graph.
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.