pub trait Graph<N = String, V = i64>:
Clone
+ Contain<N>
+ Contain<Edge<N, V>>
+ IndexMut<N, Output = Vec<(N, V)>>{
Show 15 methods
// Required methods
fn store_mut(&mut self) -> &mut AdjacencyTable<N, V>;
fn store(&self) -> &AdjacencyTable<N, V>;
// Provided methods
fn add_edge(&mut self, edge: Edge<N, V>) { ... }
fn add_edges(&mut self, iter: impl IntoIterator<Item = Edge<N, V>>) { ... }
fn add_node(&mut self, node: N) -> bool { ... }
fn add_nodes(&mut self, iter: impl IntoIterator<Item = N>) { ... }
fn contains_edge(&self, edge: &Edge<N, V>) -> bool { ... }
fn contains_node(&self, node: &N) -> bool { ... }
fn degree(&self, node: &N) -> Result<usize, GraphError> { ... }
fn edges(&self) -> Vec<Edge<N, V>> { ... }
fn edges_from(&self, node: &N) -> Result<Vec<Edge<N, V>>, GraphError> { ... }
fn edges_to(&self, node: &N) -> Result<Vec<Edge<N, V>>, GraphError> { ... }
fn is_connected(&self) -> bool { ... }
fn neighbors(&self, node: N) -> Result<&Vec<(N, V)>, GraphError> { ... }
fn nodes(&self) -> HashSet<N> { ... }
}
Expand description
Graph describes the basic operations of a graph data-structure
Required Methods§
Sourcefn store_mut(&mut self) -> &mut AdjacencyTable<N, V>
fn store_mut(&mut self) -> &mut AdjacencyTable<N, V>
Graph::store_mut returns an owned, mutable instance of the AdjacencyTable
Sourcefn store(&self) -> &AdjacencyTable<N, V>
fn store(&self) -> &AdjacencyTable<N, V>
Graph::store returns an owned instance of the AdjacencyTable
Provided Methods§
Sourcefn add_edge(&mut self, edge: Edge<N, V>)
fn add_edge(&mut self, edge: Edge<N, V>)
Graph::add_edge inserts a new Edge into the graph
Sourcefn add_edges(&mut self, iter: impl IntoIterator<Item = Edge<N, V>>)
fn add_edges(&mut self, iter: impl IntoIterator<Item = Edge<N, V>>)
Graph::add_edges insert several edges into the graph
Sourcefn add_node(&mut self, node: N) -> bool
fn add_node(&mut self, node: N) -> bool
Graph::add_node if the given Node is not already in the Graph, insert the Node and return true; else return false
Sourcefn add_nodes(&mut self, iter: impl IntoIterator<Item = N>)
fn add_nodes(&mut self, iter: impl IntoIterator<Item = N>)
Graph::add_nodes insert several nodes into the graph
Sourcefn contains_edge(&self, edge: &Edge<N, V>) -> bool
fn contains_edge(&self, edge: &Edge<N, V>) -> bool
Graph::contains_edge returns true if the given Edge is in the graph
Sourcefn contains_node(&self, node: &N) -> bool
fn contains_node(&self, node: &N) -> bool
Graph::contains_node returns true if the given Node is in the graph
Sourcefn degree(&self, node: &N) -> Result<usize, GraphError>
fn degree(&self, node: &N) -> Result<usize, GraphError>
Graph::degree returns the degree of the given Node
Sourcefn edges(&self) -> Vec<Edge<N, V>>
fn edges(&self) -> Vec<Edge<N, V>>
Graph::edges returns all of the edges persisting within the graph
Sourcefn edges_from(&self, node: &N) -> Result<Vec<Edge<N, V>>, GraphError>
fn edges_from(&self, node: &N) -> Result<Vec<Edge<N, V>>, GraphError>
Graph::edges_from returns all of the edges originating from the given Node
Sourcefn edges_to(&self, node: &N) -> Result<Vec<Edge<N, V>>, GraphError>
fn edges_to(&self, node: &N) -> Result<Vec<Edge<N, V>>, GraphError>
Graph::edges_to returns all of the edges terminating at the given Node
Sourcefn is_connected(&self) -> bool
fn is_connected(&self) -> bool
Graph::is_connected returns true if the graph is connected
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.