Easy Video Walkthrough
Video Walkthrough\n\nclass Solution:\n    def countRestrictedPaths(self, n: int, edges: List[List[int]]) -> int:\n        G = [[] for _ in range(n+1)]\n        
[Video Walkthrough](https://youtu.be/hXrcIbzaVHQ)\n```\nclass Solution:\n    def countRestrictedPaths(self, n: int, edges: List[List[int]]) -> int:\n        G = [[] for _ in range(n+1)]\n        SRC = n\n        pq = [(0,SRC)]\n        \n        for u,v,w in edges: G[u].append((v,w)), G[v].append((u,w))\n        distToLastNode = [float(\'inf\')] * (n+1)\n    \n        while pq:\n            w_u, u = heapq.heappop(pq)\n            if w_u > distToLastNode[u]: continue\n            distToLastNode[u] = w_u\n            for v, w_v in G[u]:\n                if w_u + w_v < distToLastNode[v]:\n                    distToLastNode[v] = w_u + w_v\n                    heapq.heappush(pq,(w_u + w_v, v))\n        D = [0] * (n+1)\n        D[n] = 1\n        def dfs(u):\n            if D[u]: return D[u]\n            for v,_ in G[u]:\n                if distToLastNode[v] < distToLastNode[u]:\n                    D[u] += dfs(v)\n            return D[u]        \n        return dfs(1) % ( 10 ** 9 + 7)\n```\n        \n
['Python']