heapq python - how to modify values for which heap is sorted
问题 I transform an empty list called UNVISITED into a heap, such that: UNVISITED = [] heapq.heappush(UNVISITED, (a.f, a)) The object a that I push, which is instantiated from a class, has the following fields: class UNVISITEDNode(): def __init__(self, value1, value2 , value3, value4, value5): self.q = value1 self.h = value2 self.g = value3 self.f = value4 self.p = value5 Throughout my algorithm, I keep modifying any valueX from the object already in the heap whenever is needed like: for i in