pub struct DirectedGraph { /* private fields */ }Expand description
A directed graph with n nodes, represented as an adjacency list.
Implementations§
Source§impl DirectedGraph
impl DirectedGraph
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Return the number of nodes.
Sourcepub fn out_degree(&self, u: usize) -> usize
pub fn out_degree(&self, u: usize) -> usize
Return the out-degree of node u.
Sourcepub fn successors(&self, u: usize) -> &[usize]
pub fn successors(&self, u: usize) -> &[usize]
Iterate over the successors of u.
Sourcepub fn topological_sort(&self) -> Option<Vec<usize>>
pub fn topological_sort(&self) -> Option<Vec<usize>>
Compute a topological ordering using Kahn’s algorithm.
Returns None if the graph contains a cycle.
Sourcepub fn strongly_connected_components(&self) -> Vec<Vec<usize>>
pub fn strongly_connected_components(&self) -> Vec<Vec<usize>>
Compute strongly connected components using Kosaraju’s algorithm.
Trait Implementations§
Source§impl Clone for DirectedGraph
impl Clone for DirectedGraph
Source§fn clone(&self) -> DirectedGraph
fn clone(&self) -> DirectedGraph
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for DirectedGraph
impl RefUnwindSafe for DirectedGraph
impl Send for DirectedGraph
impl Sync for DirectedGraph
impl Unpin for DirectedGraph
impl UnsafeUnpin for DirectedGraph
impl UnwindSafe for DirectedGraph
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more