Struct AdjacencyList

Source
pub struct AdjacencyList<T, M> { /* private fields */ }
Expand description

Represents a pointer bag design for an adjacency list graph representation. Nodes are identified by stable Vec indices for the lifetime of the graph.

Implementations§

Source§

impl<T, M> AdjacencyList<T, M>
where T: PartialEq,

Source

pub fn new() -> Self

Creates a new, empty graph

Source

pub fn add_node(&mut self, data: T) -> usize

Creates and adds a new vertex for the specified data

Creates and adds a new edge from an originating vertex to a destination vertex with an optional metadata element M such as a weight. Origin and destination arguments are positional for directed graphs.

Creates and adds a new undirected edge from one node to another node with an optional metadata element M such as a weight.

Source

pub fn get_node(&self, index: usize) -> Option<&Node<T, M>>

Returns a reference to a node for a given index.

Source

pub fn num_nodes(&self) -> usize

Returns the number of nodes in the graph

Returns the number of unique links in the graph

Source

pub fn nodes(&self) -> &Vec<Node<T, M>>

Returns an iterable collection over all vertices in the graph

Source

pub fn nodes_iter(&self) -> impl Iterator<Item = &Node<T, M>>

Returns an iterator over all vertices in the graph

Returns an iterator over all outgoing links for a given node

Returns an iterator over incoming links from a given node

Returns an iterator over all incoming links to a given node

Returns an iteratable collection over all links in the graph as { (u, (u → v)) | u ∈ V, (u → v) ∈ Adj[u] }

Returns an iterator over all links in the graph

Trait Implementations§

Source§

impl<T, M> Default for AdjacencyList<T, M>
where T: PartialEq,

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<T, M> Freeze for AdjacencyList<T, M>

§

impl<T, M> RefUnwindSafe for AdjacencyList<T, M>

§

impl<T, M> Send for AdjacencyList<T, M>
where T: Send, M: Send,

§

impl<T, M> Sync for AdjacencyList<T, M>
where T: Sync, M: Sync,

§

impl<T, M> Unpin for AdjacencyList<T, M>
where T: Unpin, M: Unpin,

§

impl<T, M> UnwindSafe for AdjacencyList<T, M>
where T: UnwindSafe, M: 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, 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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V