Construct the number of shortest paths matrix