Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Algorithm Implementation/Graphs/Depth-first search

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

In C++: /* Depth-first search running time is O(|E|+|V|) g - adjacency list used - bool array, to check if node is visited vector<vector<int>> g; vector<bool> used; void dfs(int v) { used[v] = true; // ... for (int &to:g[v]) { //... if(!used[to]) dfs(to); } }