Struct ddgg::Graph

source ·
pub struct Graph<V, E> { /* private fields */ }
Expand description

Main graph structure

Implementations§

source§

impl<V, E> Graph<V, E>

source

pub fn from_constraints() -> Graph<V, E>

source§

impl<V: Clone, E: Clone> Graph<V, E>

source

pub fn new() -> Graph<V, E>

source

pub fn add_vertex(&mut self, vertex_data: V) -> (VertexIndex, GraphDiff<V, E>)

source

pub fn add_edge( &mut self, from_index: VertexIndex, to_index: VertexIndex, edge_data: E ) -> Result<(EdgeIndex, GraphDiff<V, E>), GraphError>

source

pub fn update_vertex( &mut self, index: VertexIndex, value: V ) -> Result<(V, GraphDiff<V, E>), GraphError>

source

pub fn update_edge( &mut self, index: EdgeIndex, value: E ) -> Result<(E, GraphDiff<V, E>), GraphError>

source

pub fn remove_edge( &mut self, edge_index: EdgeIndex ) -> Result<(E, GraphDiff<V, E>), GraphError>

source

pub fn remove_vertex( &mut self, vertex_index: VertexIndex ) -> Result<(V, GraphDiff<V, E>), GraphError>

source

pub fn apply_diff(&mut self, diff: GraphDiff<V, E>) -> Result<(), GraphError>

source

pub fn rollback_diff(&mut self, diff: GraphDiff<V, E>) -> Result<(), GraphError>

source§

impl<V: Clone, E: Clone> Graph<V, E>

source

pub fn get_vertex(&self, index: VertexIndex) -> Option<&Vertex<V>>

source

pub fn get_vertex_data(&self, index: VertexIndex) -> Option<&V>

source

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

source

pub fn get_edge(&self, index: EdgeIndex) -> Option<&Edge<E>>

source

pub fn get_edge_data(&self, index: EdgeIndex) -> Option<&E>

source

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

source

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

source

pub fn assert_edge_exists(&self, index: EdgeIndex) -> Result<(), GraphError>

source

pub fn shared_edges( &self, from: VertexIndex, to: VertexIndex ) -> Result<impl Iterator<Item = EdgeIndex> + '_, GraphError>

Get a list of edges between two nodes. This only returns connections in one direction.

source

pub fn get_verticies(&self) -> &GenVec<Vertex<V>>

source

pub fn get_edges(&self) -> &GenVec<Edge<E>>

source

pub fn vertex_indexes(&self) -> impl Iterator<Item = VertexIndex> + '_

source

pub fn edge_indexes(&self) -> impl Iterator<Item = EdgeIndex> + '_

source

pub fn vertex_iter( &self ) -> impl Iterator<Item = (VertexIndex, &Vertex<V>)> + '_

source

pub fn edge_iter(&self) -> impl Iterator<Item = (EdgeIndex, &Edge<E>)> + '_

source

pub fn vertex_data_iter(&self) -> impl Iterator<Item = (VertexIndex, &V)> + '_

source

pub fn edge_data_iter(&self) -> impl Iterator<Item = (EdgeIndex, &E)> + '_

Trait Implementations§

source§

impl<V: Clone, E: Clone> Clone for Graph<V, E>

source§

fn clone(&self) -> Graph<V, E>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<V: Debug, E: Debug> Debug for Graph<V, E>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<V: Clone, E: Clone> Default for Graph<V, E>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

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>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<V: Clone, E: Clone> Index<EdgeIndex> for Graph<V, E>

§

type Output = Edge<E>

The returned type after indexing.
source§

fn index(&self, index: EdgeIndex) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl<V: Clone, E: Clone> Index<VertexIndex> for Graph<V, E>

§

type Output = Vertex<V>

The returned type after indexing.
source§

fn index(&self, index: VertexIndex) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl<V: Clone, E: Clone> IndexMut<EdgeIndex> for Graph<V, E>

source§

fn index_mut(&mut self, index: EdgeIndex) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
source§

impl<V: Clone, E: Clone> IndexMut<VertexIndex> for Graph<V, E>

source§

fn index_mut(&mut self, index: VertexIndex) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
source§

impl<V, E> Serialize for Graph<V, E>
where V: Serialize, E: Serialize,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<V, E> RefUnwindSafe for Graph<V, E>

§

impl<V, E> Send for Graph<V, E>
where E: Send, V: Send,

§

impl<V, E> Sync for Graph<V, E>
where E: Sync, V: Sync,

§

impl<V, E> Unpin for Graph<V, E>
where E: Unpin, V: Unpin,

§

impl<V, E> UnwindSafe for Graph<V, E>
where E: UnwindSafe, V: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,