MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / dfs

Function dfs

Trees/LCA.cpp:11–24  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9vector<vector<int>> up;
10
11void dfs(int v, int p)
12{
13 tin[v] = ++timer;
14 up[v][0] = p;
15 for (int i = 1; i <= l; ++i)
16 up[v][i] = up[up[v][i-1]][i-1];
17
18 for (int u : adj[v]) {
19 if (u != p)
20 dfs(u, v);
21 }
22
23 tout[v] = ++timer;
24}
25
26bool is_ancestor(int u, int v)
27{

Callers 3

dfsMethod · 0.70
addOneRowMethod · 0.70
preprocessFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected