File tree Expand file tree Collapse file tree 1 file changed +2
-2
lines changed
Ch07. Graphs and Graph Algorithms/Dijkstras algorithm Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ def deleteMin(self):
2929 def percDown (self , index ):
3030 while index * 2 <= self .size :
3131 min_index = self .getMinIndex (index )
32- if self .queue [index ].weight < self .queue [min_index ].weight :
32+ if self .queue [index ].weight > self .queue [min_index ].weight :
3333 tmp = self .queue [index ]
3434 self .queue [index ] = self .queue [min_index ]
3535 self .queue [min_index ] = tmp
@@ -39,7 +39,7 @@ def getMinIndex(self, index):
3939 if index * 2 + 1 > self .size :
4040 return index * 2
4141 else :
42- if self .queue [index * 2 ].weight < self .queue [index * 2 + 1 ].weight :
42+ if self .queue [index * 2 ].weight <= self .queue [index * 2 + 1 ].weight :
4343 return index * 2
4444 else :
4545 return index * 2 + 1
You can’t perform that action at this time.
0 commit comments