MCPcopy Create free account
hub / github.com/Ayush7614/Daily-Coding-DS-ALGO-Practice / relax

Function relax

Algorithms/JohnsonAlgorithm.cpp:18–30  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16*/
17
18bool relax(int u, int v, int w, vector <int> &dist) {
19
20 // both vertices u and v are not visited from bellman source
21 if (dist[u] == INT_MAX && dist[v] == INT_MAX) {
22 return false;
23 }
24
25 if (dist[v] > dist[u] + w) {
26 dist[v] = dist[u] + w;
27 return true;
28 }
29 return false;
30}
31
32/* Bellman ford function to check negative cycle
33* v = no. of verties

Callers 1

bellman_fordFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected