Algorithms, Programming, Interview, Python.
in edges: self.adjList[source].append((dest, weight)) def get_route(prev, i, route): if i >= 0: get_route(prev, prev[i], route) route.append(i) def dijkstra(graph, source, n): pq = [] heappush(pq, Node(source)) dist = [math.inf] * n dist[source] = 0 processed = [False] * n processed[source] = True