java
```\nclass Solution {\n    int mod = 1_000_000_007;\n    public int countRestrictedPaths(int n, int[][] edges) {\n        List[] nei = new List[n+1];\n        f
```\nclass Solution {\n    int mod = 1_000_000_007;\n    public int countRestrictedPaths(int n, int[][] edges) {\n        List<int[]>[] nei = new List[n+1];\n        for(int i=1; i<=n; i++)\n            nei[i] = new ArrayList<int[]>();\n        for(int[] edge : edges){\n            nei[edge[0]].add(new int[]{edge[1], edge[2]});\n            nei[edge[1]].add(new int[]{edge[0], edge[2]});\n        }\n        int[] dis = new int[n+1];\n        PriorityQueue<int[]> q = new PriorityQueue<int[]>((a,b)->(a[1]-b[1]));\n        q.offer(new int[]{n, 0});\n        int[] visited = new int[n+1];\n        while(!q.isEmpty()){\n            int[] cur = q.poll();\n            if(visited[cur[0]] == 1)\n                continue;\n            dis[cur[0]] = cur[1];\n            visited[cur[0]]=1;\n            for(int[] next : nei[cur[0]])\n                if(visited[next[0]] == 0)\n                    q.offer(new int[]{next[0], next[1]+cur[1]});\n        }\n        return dfs(1, n, dis, new HashMap(), nei);\n    }\n    \n    public int dfs(int from, int to, int[] dis, HashMap<Integer, Integer> map, List<int[]>[] nei){\n        if(from == to) return 1;\n        if(map.containsKey(from)) return map.get(from);\n        int res = 0;\n        for(int[] next : nei[from])\n            if(dis[next[0]]<dis[from])\n                res = (res+dfs(next[0], to, dis, map, nei))%mod;\n        map.put(from, res);\n        return res;\n    }\n}
[]