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

Method dfs

src/graph/directed/order.rs:51–64  ·  view source on GitHub ↗

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

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

Source from the content-addressed store, hash-verified

49
50 /// run DFS in digraph G from vertex v and compute preorder/postorder
51 fn dfs(&mut self, graph: &dyn IGraph, v: usize) {
52 self.marked[v] = true;
53 self.pre[v] = self.pre_counter;
54 self.pre_counter += 1;
55 self.pre_order.push(v);
56 for &w in graph.adj(v) {
57 if !self.marked[w] {
58 self.dfs(graph, w);
59 }
60 }
61 self.post_order.push(v);
62 self.post[v] = self.post_counter;
63 self.post_counter += 1;
64 }
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) {

Callers

nothing calls this directly

Calls 2

pushMethod · 0.80
adjMethod · 0.45

Tested by

no test coverage detected