i am getting wrong answer through this code. please check my code and help me finding the mistake
here is my code
DIJKSTRA'S ALGORITHM
@aditikandhway
Replace line 50-54 by
for(int i=1;i<=nodes;i++){ if(i == src) continue; auto f = dis.find(i); if(f != dis.end()&&dis[i]!=INT_MAX){ cout<<dis[i]<<" “; } else{ cout<<”-1"<<" "; } }
We are printing like this because in map order of elements inserted can be different(shuffled).