run DFS in edge-weighted digraph G from vertex v and compute preorder/postorder
(&mut self, graph: &dyn IEWDigraph, v: usize)
| 65 | |
| 66 | /// run DFS in edge-weighted digraph G from vertex v and compute preorder/postorder |
| 67 | fn dfs_ewd(&mut self, graph: &dyn IEWDigraph, v: usize) { |
| 68 | self.marked[v] = true; |
| 69 | self.pre[v] = self.pre_counter; |
| 70 | self.pre_counter += 1; |
| 71 | self.pre_order.push(v); |
| 72 | for e in graph.adj(v) { |
| 73 | let w = e.to(); |
| 74 | if !self.marked[w] { |
| 75 | self.dfs_ewd(graph, w); |
| 76 | } |
| 77 | } |
| 78 | self.post_order.push(v); |
| 79 | self.post[v] = self.post_counter; |
| 80 | self.post_counter += 1; |
| 81 | } |
| 82 | |
| 83 | /// check that pre() and post() are consistent with pre[v] and post[v] |
| 84 | pub fn check(&self) -> Result<(), &'static str> { |