We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 895dffb commit 39086dcCopy full SHA for 39086dc
1 file changed
graphs/dijkstra_algorithm.py
@@ -21,11 +21,11 @@ def is_empty(self):
21
def min_heapify(self, idx):
22
lc = self.left(idx)
23
rc = self.right(idx)
24
- if lc < self.cur_size and self.array(lc)[0] < self.array(idx)[0]:
+ if lc < self.cur_size and self.array[lc][0] < self.array[idx][0]:
25
smallest = lc
26
else:
27
smallest = idx
28
- if rc < self.cur_size and self.array(rc)[0] < self.array(smallest)[0]:
+ if rc < self.cur_size and self.array[rc][0] < self.array[smallest][0]:
29
smallest = rc
30
if smallest != idx:
31
self.swap(idx, smallest)
@@ -43,7 +43,7 @@ def extract_min(self):
43
min_node = self.array[0][1]
44
self.array[0] = self.array[self.cur_size - 1]
45
self.cur_size -= 1
46
- self.min_heapify(1)
+ self.min_heapify(0)
47
del self.pos[min_node]
48
return min_node
49
0 commit comments