Simple Python Solution (Dijkstra algo)
\'\'\'\n\n    def countPaths(self, n: int, roads: List[List[int]]) -> int:\n        \n\t\t//creating adgecency matrix\n        mat = [[0] * n for _ in range(n)]
\'\'\'\n\n    def countPaths(self, n: int, roads: List[List[int]]) -> int:\n        \n\t\t//creating adgecency matrix\n        mat = [[0] * n for _ in range(n)]\n        for i,j,k in roads:\n            mat[i][j]= mat[j][i] = k\n       \n\t\t// An array for keeping track of distance of last node from each node\n        d = [float(\'inf\')] * (n)\n        d[-1] = 0\n \t\t\n\t\t//count matrix for counting the no of paths from each node\n        c = [1] * n\n\t\t\n        for i in reversed(range(n-1)):\n            incount = 0\n            for j in range(i,n):\n                if mat[i][j] > 0:\n                    if mat[i][j] + d[j] < d[i]:\n\t\t\t\t\t\t//updating the distace of ith node\n                        d[i] = mat[i][j] + d[j]\n\t\t\t\t\t\t//initializing the incount by the no of paths from node j\n                        incount =  c[j]\n\t\t\t\t\t\t\n                    elif mat[i][j] + d[j] == d[i]:\n\t\t\t\t\t\t//updating the value of incount for samllest distance\n                        incount +=  c[j]\n            \n\t\t\tc[i] = incount\n\t\t\t\n        return c[0] % 1000000007\n            \n                \n        \n\n        \n\'\'\'
['Python']