pub trait TopologicalGraphAlgorithms<N, W>: GraphView<N, W> {
// Required methods
fn find_cycle(&self) -> Result<Option<Vec<usize>>, GraphError>;
fn has_cycle(&self) -> Result<bool, GraphError>;
fn topological_sort(&self) -> Result<Option<Vec<usize>>, GraphError>;
}Required Methods§
Sourcefn find_cycle(&self) -> Result<Option<Vec<usize>>, GraphError>
fn find_cycle(&self) -> Result<Option<Vec<usize>>, GraphError>
Finds a single cycle in the graph and returns the path of nodes that form it.
Sourcefn has_cycle(&self) -> Result<bool, GraphError>
fn has_cycle(&self) -> Result<bool, GraphError>
Checks if the graph contains any directed cycles.
This method should be implemented as a simple call to self.find_cycle().is_some().
Sourcefn topological_sort(&self) -> Result<Option<Vec<usize>>, GraphError>
fn topological_sort(&self) -> Result<Option<Vec<usize>>, GraphError>
Computes a topological sort of the graph, if it is a Directed Acyclic Graph (DAG).
Returns None if the graph contains a cycle.