To assess how “well-connected” two nodes in a directed graphare, one can not only look at the length of the shortest pathbetween them, but can also count the number of shortest paths.
This turns out to be a problem that can be solved efficiently,subject to some restrictions on the edge costs. Suppose we aregiven a directed graph G = (V, E), with costs on the edges; thecosts may be positive or negative, but every cycle in the graph hasstrictly positive cost. We are also given two nodes v, w ∈ V. Givean efficient algorithm that computes the number of shortest v-wpaths
OR
OR