Bellman Ford algorithm code not working

Here’s the link to my code

hello @Prankur-Tewari-2574939259288733
what issue u r getting?

sir basically my relaxation loop for every edge is working only once so my vertext distances are not only getting updated
for(int i=0;i<n-1;i++){
for(int j=0;j<m;j++){
int from,to,weight;
from=edges[i][0];to=edges[i][1];weight=edges[i][2];
if(dist[from]!=INT_MAX and dist[to]>(dist[from]+weight)){
dist[to]=dist[from]+weight;
cout<<“1”;
}
}
}
for ex if the graph is
3 3
1 2 4
1 3 5
3 2 -7
weight of the vertexes should be after relaxation
1–>0
2–>4
3–>-2
but my vertex are not getting relaxed

print ur edge vector , it is printing only single edge

that i have recognised sir,but why it is not working
for(auto x:edges)

image
bro remove this semicolon

sorry sir for such a stupid thing :grimacing: :grimacing: :grimacing:

image
me after seeing that ;(semicolon) :rofl::rofl::rofl::rofl:

1 Like

:rofl: :rofl: :rofl: :rofl:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.