Download presentation

Presentation is loading. Please wait.

Published byVincent Coffing Modified about 1 year ago

1
Chapter 5 Shortest Paths: Label-Correcting Algorithms 1

2
5.2 Optimality Conditions Thm 5.1) Let d(j), j N be the length of some directed path from s to node j. Then the numbers d(j) represent shortest path distances if and only if they satisfy the following shortest path optimality conditions: d(j) d(i) + c ij for all (i, j) A.(5.1) Pf) ) Suppose that d(j), j N be the shortest path lengths and d(j) > d(i) + c ij for some arc (i, j). Then the path to i + arc (i, j) gives a path with length < d(j), which is a contradiction. ) Let d(j) represent the length of some directed path from s to j and they satisfy conditions (5.1). Let s = i 1 - i 2 - … -i k = j be any path to j. Then d(j) = d(i k ) d(i k-1 ) + c i(k-1)i(k), d(i k-1 ) d(i k-2 ) + c i(k-2)i(k-1), …. d(i 2 ) d(i 1 ) + c i(1)i(2) = c i(1)i(2) (d(i 1 ) = d(s) = 0) d(j) = d(i k ) c i(k-1)i(k) + c i(k-2)i(k-1) + c i(1)i(2) = (i, j) P c ij. d(j) is lower bound on the length of any path to node j. d(j) is also upper bound since it is the length of some path to j. Network Theory and Applications 2010 2

3
Define reduced arc length c ij d = c ij + d(i) – d(j) Optimality condition is c ij d 0 for all (i, j) A. Property 5.2 a.For any directed cycle W, (i, j) W c ij d = (i, j) W c ij. b.For any directed path P from node k to node l, (i, j) P c ij d = (i, j) P c ij + d(k) – d(l). c.If d( ) represent shortest path distances, c ij d 0 for every arc (i, j) A. If the network contains a negative cycle, no set of distance labels d( ) satisfies (5.2). Pf) Suppose labels d( ) satisfy (5.2) for any cycle W → (i, j) W c ij d 0 for d( ) satisfying (5.2) → (i, j) W c ij d = (i, j) W c ij 0, contradiction Network Theory and Applications 2010 3

4
5.3 Generic Label-Correcting Algorithms Ford’s algorithm: While there exists (i, j) A satisfying d(j) > d(i) + c ij (c ij d < 0) set d(j) = d(i) + c ij pred(j) = i Predecessor graph T: collection of arcs (pred(j), j) for every finitely labeled node j (except the source node) Properties of the predecessor graph: c ij d 0 for all (i, j) in predecessor graph T. When we add (i, j) to G, set d(j) = d(i) + c ij, hence c ij d = c ij + d(i) – d(j) = 0. In the following iterations, labels d( ) never increases. If d(i) decreases → maintains c ij d 0. If d(j) decreases → (i, j) drop out from G. Network Theory and Applications 2010 4

5
(continued) Predecessor graph T is a tree if there does not exist a negative cycle in G. Network Theory and Applications 2010 5 cd0cd0 cd0cd0 c d <0 X (i, j) W c ij d = (i, j) W c ij. Predecessor graph T contains a unique directed path from s to every node k and the length of this path is at most d(k). ( 0 > (i, j) P c ij d = (i, j) P c ij + d(s) – d(k) = (i, j) P c ij – d(k) ) When algorithm terminates, c ij d = 0 for all (i, j) T. (c ij d 0 always. If < 0, we update d) Hence length of the path to every node k in T equals d(k). So optimal paths.

6
Running time: -nC d(j) nC. Algorithm updates any label d(j) at most 2nC times O(n 2 C) iterations. Modified label correcting algorithm: Idea: If d(j) decreases, the reduced length of all arcs emanating from node j decreases, but the optimality conditions of incoming arcs to node j are not affected. Hence arcs emanating from j can be candidates for updating. Instead of maintaining arcs to update, maintain the set of nodes to check. running time: when d(j) is updated, node j is added to LIST (if not in LIST) and scanned later. When scanning, scan arc lists A(j). i N (2nC)|A(i)| = O(nmC) time Network Theory and Applications 2010 6

