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