Algorithms, Programming, Interview, Python.
prev = [-1] * n while pq: node = heappop(pq) u = node.vertex for (v, weight) in graph.adjList[u]: if not processed[v] and (dist[u] + weight) < dist[v]: dist[v] = dist[u] + weight prev[v] = u heappush(pq, Node(v, dist[v])) processed[u] = True route = [] for i in range(n): if i != source and dist[i]