[−][src]Struct toposort_scc::IndexGraph
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]
F: FnMut(IndexGraphBuilder, &T),
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]
fn clone(&self) -> IndexGraph
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for IndexGraph
[src]
impl Index<usize> for IndexGraph
[src]
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?
fn into_iter(self) -> Self::IntoIter
[src]
impl IntoIterator for IndexGraph
[src]
Auto Trait Implementations
impl RefUnwindSafe for IndexGraph
impl Send for IndexGraph
impl Sync for IndexGraph
impl Unpin for IndexGraph
impl UnwindSafe for IndexGraph
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
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?
fn into_iter(self) -> I
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
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>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,