Skip to content

Commit 32d8baf

Browse files
authored
Merge pull request #78 from Ujwal200707/main
Fix loop range in negative weight cycle detection
2 parents b7022bd + e698859 commit 32d8baf

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

07_Graph/Bellman Ford Algorithm/Detect Negative Weight Cycle in Graphs - Bellman Ford Algorithm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def isNegativeWeightCycle(self, n, edges):
77
dist = [2**31] * n
88
dist[0] = 0
99

10-
for i in range(n):
10+
for i in range(n - 1):
1111
for j in range(len(edges)):
1212
frm = edges[j][0]
1313
to = edges[j][1]
@@ -57,4 +57,4 @@ def isNegativeWeightCycle(self, n, edges):
5757
5858
# Time: O(N * E * log(E))
5959
# Space: O(N * E)
60-
'''
60+
'''

0 commit comments

Comments
 (0)