Skip to main content

DiGraph

Struct DiGraph 

Source
pub struct DiGraph<L = ()> { /* private fields */ }
Expand description

Directed graph.

Implementations§

Source§

impl DiGraph<()>

Source

pub fn add_vertex(&mut self) -> VertexId

Adds a new vertex.

Source§

impl<L: PartialEq> DiGraph<L>

Source

pub fn vertex(&self, label: &L) -> Option<VertexId>

Returns the identifier of a vertex having given label.

Source§

impl<L: Copy> DiGraph<L>

Source

pub fn copied_labels(&self, vertices: impl AsRef<[VertexId]>) -> Vec<L>

Copies and returns all labels associated with the given vertices.

Source§

impl<L: Clone> DiGraph<L>

Source

pub fn cloned_labels(&self, vertices: impl AsRef<[VertexId]>) -> Vec<L>

Clones and returns all labels associated with the given vertices.

Source§

impl<L> DiGraph<L>

Source

pub const fn new() -> Self

Creates an empty graph.

Source

pub fn add_edge(&mut self, source: VertexId, sink: VertexId) -> bool

Creates a directed edge between vertices.

Source

pub fn labels(&self, vertices: &[VertexId]) -> impl Iterator<Item = &L>

Returns iterator over labels for given vertices.

Source

pub fn is_acyclic(&self) -> bool

Returns true when a graph is acyclic.

Source

pub fn cycle(&self) -> Option<Vec<VertexId>>

Returns the first found cycle.

Source

pub fn sort(&self) -> Result<Vec<VertexId>, Vec<VertexId>>

Returns topologically sorted vertices when the graph is acyclic.

§Errors

When the graph is not acyclic, returns the first found cycle.

Trait Implementations§

Source§

impl<L: Debug> Debug for DiGraph<L>

Source§

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

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

impl<L> Default for DiGraph<L>

Source§

fn default() -> Self

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

impl<L> LabeledVertex<L> for DiGraph<L>

Source§

fn add_vertex(&mut self, label: L) -> VertexId

Adds a new vertex with label.

Auto Trait Implementations§

§

impl<L> Forget for DiGraph<L>

§

impl<L> Freeze for DiGraph<L>

§

impl<L> Move for DiGraph<L>

§

impl<L> RefUnwindSafe for DiGraph<L>
where L: RefUnwindSafe,

§

impl<L> Send for DiGraph<L>
where L: Send, RawVecInner: Send,

§

impl<L> Sync for DiGraph<L>
where L: Sync, RawVecInner: Sync,

§

impl<L> Unpin for DiGraph<L>
where L: Unpin, *const u8 is !null: Unpin,

§

impl<L> UnsafeUnpin for DiGraph<L>

§

impl<L> UnwindSafe for DiGraph<L>
where RawVecInner: UnwindSafe, L: 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.