MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / push

Method push

graphs/minimum_spanning_tree_prims2.py:101–106  ·  view source on GitHub ↗
(self, elem: T, weight: int)

Source from the content-addressed store, hash-verified

99 return self.elements == 0
100
101 def push(self, elem: T, weight: int) -> None:
102 # Add an element with given priority to the queue
103 self.heap.append((elem, weight))
104 self.position_map[elem] = self.elements
105 self.elements += 1
106 self._bubble_up(elem)
107
108 def extract_min(self) -> T:
109 # Remove and return the element with lowest weight (highest priority)

Callers 1

prims_algoFunction · 0.95

Calls 2

_bubble_upMethod · 0.95
appendMethod · 0.45

Tested by

no test coverage detected