MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / par

Method par

graphs/dijkstra_algorithm.py:156–169  ·  view source on GitHub ↗

Returns the index of parent Examples: >>> priority_queue_test = PriorityQueue() >>> priority_queue_test.par(1) 0 >>> priority_queue_test.par(2) 1 >>> priority_queue_test.par(4) 2

(self, i)

Source from the content-addressed store, hash-verified

154 return 2 * i + 2
155
156 def par(self, i):
157 """
158 Returns the index of parent
159
160 Examples:
161 >>> priority_queue_test = PriorityQueue()
162 >>> priority_queue_test.par(1)
163 0
164 >>> priority_queue_test.par(2)
165 1
166 >>> priority_queue_test.par(4)
167 2
168 """
169 return math.floor(i / 2)
170
171 def swap(self, i, j):
172 """

Callers 1

decrease_keyMethod · 0.95

Calls 1

floorMethod · 0.80

Tested by

no test coverage detected