[][src]Struct toposort_scc::ArenaGraph

pub struct ArenaGraph<'a, T, A: ArenaBehavior> { /* fields omitted */ }

An adjacency-list-based graph data structure wrapping an Arena from the id-arena crate.

Stores graph vertices as lists of incoming and outgoing edges by their Id in the graph.

Implementations

impl<'a, T, A: ArenaBehavior> ArenaGraph<'a, T, A>[src]

pub fn from_graph<F>(g: &'a Arena<T, A>, f: F) -> ArenaGraph<'a, T, A> where
    F: FnMut(ArenaGraphBuilder<'_, 'a, T, A>, &T), 
[src]

Create a new graph from an existing Arena-based graph-like data structure

The given closure will be called once for every element of g, with an ArenaGraphBuilder instance so that edges can be easily added.

pub fn arena_id(&self) -> u32[src]

Returns the id of the arena this graph belongs to

pub fn as_index_graph(&self) -> &IndexGraph[src]

Returns a reference to the underlying IndexGraph

pub fn into_index_graph(self) -> IndexGraph[src]

Returns the underlying IndexGraph

pub fn toposort_or_scc(self) -> Result<Vec<A::Id>, Vec<Vec<A::Id>>>[src]

Perform topological sort or find strongly connected components

If the graph contains no cycles, finds the topological ordering of this graph using Kahn's algorithm and returns it as Ok(sorted).

If the graph contains cycles, finds the strongly connected components of this graph using Kosaraju's algorithm and returns them as Err(cycles).

Trait Implementations

impl<'a, T: Clone, A: Clone + ArenaBehavior> Clone for ArenaGraph<'a, T, A>[src]

impl<'a, T: Debug, A: Debug + ArenaBehavior> Debug for ArenaGraph<'a, T, A>[src]

impl<'_, T, A: ArenaBehavior> Index<<A as ArenaBehavior>::Id> for ArenaGraph<'_, T, A>[src]

type Output = Vertex

The returned type after indexing.

Auto Trait Implementations

impl<'a, T, A> RefUnwindSafe for ArenaGraph<'a, T, A> where
    T: RefUnwindSafe

impl<'a, T, A> Send for ArenaGraph<'a, T, A> where
    T: Sync

impl<'a, T, A> Sync for ArenaGraph<'a, T, A> where
    T: Sync

impl<'a, T, A> Unpin for ArenaGraph<'a, T, A>

impl<'a, T, A> UnwindSafe for ArenaGraph<'a, T, A> where
    T: RefUnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.