MCPcopy Create free account
hub / github.com/easy-graph/Easy-Graph / push

Method push

easygraph/utils/mapped_queue.py:72–83  ·  view source on GitHub ↗

Add an element to the queue.

(self, elt)

Source from the content-addressed store, hash-verified

70 raise AssertionError("Heap contains duplicate elements")
71
72 def push(self, elt):
73 """Add an element to the queue."""
74 # If element is already in queue, do nothing
75 if elt in self.d:
76 return False
77 # Add element to heap and dict
78 pos = len(self.h)
79 self.h.append(elt)
80 self.d[elt] = pos
81 # Restore invariant by sifting down
82 self._siftdown(pos)
83 return True
84
85 def pop(self):
86 """Remove and return the smallest element in the queue."""

Callers 2

prim_mst_edgesFunction · 0.80

Calls 2

_siftdownMethod · 0.95
appendMethod · 0.80

Tested by

no test coverage detected