Struct BasicDirectedGraph

Source
pub struct BasicDirectedGraph<K, V>
where K: Key, V: Value,
{ /* private fields */ }
Expand description

A basic implementation of a directed graph. It doesn’t allow multiple edges but allow loops.

Implementations§

Source§

impl<K, V> BasicDirectedGraph<K, V>
where K: Key, V: Value,

Source

pub fn new() -> Self

Create a new directed graph. Complexity: O(1)

Trait Implementations§

Source§

impl<K, V> Algorithms<K, V> for BasicDirectedGraph<K, V>
where K: Key, V: Value,

Source§

fn bfs(&self) -> Option<Self>

Execute a Broad Search First the return the discovered graph. There is no order in which the edges are treated.
Source§

fn bfs_with_starting_vertex( &self, starting_vertex: &Vertex<K, V>, ) -> Option<Self>

Execute a Broad Search First with a starting vertex the return the discovered graph. There is no order in which the edges are treated.
Source§

fn dfs(&self) -> Option<Self>

Execute a Deep Search First the return the discovered graph. There is no order in which the edges are treated.
Source§

fn dfs_with_starting_vertex( &self, starting_vertex: &Vertex<K, V>, ) -> Option<Self>

Execute a Deep Search First with a starting vertex the return the discovered graph. There is no order in which the edges are treated.
Source§

impl<K, V> AnyGraph<K, V> for BasicDirectedGraph<K, V>
where K: Key, V: Value,

Source§

fn vertices(&self) -> Vec<Vertex<K, V>>

Get the vertices of the graph. Complexity: O(1*).

Source§

fn edges(&self) -> Vec<Edge<K>>

Get the edges of the graph. Complexity: O(1*).

Source§

fn add_vertex(&self, vertex: Vertex<K, V>) -> Option<Self>

Add a new vertex then return the graph. Complexity: O(1*).

Source§

fn remove_vertex( &self, vertex: &Vertex<K, V>, ) -> Option<(Self, Vertex<K, V>, Vec<Edge<K>>)>

Remove a vertex then return the new graph, the deleted vertex and its edges. Complexity: O(E).

Source§

fn remove_all_vertices(&self) -> Option<(Self, Vec<Vertex<K, V>>, Vec<Edge<K>>)>

Remove all vertices then return the new graph, the deleted vertices and all the edges. Complexity: O(1*).

Source§

fn remove_vertex_where_key( &self, key: K, ) -> Option<(Self, Vertex<K, V>, Vec<Edge<K>>)>

Remove a vertex by its key then return the new graph, the deleted vertex and its edges. Complexity: O(E).

Source§

fn add_edge(&self, edge: Edge<K>) -> Option<Self>

Add a new edge then return the new graph. Complexity: O(1*).

Source§

fn add_edge_between_keys(&self, key_from: K, key_to: K) -> Option<Self>

Add a new edge between 2 keys then return the new graph. Complexity: O(1*).

Source§

fn remove_edge(&self, edge: &Edge<K>) -> Option<(Self, Edge<K>)>

Remove an existing edge then return the new graph and the deleted edge. Complexity: O(1*).

Source§

fn remove_edge_where_keys( &self, key_from: K, key_to: K, ) -> Option<(Self, Edge<K>)>

Remove an existing edge by their keys, then return the new graph and the deleted edge. Complexity: O(1*).

Source§

fn remove_all_edges(&self) -> Option<(Self, Vec<Edge<K>>)>

Remove all the edges then return the new graph and all the deleted edges. Complexity: O(1*).

Source§

fn remove_all_edges_where_vertex( &self, vertex: &Vertex<K, V>, ) -> Option<(Self, Vec<Edge<K>>)>

Remove all existing edges from or to a given vertex, then return the new graph and the deleted edges. Complexity: O(E).

Source§

fn remove_all_edges_where_key( &self, key_from: K, ) -> Option<(Self, Vec<Edge<K>>)>

Remove all existing edges from or to a given key, then return the new graph and the deleted edges. Complexity: O(E).

Source§

fn remove_all_edges_from_vertex( &self, vertex: &Vertex<K, V>, ) -> Option<(Self, Vec<Edge<K>>)>

Remove all existing edges from a given vertex, then return the new graph and the deleted edges. Complexity: O(E).

Source§

fn remove_all_edges_from_key(&self, key_from: K) -> Option<(Self, Vec<Edge<K>>)>

Remove all existing edges from a given key, then return the new graph and the deleted edges. Complexity: O(E).

Source§

impl<K, V> Clone for BasicDirectedGraph<K, V>
where K: Key + Clone, V: Value + Clone,

Source§

fn clone(&self) -> BasicDirectedGraph<K, V>

Returns a duplicate 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<K, V> Kinship<K, V> for BasicDirectedGraph<K, V>
where K: Key, V: Value,

Source§

fn successors(&self) -> HashMap<Vertex<K, V>, Vec<Edge<K>>, RandomState>

Get the successors of each vertex. Complexity: O(V + E).

Source§

fn predecessors(&self) -> HashMap<Vertex<K, V>, Vec<Edge<K>>, RandomState>

Get the predecessors of each vertex. Complexity: O(V + E).

Source§

fn successors_as_key_and_edges(&self) -> HashMap<K, Vec<Edge<K>>>

Get the successors of each vertex where the key is a Key.
Source§

fn predecessors_as_key_and_edges(&self) -> HashMap<K, Vec<Edge<K>>>

Get the predecessors of each vertex where the key is a Key.
Source§

fn key_vertex_map(&self) -> HashMap<K, Vertex<K, V>>

Get the map of key and vertex.
Source§

impl<K, V> PartialEq for BasicDirectedGraph<K, V>
where K: Key + PartialEq, V: Value + PartialEq,

Source§

fn eq(&self, other: &BasicDirectedGraph<K, V>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<K, V> StructuralPartialEq for BasicDirectedGraph<K, V>
where K: Key, V: Value,

Auto Trait Implementations§

§

impl<K, V> Freeze for BasicDirectedGraph<K, V>

§

impl<K, V> RefUnwindSafe for BasicDirectedGraph<K, V>

§

impl<K, V> Send for BasicDirectedGraph<K, V>
where K: Send, V: Send,

§

impl<K, V> Sync for BasicDirectedGraph<K, V>
where K: Sync, V: Sync,

§

impl<K, V> Unpin for BasicDirectedGraph<K, V>
where K: Unpin, V: Unpin,

§

impl<K, V> UnwindSafe for BasicDirectedGraph<K, V>
where K: 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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

Source§

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

Source§

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.