does this graph have two parallel edges?
(&mut self, graph: &dyn IGraph)
| 71 | |
| 72 | // does this graph have two parallel edges? |
| 73 | fn has_parallel_edges(&mut self, graph: &dyn IGraph) -> bool { |
| 74 | self.marked.fill(false); |
| 75 | |
| 76 | for v in 0..graph.V() { |
| 77 | for &w in graph.adj(v) { |
| 78 | if self.marked[w] { |
| 79 | let mut cycle = Stack::default(); |
| 80 | cycle.push(v); |
| 81 | cycle.push(w); |
| 82 | cycle.push(v); |
| 83 | self.cycle = Some(cycle); |
| 84 | return true; |
| 85 | } |
| 86 | self.marked[w] = true; |
| 87 | } |
| 88 | |
| 89 | // reset so marked[v] = false for all v |
| 90 | self.marked.fill(false); |
| 91 | } |
| 92 | |
| 93 | false |
| 94 | } |
| 95 | } |