Advertisement
keverman

Depth First Search

May 11th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.19 KB | None | 0 0
  1. void dfs(int from, std::vector<bool> &visited)
  2. {
  3.     visited[from] = true;
  4.  
  5.     // do something
  6.  
  7.     for(int &to : edges[from])
  8.         if(!visited[to])
  9.             dfs(to, visited);
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement