Can anyone tell me that how can i compute the multiple length(same) of a shortest path and also where i want to know the both path or vertex number??
Is it possible to find out with Floyd Warshall algo or any other algorithm??
please help me.
about multiple path
Moderator: Board moderators
Here is my approach
You can choose any shortest path algorithm so long as you compute the predecessor matrix/array. Then remove the shortest path and run the algorithm once more; you will end up with the alternate shortest path. If you find a way of computing all (same length) shortest paths with a single pass of the shortest path algorithm let me know.
Let dist(x) be the length of shortest path from the source to vertex x.
Remove all (directed) edges (u,v) from the graph for which: dist(v) != weight(u,v) + dist(u).
Now, all remaining paths from source to destination are shortest paths.
Edit:
Yes, that dist(v) was a typo. Fixed now.
Remove all (directed) edges (u,v) from the graph for which: dist(v) != weight(u,v) + dist(u).
Now, all remaining paths from source to destination are shortest paths.
Edit:
Yes, that dist(v) was a typo. Fixed now.
Last edited by mf on Sun Jul 23, 2006 10:01 pm, edited 1 time in total.
-
- Experienced poster
- Posts: 209
- Joined: Sun Jan 16, 2005 6:22 pm
thnx rmotome and mf.
Now i got it. But to mf,
i dont get this line. Is it dist(v) != weight(u,v) + dist(u) or not?
mf, if i consider graph as an undirected then what should be the step??
Now i got it. But to mf,
Code: Select all
dist(v) != weight(u,v) + dist(v)
mf, if i consider graph as an undirected then what should be the step??
-
- Experienced poster
- Posts: 209
- Joined: Sun Jan 16, 2005 6:22 pm