private bool[] onStack; // vertex on recursive call stack public DirectedCycle(Digraph G) { onStack = new bool[G.v()]; edgeTo = new int[G.v()]; mark = new bool[G.v()]; for (int v = 0; v < G.v(); v++) { if (!mark[v]) { dfs(G, v); } } }
public DepthFirstOrder(Digraph G) { pre = new Queue <object>(); post = new Queue <object>(); reversePost = new Stack <object>(); mark = new bool[G.v()]; for (int v = 0; v < G.v(); v++) { if (!mark[v]) { dfs(G, v); } } }
public DirectedDFS(Digraph G, IEnumerable <int> sources) { mark = new bool[G.v()]; foreach (int s in sources) { if (!mark[s]) { dfs(G, s); } } }
public DirectedDFS(Digraph G, int s) { mark = new bool[G.v()]; dfs(G, s); }