Page 1 of 1

K'th Shortest Path

Posted: Mon Oct 08, 2007 10:25 pm
by sunny
http://acmicpc-live-archive.uva.es/nuev ... php?p=3624

If there wasn't the constraint that a vertex can't be visited multiple times, an easy O (k*E*log(k*V)) solution was possible.

But how to do this?

Posted: Tue Oct 09, 2007 4:02 am
by sclo
use a modified form of dijkstra.
For each node, we are allowed to remove it at most k times from the heap, instead of only once. And each time we remove it from the heap, we update distances of neighbors and insert them into heap.

Posted: Thu Oct 11, 2007 6:27 pm
by forest
i suppose it is the same algorithm sunny was talking about. It allows vertexes appear multiple times

Posted: Fri Oct 12, 2007 10:58 am
by ImLazy
I heard that the generalizations of Dijkstra can not handle loopless paths.

Posted: Fri Oct 12, 2007 12:23 pm
by sunny
I didn't understand how sclo's algorithm can find cycle-less paths.
Otherwise, I too think it is the same thing I mentioned for finding cycle-allowed K'th shortest path.

Well I tried to modify that algorithm. I store one additional information for every node which is the intermediate vertices visited to get to that node. This is to not allow any cycles.

As every vertex is proccessed upto K times so the number of nodes can be K*V. So, overall runtime becomes K^2*E*log(KV) which gets TLE.

Posted: Wed Nov 14, 2007 7:20 am
by ImLazy
The offical report of Yokohama 2006 gives the algorithm.

Posted: Wed Nov 28, 2007 5:59 am
by richardxx
ImLazy wrote:I heard that the generalizations of Dijkstra can not handle loopless paths.
But, indeed it solves the loopless form.
Try add the information into the dijkstra label, any time we expand the label according to this visiting information. This can be done with bits operations.

Say:

0110011

We have visited the 1st,2nd,5th and 6th city, so if these cities can be reach from this point, we simply ignore them.