| 53 | } |
| 54 | |
| 55 | int main() |
| 56 | { |
| 57 | int v; |
| 58 | v = 6; |
| 59 | vector<int> vec[v]; |
| 60 | |
| 61 | // adding edges from this point |
| 62 | |
| 63 | // add_edge(vec, 0, 1); |
| 64 | // add_edge(vec, 1, 2); |
| 65 | // add_edge(vec, 2, 3); |
| 66 | // add_edge(vec, 2, 4); |
| 67 | // add_edge(vec, 4, 5); |
| 68 | // add_edge(vec, 5, 1); |
| 69 | |
| 70 | add_edge(vec, 0, 1); |
| 71 | add_edge(vec, 2, 3); |
| 72 | add_edge(vec, 3, 4); |
| 73 | add_edge(vec, 4, 5); |
| 74 | add_edge(vec, 5, 1); |
| 75 | |
| 76 | if (dfs_rec(vec, v)) |
| 77 | { |
| 78 | cout << "There is a cycle in the graph!!" << endl; |
| 79 | } |
| 80 | else |
| 81 | { |
| 82 | cout << "There isnt a cycle in the graph!!" << endl; |
| 83 | } |
| 84 | return 0; |
| 85 | } |