pub fn is_cyclic_directed<G>(g: G) -> bool
Expand description
[Generic] Return true
if the input directed graph contains a cycle.
This implementation is recursive; use toposort
if an alternative is needed.
§Arguments:
g
: a directed graph.
§Returns
true
: if the input graph contains a cycle.
false
: otherwise.
§Complexity
- Time complexity: O(|V| + |E|).
- Auxiliary space: O(|V|).
where |V| is the number of nodes and |E| is the number of edges.