Skip to content

Commit da9e74b

Browse files
authored
Merge pull request cp-algorithms#1522 from aleksmish/patch-5
fix typo
2 parents 2b6905a + 2f29662 commit da9e74b

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/graph/bellman_ford.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ Due to the presence of a negative cycle, for $n$ iterations of the algorithm, th
201201
d[e.b] = max(-INF, d[e.a] + e.cost);
202202
```
203203

204-
The above implementation looks for a negative cycle reachable from some starting vertex $v$; however, the algorithm can be modified to just looking for any negative cycle in the graph. For this we need to put all the distance $d[i]$ to zero and not infinity — as if we are looking for the shortest path from all vertices simultaneously; the validity of the detection of a negative cycle is not affected.
204+
The above implementation looks for a negative cycle reachable from some starting vertex $v$; however, the algorithm can be modified to just look for any negative cycle in the graph. For this we need to put all the distance $d[i]$ to zero and not infinity — as if we are looking for the shortest path from all vertices simultaneously; the validity of the detection of a negative cycle is not affected.
205205

206206
For more on this topic — see separate article, [Finding a negative cycle in the graph](finding-negative-cycle-in-graph.md).
207207

0 commit comments

Comments
 (0)