I have an adjacency matrix for a graph. And I need to output all the cycles in this graph. How can I do this using dfs?
void al_dfs(int tmp_vertex,int** Graph,vector<int>& color,int number,vector<int>& result){
color[tmp_vertex] = 1;
for(int i = 0;i<number;i++){
if((color[i] == 0)){ al_dfs(i,Graph,color,number,result); result.push_back(i); };
if((color[i] == 1)){
for(int i = 0;i< result.size();i++) cout << result[i] << " ";
}
}
color[tmp_vertex] = 2;
}
I wrote a small function, but I understand that there is a lot of things that have not been completed yet.