Trait Graph

Source
pub trait Graph<N = String, V = i64>:
    Clone
    + Contain<N>
    + Contain<Edge<N, V>>
    + IndexMut<N, Output = Vec<(N, V)>>
where N: Node, V: Weight,
{
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§

Source

fn store_mut(&mut self) -> &mut AdjacencyTable<N, V>

Graph::store_mut returns an owned, mutable instance of the AdjacencyTable

Source

fn store(&self) -> &AdjacencyTable<N, V>

Graph::store returns an owned instance of the AdjacencyTable

Provided Methods§

Source

fn add_edge(&mut self, edge: Edge<N, V>)

Graph::add_edge inserts a new Edge into the graph

Source

fn add_edges(&mut self, iter: impl IntoIterator<Item = Edge<N, V>>)

Graph::add_edges insert several edges into the graph

Source

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

Source

fn add_nodes(&mut self, iter: impl IntoIterator<Item = N>)

Graph::add_nodes insert several nodes into the graph

Source

fn contains_edge(&self, edge: &Edge<N, V>) -> bool

Graph::contains_edge returns true if the given Edge is in the graph

Source

fn contains_node(&self, node: &N) -> bool

Graph::contains_node returns true if the given Node is in the graph

Source

fn degree(&self, node: &N) -> Result<usize, GraphError>

Graph::degree returns the degree of the given Node

Source

fn edges(&self) -> Vec<Edge<N, V>>

Graph::edges returns all of the edges persisting within the graph

Source

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

Source

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

Source

fn is_connected(&self) -> bool

Graph::is_connected returns true if the graph is connected

Source

fn neighbors(&self, node: N) -> Result<&Vec<(N, V)>, GraphError>

Graph::neighbors attempts to return a Vec that contains all of the connected Node and their values

Source

fn nodes(&self) -> HashSet<N>

Graph::nodes returns a cloned HashSet of the graph’s current Nodes

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.

Implementors§

Source§

impl<N, V> Graph<N, V> for DirectedGraph<N, V>
where N: Node, V: Weight,

Source§

impl<N, V> Graph<N, V> for UndirectedGraph<N, V>
where N: Node, V: Weight,