def get_top_priority ( self ) : if self . is_empty ( ) : raise IndexError ( "Priority queue is empty." ) _ , _ , element = heapq . heappop ( self . pq ) if element in self . element_finder : del self . element_finder [ element ] return element
to print tht top element in queue in python
Pops the element that has the top ( smallest ) priority .
def get_top_priority(self):
        """Pops the element that has the top (smallest) priority.

        :returns: element with the top (smallest) priority.
        :raises: IndexError -- Priority queue is empty.

        """
        if self.is_empty():
            raise IndexError("Priority queue is empty.")
        _, _, element = heapq.heappop(self.pq)
        if element in self.element_finder:
            del self.element_finder[element]
        return element