Search
Graph Search🔗
DFS🔗
const UNVISITED = -1;
const VISITED = 1;
vector<int> dfs_num; // initially all set to unvisited
void dfs(int u) {
dfs_num[u] = VISITED;
for(auto v:adj[u]) {
if(dfs_num[v] == UNVISITED)
dfs(v);
} }