Python Simple Dijkstra
\nclass Solution:\n    def maximalPathQuality(self, values: List[int], edges: List[List[int]], maxTime: int) -> int:\n        graph = defaultdict(dict) # dict o
```\nclass Solution:\n    def maximalPathQuality(self, values: List[int], edges: List[List[int]], maxTime: int) -> int:\n        graph = defaultdict(dict) # dict of dict to store weights\n        pq = []\n        res = 0\n\n        heapq.heappush(pq, (-values[0], 0, 0, {0})) # quality, time, index, nodes\n\n        for i in range(len(edges)):\n            u, v, w = edges[i]\n            graph[u][v] = w\n            graph[v][u] = w\n\n        while pq:\n            top = heapq.heappop(pq)\n            u = top[2]\n            if u == 0:\n                res = max(res, -top[0])\n            for v in graph[u]:\n                time = top[1] + graph[u][v]\n                nodes = top[3].copy()\n                if time <= maxTime:\n                    if v in nodes:\n                        heapq.heappush(pq, (top[0], time, v, nodes))\n                    else:\n                        nodes.add(v)\n                        heapq.heappush(pq, (top[0] - values[v], time, v, nodes))\n\n        return res\n```
[]