clean short code using heap in python
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution:\n    def countRestrictedPaths(self, n: int, edges: List[List[int]]) -> int:\n\n        adjl = {}\n        for edge in edges:\n            if edge[0] not in adjl:\n                adjl[edge[0]] = { edge[1] : edge[2] }\n            else:\n                adjl[edge[0]][edge[1]] = edge[2]\n            if edge[1] not in adjl:\n                adjl[edge[1]] = { edge[0] : edge[2] }\n            else:\n                adjl[edge[1]][edge[0]] = edge[2]\n        shortest  = {}\n        minHeap = []\n        heapq.heappush(minHeap,(0,n))\n        while minHeap and len(shortest)!=n:\n            k=heapq.heappop(minHeap)\n            if k[1] in shortest:\n                continue\n            shortest[k[1]]=k[0]\n\n            for neighbour,weight in adjl[k[1]].items():\n                if neighbour not in shortest:\n                    heapq.heappush(minHeap,(weight + k[0],neighbour)) \n        no_of_paths = [0]*n\n        no_of_paths[n-1] = 1\n        heap = []\n        visited = set()\n        for i in range(n):\n            heapq.heappush(heap,(shortest[i+1],i+1))\n        while heap:\n            p = heapq.heappop(heap)\n            for k,_ in adjl[p[1]].items():\n                if p[0]<shortest[k]:\n                    no_of_paths[k-1] += no_of_paths[p[1]-1] \n        return no_of_paths[0]%(10**9+7)\n\n        \n```
['Dynamic Programming', 'Graph', 'Topological Sort', 'Heap (Priority Queue)', 'Shortest Path', 'Python3']