Created
December 23, 2015 11:19
-
-
Save CsengerG/231b9d4e5b48ed36d1e3 to your computer and use it in GitHub Desktop.
Depth-first search
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <bits/stdc++.h> | |
| using namespace std; | |
| const int maxn=100000; | |
| vector<int> g[maxn]; | |
| bool explored[maxn]; | |
| void dfs(int v){ | |
| explored[v]=true; | |
| for(int i=0;i<g[v].size();++i){ | |
| int neighbor=g[v][i]; | |
| if(explored[neighbor]==false) dfs(neighbor); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment