| 13 | } |
| 14 | |
| 15 | bool dfs(vector<int> vec[], vector<bool> &visited, vector<bool> &recst, int source) |
| 16 | { |
| 17 | visited[source] = true; |
| 18 | recst[source] = true; |
| 19 | for (int i = 0; i < vec[source].size(); i++) |
| 20 | { |
| 21 | int adjacent = vec[source][i]; |
| 22 | if (visited[adjacent] == false) |
| 23 | { |
| 24 | if (dfs(vec, visited, recst, adjacent) == true) |
| 25 | { |
| 26 | return true; |
| 27 | } |
| 28 | } |
| 29 | else if (visited[adjacent] == true && recst[adjacent] == true) |
| 30 | { |
| 31 | return true; |
| 32 | } |
| 33 | } |
| 34 | recst[source] = false; |
| 35 | return false; |
| 36 | } |
| 37 | |
| 38 | bool dfs_rec(vector<int> vec[], int v) |
| 39 | { |