C++ solution
Code

# Code
```cpp []
class Solution {
public:
    int countRestrictedPaths(int n, vector<vector<int>>& edges) {
        const unsigned int M = 1000000007;
        vector<vector<pair<int, int>>> adj(n + 1);
        // create adjacent matrix
        for (vector<int>& e : edges) {
            adj[e[0]].push_back({e[1], e[2]});
            adj[e[1]].push_back({e[0], e[2]});
        }
        priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
        vector<bool> vis(n + 1, 0);
        // minDist[i] means the length of the shortest path from node i to last node
        vector<int> minDist(n + 1, INT_MAX);
        // numRestricted[i] means the number of restricted paths from node i to last node.
        vector<int> numRestricted(n + 1, 0);
        pq.push({0, n});
        minDist[n] = 0;
        numRestricted[n] = 1;
        while (!pq.empty()) {
            int currDist = pq.top().first;
            int currNode = pq.top().second;
            pq.pop();
            if (vis[currNode]) continue;
            vis[currNode] = 1;
            for (auto& pair : adj[currNode]) {
                int adjNode = pair.first;
                int adjDist = pair.second;
                if (adjDist + currDist < minDist[adjNode]) {
                    minDist[adjNode] = adjDist + currDist;
                    pq.push({adjDist + currDist, adjNode});
                }
                if (minDist[adjNode] > currDist) 
                    numRestricted[adjNode] = ((long long) numRestricted[adjNode] + numRestricted[currNode]) % M;
            }
        }
        return numRestricted[1];
    }
};
```
['Heap (Priority Queue)', 'Shortest Path', 'C++']