Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions graphs/dijkstra_algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ def is_empty(self):
def min_heapify(self, idx):
lc = self.left(idx)
rc = self.right(idx)
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]:
smallest = lc
else:
smallest = idx
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]:
smallest = rc
if smallest != idx:
self.swap(idx, smallest)
Expand All @@ -43,7 +43,7 @@ def extract_min(self):
min_node = self.array[0][1]
self.array[0] = self.array[self.cur_size - 1]
self.cur_size -= 1
self.min_heapify(1)
self.min_heapify(0)
del self.pos[min_node]
return min_node

Expand Down