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

Method remove

easygraph/utils/mapped_queue.py:115–134  ·  view source on GitHub ↗

Remove an element from the queue.

(self, elt)

Source from the content-addressed store, hash-verified

113 self._siftdown(pos)
114
115 def remove(self, elt):
116 """Remove an element from the queue."""
117 # Find and remove element
118 try:
119 pos = self.d[elt]
120 del self.d[elt]
121 except KeyError:
122 # Not in queue
123 raise
124 # If elt is last item, remove and return
125 if pos == len(self.h) - 1:
126 self.h.pop()
127 return
128 # Replace elt with last element
129 last = self.h.pop()
130 self.h[pos] = last
131 self.d[last] = pos
132 # Restore invariant by sifting up, then down
133 pos = self._siftup(pos)
134 self._siftdown(pos)
135
136 def _siftup(self, pos):
137 """Move element at pos down to a leaf by repeatedly moving the smaller

Callers 12

WS_RandomFunction · 0.80
PrimFunction · 0.80
Rough_CoresFunction · 0.80
extend_subgraphFunction · 0.80
random_extend_subgraphFunction · 0.80
ICCFunction · 0.80
BICCFunction · 0.80
AP_BICCFunction · 0.80
maxBlockFastFunction · 0.80
testMethod · 0.80
test_graphMethod · 0.80

Calls 3

_siftupMethod · 0.95
_siftdownMethod · 0.95
popMethod · 0.80

Tested by 2

testMethod · 0.64
test_graphMethod · 0.64