Graph

Struct Graph 

Source
pub struct Graph<T> { /* private fields */ }
Expand description

The graph structure, containing a list of nodes.

Implementations§

Source§

impl<T> Graph<T>

Source

pub fn new() -> Self

Creates a new, empty graph.

Source

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

Adds a node with the given value to the graph. Returns the index of the new node.

Source

pub fn add_edge(&self, from_index: usize, to_index: usize)

Adds an edge from the node at from_index to the node at to_index.

Source

pub fn get_node_value(&self, index: usize) -> Option<T>
where T: Clone,

Returns a clone of the value of the node at the given index.

Source

pub fn neighbors_of(&self, index: usize) -> Option<Vec<T>>
where T: Clone,

Returns a vector of clones of the values of the neighbors of the node at the given index.

Trait Implementations§

Source§

impl<T> Drop for Graph<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Graph<T>

§

impl<T> RefUnwindSafe for Graph<T>

§

impl<T> Send for Graph<T>
where T: Send,

§

impl<T> Sync for Graph<T>
where T: Send,

§

impl<T> Unpin for Graph<T>

§

impl<T> UnwindSafe for Graph<T>

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

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

Performs the conversion.