Closed nprakhar0411 closed 4 years ago
The algorithm provided in DepthFirstSearch.cpp assumes the the graph is connected and we traverse all vertices on a single call to vertex numbered 1. Correct way should be: for(int i = 1; i <= nodes; ++i){ if(!visited[i]){ dfs(i); } }
for(int i = 1; i <= nodes; ++i){
if(!visited[i]){
dfs(i);
}
The algorithm provided in DepthFirstSearch.cpp assumes the the graph is connected and we traverse all vertices on a single call to vertex numbered 1. Correct way should be:
for(int i = 1; i <= nodes; ++i){
if(!visited[i]){
dfs(i);
}
}