pub trait Graph<N, E>{
// Required methods
fn insert_edge(
&mut self,
edge: E,
) -> Result<Option<E>, InvalidEdgeEndError<N::Identifier>>;
fn remove_edge(&mut self, identifier: &E::Identifier) -> Option<E>;
fn insert_node(&mut self, node: N) -> Option<N>;
fn remove_node(
&mut self,
identifier: &N::Identifier,
) -> Result<Option<N>, RemainingConnectedEdgesError<E::Identifier>>;
// Provided method
fn remove_node_with_edges(
&mut self,
identifier: &N::Identifier,
) -> Option<(N, Vec<E>)> { ... }
}Expand description
Trait that defines a graph structure.
Required Methods§
Sourcefn insert_edge(
&mut self,
edge: E,
) -> Result<Option<E>, InvalidEdgeEndError<N::Identifier>>
fn insert_edge( &mut self, edge: E, ) -> Result<Option<E>, InvalidEdgeEndError<N::Identifier>>
Attempts to insert an edge into the graph.
If there edge end ids are not represented as nodes in the graph, this will return in error. Otherwise, this will return an option possibly containing a replaced edge.
Sourcefn remove_edge(&mut self, identifier: &E::Identifier) -> Option<E>
fn remove_edge(&mut self, identifier: &E::Identifier) -> Option<E>
Removes an edge from the graph.
Returns an option containing the removed edge entry if the identified edge was present.
Sourcefn insert_node(&mut self, node: N) -> Option<N>
fn insert_node(&mut self, node: N) -> Option<N>
Inserts a node into the graph.
Returns an option possibly containing a replaced node.
Sourcefn remove_node(
&mut self,
identifier: &N::Identifier,
) -> Result<Option<N>, RemainingConnectedEdgesError<E::Identifier>>
fn remove_node( &mut self, identifier: &N::Identifier, ) -> Result<Option<N>, RemainingConnectedEdgesError<E::Identifier>>
Attempts to remove a node from the graph.
Provided Methods§
Sourcefn remove_node_with_edges(
&mut self,
identifier: &N::Identifier,
) -> Option<(N, Vec<E>)>
fn remove_node_with_edges( &mut self, identifier: &N::Identifier, ) -> Option<(N, Vec<E>)>
Removes a node and all dependent edges from the graph.
This implicitly depends on remove_node and remove_edge to work as excpted, otherwise it may panic.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".