Skip to main content

Graph

Trait Graph 

Source
pub trait Graph<N, E>
where N: Node, E: Edge<N>,
{ // 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§

Source

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.

Source

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.

Source

fn insert_node(&mut self, node: N) -> Option<N>

Inserts a node into the graph.

Returns an option possibly containing a replaced node.

Source

fn remove_node( &mut self, identifier: &N::Identifier, ) -> Result<Option<N>, RemainingConnectedEdgesError<E::Identifier>>

Attempts to remove a node from the graph.

Provided Methods§

Source

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".

Implementors§

Source§

impl<NodeIdentifier, EdgeIdentifier> Graph<NodeEntry<NodeIdentifier>, EdgeEntry<EdgeIdentifier, NodeIdentifier>> for GraphWidget<NodeIdentifier, EdgeIdentifier>
where NodeIdentifier: Identifier, EdgeIdentifier: Identifier,