
You are given an undirected graph (the "original graph" ) with n nodes labeled from 0 to n - 1 . You decide to subdivide each edge in the graph into a chain of nodes, with the number of new nodes varying between each edge.
The graph is given as a 2D array of edges where edges[i] = [u _i , v _i , cnt _i ] indicates that there is an edge between nodes u _i and v _i in the original graph, and cnt _i is the total number of new nodes that you will subdivide the edge into. Note that cnt _i == 0 means you will not subdivide the edge.
To subdivide the edge [u _i , v _i ] , replace it with (cnt _i + 1) new edges and cnt _i new nodes. The new nodes are x _1 , x _2 , ..., x _cnti , and the new edges are [u _i , x _1 ] , [x _1 , x _2 ] , [x _2 , x _3 ] , ..., [x _cnti-1 , x _cnti ] , [x _cnti , v _i ] .
In this new graph , you want to know how many nodes are reachable from the node 0 , where a node is reachable if the distance is maxMoves or less.
Given the original graph and maxMoves , return the number of nodes that are reachable from node 0 in the new graph .
0 <= edges.length <= min(n * (n - 1) / 2, 10 ^4 )edges[i].length == 30 <= u _i < v _i < nThere are no multiple edges in the graph.0 <= cnt _i <= 10 ^40 <= maxMoves <= 10 ^91 <= n <= 3000