P. 1
K-ShortestPath

K-ShortestPath

|Views: 1|Likes:
Published by Phạm Đức Minh

More info:

Published by: Phạm Đức Minh on Mar 18, 2012
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

05/13/2014

pdf

text

original

Kth Shortest Path Example∗

Matt Redmond† January 28, 2010

1

Introduction

The Shortest Path problem is very common and has many solutions. Here I present the inner working details of the Kth shortest path problem. This has been written out in other places, but I hope to reveal how it works to the finner details.

2
2.1

The Example Problem
Problem

Given the following network:

Based on Professor Jays Lecture which is loosly based off Larson and Ordoni’s book, Urban Operations Research † mredmond@uci.edu

1

. Since this is the shortest path out of node 1. ∞} = {∞. ∞. } (10) (11) Notice that these values for the length are the cummulative lengths from node 1 to node ln . 2. with our orgin at 1. ∞. We can see here from this formulation. . l3 = {2. ∞. ∞} = {∞. ∞. P4 = {1. l2 l3 l4 l5 = {1. ∞} = {1. . ∞. ∞. . l1 (1)=0. This is simply: l1 l2 l3 l4 l5 = {0. ∞. . . } } } } (6) (7) (8) (9) We then find the minimum value over all the labels. 2. ∞. ∞. ∞. } P5 = {2. ∞. which is: l2 (1) = 1. (10). . Then go exploring to the other nodes connected to 1 and try to fill in the ∞’s and blanks ” ”. } } } } } (1) (2) (3) (4) (5) We then close the smallest label. P5 = { . ∞} P1 P2 P3 P4 P5 ={ ={ ={ ={ ={ . . . . . . ∞. where l2 will remain unchanged. ∞} = {∞. ∞} = {∞. From node 2 we will move to node’s 3 and 5. ∞} P3 = {1. P3 = {1. . ∞} = {2.2 Solution To start we initilize our first length (or distance) label from position 1 as well as all the predicessor labels. ∞. . ∞. . . . ∞. We are asked to find the shortest path to all the other nodes.In the network figure above. ∞. ∞. So we close this path. ∞} We then go exploring again. ∞} = {∞. . . ∞} P2 = {1. ∞. ∞. the circles with the numbers inside are the numbered nodes. ∞. which have a certain travel time (distance/length) associated with them. that the 2 . . . . l2 = { 1 .5. ∞} l5 = {2. ∞. we will denote this by putting a box around this first minuver to show it is closed. . The directional arrows that are connecting the nodes are the links.5. ∞. 2. . ∞. .

we have a tie. l4 (1) = { 1. 4.5. This again is node 3.5 if we are going to node 2. } P5 = {2. We then look at the minimum of all the lengths and close that node. } (12) (13) Again. Therefore we close it. 4. ∞. 3.5. Doing so we tally up the total trip lengths from node 1 to each of these nodes. 4.5. l3 = { 2 . ∞} l4 = { 1.5). 2. } P5 {2. comes from node 2.5. ∞} P2 = {1. ∞} l5 = { 2 .5 .5. ∞.5. Closing node 5 we have: l5 = { 2 . 2 (in order of l2 to l5 ).5. So we update our Length and Precident labels for nodes 3 and 5 only. } (14) (15) (16) So of all the nodes that are still open (not with the box around them) we find the smallest value. 2. Seeing that l4 (1) has the minimum distance of 1. for it has a length of 2. we look for the minimum distance among all the lengths that are still open.5. In case of a tie simply choose either node arbitrailly. We can go to nodes 2. ∞} We then go exploring from node 3. we replace the next ∞ symbol with this new length of 4. 3. So in the label for node 2. Similarly. we will choose this node to close next. . } P4 = {1. 4. ∞. l3 = {2. So we close l3 as well. 2. ∞} P3 {1. ∞. from node 1 to 3.5. ∞} We then try to go exploring but we find no connected nodes.second shortest path for node 3. l2 = { 1 .5. 3. So between ∞. So Ill choose node 5 just for kicks! We see that l5 (1)=2. ∞. We add this length of 2 to the other link length of 2. 2. 3. 4. 2. ∞. To proceed we choose the minimum length distance again. which is simply the last node we are comming from. 3. we fill in the next blank in the Predicessor label. For example. 3.5 (=2+2. this time we know it will be l3 . 5. . we have a length of 2. ∞} 3 .4 and 5. Since we had a tie last time. 4. ∞} Going exploring from node 4 we find that we can only go to nodes 3 and 5. 4. ∞.5 . ∞} l5 = {2. 4. l3 = { 2 .5 in the second position of it’s length label. .5 . node 3 in this case.

5. Doing so we find new travel distances to nodes 2. 3. We fill in the new link lengths for connected nodes 3 and 5. 3. Rinse lather and repeat untill all the nodes are closed.5. the second fastest way to get there is to go from Node 1 to Node 3 and then from node 3 to go to node 2. 3rd · · · kth shortest paths. 4. 3.5} So again. l2 = { 1 .5. ∞} From node 4 then. We then look for the smallest unclosed node among our link length values. from node 5 we are unable to go exploring. 5.5 . 3 Conclusion This was an attempt to bring the algorithm for the 1st . Continuing on we would choose the smallest link length and close that node. Hope it helps.5 . we go exploring. 4. 4.5. Filling in the new trip lengths and predicessor node values we obtain the following. l5 = { 2 . and then from node 3 go BACK to node 2. 5. ∞} l4 = { 1. is our smallest value. because all the nodes point to it. } P5 = {2. The third fastest path to get there is to go from node 1 to node 2. For node 2. } P4 = {1. and then to go to node 3. We find that l4 (2)=4.5. then go exploring from it. 3.5} P2 = {1. 2nd . 3} (17) (18) (19) Notice here that for node 2 we have 2 shortest paths that both come from node 3. 5. This will be the length of 3.4 and 5 again. 3. 4. 4 . So we close it. 4. and none leave it. I tried to provide as much explination as possible between steps so the process becomes more intuitive to grasp.Again we go exploring from this node that was just closed. ∞} l5 = { 2 . 5.5. 4. So we go back to the list of lengths and choose the next smallest length that is not closed already. so we close it. 3. This is due to a loop in the network. l4 = {1. 3. found at: l5 (2)=3.5. 5. and good luck finding the shortest path to where ever you may be going in this journey we call life.

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->