7
Algorithm modified label-correcting;(Figure 5.5) begin d(s) :=0 and pred(s) := 0; d(j) := for each node j N\{s}; LIST := {s}; while LIST do begin remove an element i from LIST; for each arc (i, j) A(i) do If d(j) > d(i) + c ij then begin d(j) := d(i) + c ij ; pred(j) := i ; if j LIST then add node j to LIST; end; Network Theory and Applications 2010 7

8
5.5 Special Implementation of the Modified Label- Correcting Algorithm Modified label-correcting algorithm is not a polynomial-time algorithm (yet). Note that if we choose the node with minimum distance label from LIST, it is Dijkstra’s algorithm (for nonnegative arc lengths only). If we choose nodes in topological order when we solve acyclic case, it is O(m) algorithm we have seen earlier. More improvement: Ford-Bellman algorithm - O(nm) Idea: examine all arcs in a pass, then total number of passes needed is n-1. Claim: At the end of the k-th path, the algorithm will compute shortest path distances for all nodes that are connected to the source node by a shortest path consisting of k or fewer arcs. Network Theory and Applications 2010 8

9
Pf) Induction on the number of passes. True for k = 1. Suppose that the claim is true for the k-th pass. Consider a node j that is connected to the source node by a shortest path s = i 0 – i 1 – i 2 - … - i h – i h+1 = j consisting of at most k+1 arcs. Note that the path i 0 – i 1 – i 2 - … - i h is a shortest path to i h using at most k arcs. By induction hypothesis, d(i h ) is the shortest distance to i h using at most k arcs after k-th pass of the algorithm. In the (k+1)th pass, we set d(j) = d(i h ) + c i(h)j which is the shortest length using at most k+1 arcs. Possible improvement: Suppose we order the arcs in the arc list by their tail nodes. Consider one node at a time, say i, and scan A(i). Suppose that, in one pass through the arc list, algorithm does not change the distance label of node i. Then during the next pass, d(j) d(i) + c ij for all (i, j) A(i) (c ij d 0 maintained). Hence we do not need to scan A(i) in the next pass. Network Theory and Applications 2010 9

10
(continued) Store only the nodes whose distance labels change during a pass, and consider (examine) only those nodes in the next pass. Store the nodes whose distance labels change in a pass and examine the list in FIFO order (use queue) Same as the modified label-correcting algorithm (Figure 5.5) if we use queue as the data structure of LIST. Thm 5.3. The FIFO label-correcting algorithm solves the shortest path algorithm in O(nm) time. (fastest) Network Theory and Applications 2010 10

11
Dequeue implementation: pseuopolynomial worst-case behavior, but very efficient in practice dequeue: add or delete elements from the front as well as the rear of the list. Selects nodes from the front of the dequeue, but add nodes either at the front or at the rear. If the node has been in the list earlier, add it to the front; otherwise, add the node to the rear. (If label of node i updated, scan A(i) earlier will update the labels of paths following node i.) Empirically, dequeue implementation examines fewer nodes. Network Theory and Applications 2010 11

12
Detecting negative cycles: No finite d( ) exists if there exists a negative cycle. If d( ) < -nC, negative cycle exists. (d(j) is an upper bound on the length of the path to node j in the predecessor graph T) Count the number of node examination in FIFO label-correcting algorithm. (the number of examination should be (n-1) ) Identifying negative cycle: (see Figure 5.4) designate source node as marked. All other nodes are unmarked. One by one, examine each unmarked node k and do the following; Temporarily mark node k, and trace the predecessor indices starting at node k, and temporarily mark all the nodes encountered until (1)we reach the first already marked node, (2) or visits a temporarily marked node, say l, again. (1) make all temporary marked nodes as permanent. (s-t path exists in T) (2) node l is in a negative cycle. Identify the cycle starting from node l. (check the correctness of the explanation given in the text.) Perform the algorithm after every n distance updates. Network Theory and Applications 2010 12

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google