Page 1 of 1

shortest paths network

Posted: Sun Apr 05, 2009 7:54 pm
by nicoletsg
In a network i want to find the number of alternate shortes paths from a start node to all other nodes. Normally Dijkstra can be used.
But because there are no weights BFS should also working.
I can modify BFS algorithm so that pred (n) doesn't only store one predecessor
but a list of possible predecessors. So i have now the PATHs
But is there any way to calculate the Number of shortest paths from a start node to rest of nodes ?

Re: shortest paths network

Posted: Mon Apr 06, 2009 5:54 pm
by maxdiver
You don't even need in pred[], only distances dist[] from vertex s to the others.
After that, calculate for each vertex dynamics: d[v] is the number of shortest paths to v.
Set d[s] = 1.
For each other vertex d[v] = SUM d[p] over all p such that dist[p] + g[p][v] == dist[v].

Re: shortest paths network

Posted: Mon Apr 13, 2009 11:58 am
by nicoletsg
Thank's for ideas