javascript dijkstra 132ms
\nconst mod = 1e9 + 7;\nconst countPaths = (n, road) => {\n    let adj = initializeGraph(n);\n    for (const [u, v, cost] of road) {\n        adj[u].push([v, co
```\nconst mod = 1e9 + 7;\nconst countPaths = (n, road) => {\n    let adj = initializeGraph(n);\n    for (const [u, v, cost] of road) {\n        adj[u].push([v, cost]);\n        adj[v].push([u, cost]);\n    }\n    return dijkstra(n, adj, 0);\n};\n\nconst dijkstra = (n, g, source) => { // g: adjacent graph list, n: total vertices\n    let dist = Array(n).fill(Number.MAX_SAFE_INTEGER);\n    let ways = Array(n).fill(0);\n    const pq = new MinPriorityQueue({ priority: x => x[0] * 200 + x[1] });\n    dist[0] = 0;\n    ways[0] = 1;\n    pq.enqueue([0, source]);\n    while (pq.size()) {\n        let cur = pq.dequeue().element;\n        let [curCost, curNode] = cur;\n        if (dist[curNode] != curCost) continue;\n        for (const [node, cost] of g[curNode]) { // parse neighbour node\n            let newDis = curCost + cost;\n            if (newDis == dist[node]) {\n                ways[node] += ways[curNode];\n                ways[node] %= mod;\n            } else if (newDis < dist[node]) {\n                dist[node] = newDis;\n                ways[node] = ways[curNode];\n                pq.enqueue([dist[node], node]);\n            }\n        }\n    }\n    return ways[n - 1];\n};\n\nconst initializeGraph = (n) => { let G = []; for (let i = 0; i < n; i++) { G.push([]); } return G; };\n```
['JavaScript']