Java, basic minHeap Dijkstra with minor changes
Perform regular Dijkstra with some adjustments: \nadd one more ways[] array alongside to distance[] basic array.\nif there is an adjacent vertex with total time
Perform regular Dijkstra with some adjustments: \nadd one more ways[] array alongside to distance[] basic array.\nif there is an adjacent vertex with total time less than currne time + edge distance, then update best distance and go ahead as usual, by adding edge into minHeap\nif same time already exists, then we have come from another vertex, but with the same overall time, so let sum both approaches ways count.\n\n```\n    public int countPaths(int n, int[][] roads) {\n        final int mod = 1000000007;\n        int[][] adj = new int[n][n];\n        for(int[] road : roads){\n            adj[ road[0] ][ road[1] ] = road[2];\n            adj[ road[1] ][ road[0] ] = road[2];\n        }\n        \n        int[] time = new int[n], ways = new int[n];\n        Arrays.fill(time,1,n, Integer.MAX_VALUE);\n        ways[0]=1;\n       \n        Queue<int[]> q = new PriorityQueue<>((a,b)->a[1]-b[1]);\n        q.offer(new int[]{0,0});  \n\n        while(!q.isEmpty()){\n            int[] e = q.poll();\n            int v = e[0], t = e[1];\n            if(t <= time[v]){\n                for(int i=0;i<n;i++){\n                    if(adj[v][i]!=0){\n                        if(time[v]+adj[v][i] < time[i]){ \n                            time[i] = time[v]+adj[v][i]; \n                            \n                            q.offer(new int[]{i,time[i]});\n                            ways[i] = ways[v];\n                        }else if(time[v]+adj[v][i] == time[i]){ \n                            ways[i] = (ways[i]+ways[v])%mod;    \n                        }\n                    }\n                }\n            }\n        }\n        return ways[n-1];\n    }\n```
[]