K'th Shortest Path

Let's talk about algorithms!

Moderator: Board moderators

Post Reply
sunny
Experienced poster
Posts: 124
Joined: Sun Sep 11, 2005 10:22 pm
Location: Civil-BUET

K'th Shortest Path

Post 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?
sclo
Guru
Posts: 519
Joined: Mon Jan 23, 2006 10:45 pm
Location: Vancouver, BC, Canada
Contact:

Post 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.
forest
New poster
Posts: 11
Joined: Sat Sep 02, 2006 5:13 pm
Contact:

Post by forest »

i suppose it is the same algorithm sunny was talking about. It allows vertexes appear multiple times
ImLazy
Experienced poster
Posts: 215
Joined: Sat Jul 10, 2004 4:31 pm
Location: Shanghai, China

Post by ImLazy »

I heard that the generalizations of Dijkstra can not handle loopless paths.
I stay home. Don't call me out.
sunny
Experienced poster
Posts: 124
Joined: Sun Sep 11, 2005 10:22 pm
Location: Civil-BUET

Post 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.
ImLazy
Experienced poster
Posts: 215
Joined: Sat Jul 10, 2004 4:31 pm
Location: Shanghai, China

Post by ImLazy »

The offical report of Yokohama 2006 gives the algorithm.
I stay home. Don't call me out.
richardxx
New poster
Posts: 3
Joined: Fri Oct 20, 2006 7:51 am

Post 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.
Post Reply

Return to “Algorithms”