[Python] One-pass Dijkstra with PriorityQueue, no extra DP
\n    def countRestrictedPaths(self, n: int, edges: List[List[int]]) -> int:\n        adj = [dict() for i in range(n + 1)]\n        for u, v, wgt in edges:\n   
```\n    def countRestrictedPaths(self, n: int, edges: List[List[int]]) -> int:\n        adj = [dict() for i in range(n + 1)]\n        for u, v, wgt in edges:\n            adj[u][v] = wgt\n            adj[v][u] = wgt\n        # Dijkstra\'s algorithm\n        dist = [float(\'inf\') for _ in range(n)] + [0]\n        num_res_paths = [0 for _ in range(n)] + [1]\n        Q = PriorityQueue()\n        Q.put((0, n))\n        visited = [False for i in range(n + 1)]\n        while Q:\n            min_dist, u = Q.get()\n            if visited[u]:\n                continue\n            visited[u] = True\n            if u == 1:\n                break\n            for v in adj[u]:\n                if not visited[v]:\n                    alt = dist[u] + adj[u][v]\n                    if alt < dist[v]:\n                        dist[v] = alt\n                        Q.put((alt, v))\n                    if dist[v] > dist[u]:\n                        num_res_paths[v] = (num_res_paths[v] + num_res_paths[u]) % (10 ** 9 + 7)\n        return num_res_paths[1]\n```
[]