Algorithms, Programming, Interview, Python.
!= math.inf: get_route(prev, i, route) print(f'Path ({source} —> {i}): Minimum cost = {dist[i]}, Route = {route}') route.clear() if __name__ == '__main__': n = 5 edges = [ (0, 1, 10), (0, 4, 3), (1, 2, 2), (1, 4, 4), (2, 3, 9), (3, 2, 7), (4, 1, 1), (4, 2, 8), (4, 3, 2) ] graph = Graph(edges, n)