pub struct Graph<V, E> { /* private fields */ }
Expand description
Main graph structure
Implementations§
source§impl<V: Clone, E: Clone> Graph<V, E>
impl<V: Clone, E: Clone> Graph<V, E>
pub fn new() -> Graph<V, E>
pub fn add_vertex(&mut self, vertex_data: V) -> (VertexIndex, GraphDiff<V, E>)
pub fn add_edge( &mut self, from_index: VertexIndex, to_index: VertexIndex, edge_data: E ) -> Result<(EdgeIndex, GraphDiff<V, E>), GraphError>
pub fn update_vertex( &mut self, index: VertexIndex, value: V ) -> Result<(V, GraphDiff<V, E>), GraphError>
pub fn update_edge( &mut self, index: EdgeIndex, value: E ) -> Result<(E, GraphDiff<V, E>), GraphError>
pub fn remove_edge( &mut self, edge_index: EdgeIndex ) -> Result<(E, GraphDiff<V, E>), GraphError>
pub fn remove_vertex( &mut self, vertex_index: VertexIndex ) -> Result<(V, GraphDiff<V, E>), GraphError>
pub fn apply_diff(&mut self, diff: GraphDiff<V, E>) -> Result<(), GraphError>
pub fn rollback_diff(&mut self, diff: GraphDiff<V, E>) -> Result<(), GraphError>
source§impl<V: Clone, E: Clone> Graph<V, E>
impl<V: Clone, E: Clone> Graph<V, E>
pub fn get_vertex(&self, index: VertexIndex) -> Option<&Vertex<V>>
pub fn get_vertex_data(&self, index: VertexIndex) -> Option<&V>
sourcepub fn get_vertex_data_mut(&mut self, index: VertexIndex) -> Option<&mut V>
pub fn get_vertex_data_mut(&mut self, index: VertexIndex) -> Option<&mut V>
Note: changes here will not be tracked. It’s usually better to use
Graph::update_vertex
pub fn get_edge(&self, index: EdgeIndex) -> Option<&Edge<E>>
pub fn get_edge_data(&self, index: EdgeIndex) -> Option<&E>
sourcepub fn get_edge_data_mut(&mut self, index: EdgeIndex) -> Option<&mut E>
pub fn get_edge_data_mut(&mut self, index: EdgeIndex) -> Option<&mut E>
Note: changes here will not be tracked. It’s usually better to use
Graph::update_edge
sourcepub fn assert_vertex_exists(&self, index: VertexIndex) -> Result<(), GraphError>
pub fn assert_vertex_exists(&self, index: VertexIndex) -> Result<(), GraphError>
Check that a vertex exists. Returns a result containing VertexDoesNotExist
if it doesn’t exist
pub fn assert_edge_exists(&self, index: EdgeIndex) -> Result<(), GraphError>
Get a list of edges between two nodes. This only returns connections in one direction.
pub fn get_verticies(&self) -> &GenVec<Vertex<V>>
pub fn get_edges(&self) -> &GenVec<Edge<E>>
pub fn vertex_indexes(&self) -> impl Iterator<Item = VertexIndex> + '_
pub fn edge_indexes(&self) -> impl Iterator<Item = EdgeIndex> + '_
pub fn vertex_iter( &self ) -> impl Iterator<Item = (VertexIndex, &Vertex<V>)> + '_
pub fn edge_iter(&self) -> impl Iterator<Item = (EdgeIndex, &Edge<E>)> + '_
pub fn vertex_data_iter(&self) -> impl Iterator<Item = (VertexIndex, &V)> + '_
pub fn edge_data_iter(&self) -> impl Iterator<Item = (EdgeIndex, &E)> + '_
Trait Implementations§
source§impl<'de, V, E> Deserialize<'de> for Graph<V, E>where
V: Deserialize<'de>,
E: Deserialize<'de>,
impl<'de, V, E> Deserialize<'de> for Graph<V, E>where
V: Deserialize<'de>,
E: Deserialize<'de>,
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl<V, E> RefUnwindSafe for Graph<V, E>where
E: RefUnwindSafe,
V: RefUnwindSafe,
impl<V, E> Send for Graph<V, E>
impl<V, E> Sync for Graph<V, E>
impl<V, E> Unpin for Graph<V, E>
impl<V, E> UnwindSafe for Graph<V, E>where
E: UnwindSafe,
V: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more