(g: &dyn IGraph)
| 15 | |
| 16 | impl Cycle { |
| 17 | pub fn new(g: &dyn IGraph) -> Self { |
| 18 | let mut cycle = Self { |
| 19 | marked: vec![false; g.V()], |
| 20 | cycle: None, |
| 21 | edge_to: vec![0; g.V()], |
| 22 | }; |
| 23 | |
| 24 | if !cycle.has_parallel_edges(g) { |
| 25 | for s in 0..g.V() { |
| 26 | if !cycle.marked[s] { |
| 27 | cycle.dfs(g, s, s); |
| 28 | } |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | cycle |
| 33 | } |
| 34 | |
| 35 | /// Returns true if the graph G has a cycle. |
| 36 | pub fn has_cycle(&self) -> bool { |
nothing calls this directly
no test coverage detected