MCPcopy Index your code
hub / github.com/subbarayudu-j/TheAlgorithms-Python / min_heapify

Method min_heapify

Graphs/dijkstra_algorithm.py:21–32  ·  view source on GitHub ↗
(self, idx)

Source from the content-addressed store, hash-verified

19 return self.cur_size == 0
20
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]:
25 smallest = lc
26 else:
27 smallest = idx
28 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)
32 self.min_heapify(smallest)
33
34 def insert(self, tup):
35 # Inserts a node into the Priority Queue

Callers 1

extract_minMethod · 0.95

Calls 3

leftMethod · 0.95
rightMethod · 0.95
swapMethod · 0.95

Tested by

no test coverage detected