Advertisement
GerONSo

Untitled

Jul 31st, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. while(!q.empty()) {
  2. int cur = q.front();
  3. q.pop();
  4. for(int i = 0; i < n; i++) {
  5. if(a[cur][i] != -1) {
  6. d[i] = min(d[i], d[cur] + a[cur][i]);
  7. if(!used[i]) {
  8. d[i] = min(d[i], d[cur] + a[cur][i]);
  9. q.push(i);
  10. used[i] = 1;
  11. }
  12. }
  13. }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement