코드 14-1
from heapq import heappush, heappop
class MinPriorityQueue:
def __init__(self):
self.heap = []
def push(self, item):
heappush(self.heap, item)
def pop(self):
return heappop(self.heap)
class ShortestPath:
def __init__(self, s, distance, p):
self.source = s
self.distance = distance
self.p = p
def print_shortest_path(self, dest):
if self.source == dest:
print(dest, end=" ")
return
if sp.p[dest] != None:
self.print_shortest_path(self.p[dest])
else:
print("There is no path")
return
print(dest, end=" ")