Just as a reminder with simple explanation.
Path Reconstruction #
Use vector<int> pre[N]
to record the previous vertices of all the vertices in the shortest path(s). When updating the distance to vertex , if the current distance is better, discard the previous record and let the current vertex be the previous vertex of . If the distance is the same, just add the current vertex to pre[v]
.
Number of shortest paths #
Similar to recording the path, if the distance is better then let the number be one. If the same, plus 1.