[][src]Struct toposort_scc::IndexGraph

pub struct IndexGraph { /* fields omitted */ }

An adjacency-list-based graph data structure

Stores graph vertices as lists of incoming and outgoing edges by their index in the graph. No additional data is stored per vertex.

Implementations

impl IndexGraph[src]

pub fn with_vertices(len: usize) -> Self[src]

Create a new graph with len vertices and no edges

pub fn from_graph<T, F>(g: &[T], f: F) -> Self where
    F: FnMut(IndexGraphBuilder, &T), 
[src]

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

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

pub fn iter(&self) -> SliceIter<Vertex>[src]

Returns an iterator over the contained vertices

pub fn add_edge(&mut self, from: usize, to: usize)[src]

Add a new edge to the graph

This method does not check for duplicate edges.

pub fn transpose(&mut self)[src]

Transpose the graph

Changes the direction of all edges in the graph

pub fn toposort_or_scc(self) -> Result<Vec<usize>, Vec<Vec<usize>>>[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 Clone for IndexGraph[src]

impl Debug for IndexGraph[src]

impl Index<usize> for IndexGraph[src]

type Output = Vertex

The returned type after indexing.

impl<'g> IntoIterator for &'g IndexGraph[src]

type Item = &'g Vertex

The type of the elements being iterated over.

type IntoIter = SliceIter<'g, Vertex>

Which kind of iterator are we turning this into?

impl IntoIterator for IndexGraph[src]

type Item = Vertex

The type of the elements being iterated over.

type IntoIter = VecIntoIter<Vertex>

Which kind of iterator are we turning this into?

Auto Trait Implementations

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<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

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.