MCPcopy Create free account
hub / github.com/douchuan/algorithm / dfs_ewd

Method dfs_ewd

src/graph/directed/order.rs:67–81  ·  view source on GitHub ↗

run DFS in edge-weighted digraph G from vertex v and compute preorder/postorder

(&mut self, graph: &dyn IEWDigraph, v: usize)

Source from the content-addressed store, hash-verified

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> {

Callers

nothing calls this directly

Calls 3

pushMethod · 0.80
toMethod · 0.80
adjMethod · 0.45

Tested by

no test coverage detected