Download presentation

Presentation is loading. Please wait.

Published byVincent Coffing Modified over 2 years ago

1
**Chapter 5 Shortest Paths: Label-Correcting Algorithms**

2
**5.2 Optimality Conditions**

Thm 5.1) Let d(j), jN 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) + cij for all (i, j) A. (5.1) Pf) ) Suppose that d(j), jN be the shortest path lengths and d(j) > d(i) + cij 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 = i1 - i2 - … -ik = j be any path to j. Then d(j) = d(ik) d(ik-1) + ci(k-1)i(k), d(ik-1) d(ik-2) + ci(k-2)i(k-1), …. d(i2) d(i1) + ci(1)i(2) = ci(1)i(2) (d(i1) = d(s) = 0) d(j) = d(ik) ci(k-1)i(k)+ ci(k-2)i(k-1) + ci(1)i(2) = (i, j)P cij. 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

3
**Define reduced arc length cijd = cij + d(i) – d(j) **

Optimality condition is cijd 0 for all (i, j)A. Property 5.2 For any directed cycle W, (i, j)W cijd = (i, j)W cij. For any directed path P from node k to node l, (i, j)P cijd = (i, j)P cij + d(k) – d(l). If d() represent shortest path distances, cijd 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 cijd 0 for d() satisfying (5.2) → (i, j)W cijd = (i, j)W cij 0, contradiction Network Theory and Applications 2010

4
**5.3 Generic Label-Correcting Algorithms**

Ford’s algorithm: While there exists (i, j)A satisfying d(j) > d(i) + cij (cijd < 0) set d(j) = d(i) + cij 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: cijd 0 for all (i, j) in predecessor graph T. When we add (i, j) to G, set d(j) = d(i) + cij , hence cijd = cij + d(i) – d(j) = 0. In the following iterations, labels d() never increases. If d(i) decreases → maintains cijd 0. If d(j) decreases → (i, j) drop out from G. Network Theory and Applications 2010

5
**(i, j)W cijd = (i, j)W cij.**

(continued) Predecessor graph T is a tree if there does not exist a negative cycle in G. cd0 X cd0 cd<0 (i, j)W cijd = (i, j)W cij. 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 cijd = (i, j)P cij + d(s) – d(k) = (i, j)P cij – d(k) ) When algorithm terminates, cijd = 0 for all (i, j)T. (cijd 0 always. If < 0, we update d) Hence length of the path to every node k in T equals d(k). So optimal paths. Network Theory and Applications 2010

6
**-nC d(j) nC. Algorithm updates any label d(j) at most 2nC times **

Running time: -nC d(j) nC. Algorithm updates any label d(j) at most 2nC times O(n2C) 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). iN(2nC)|A(i)| = O(nmC) time Network Theory and Applications 2010

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 remove an element i from LIST; for each arc (i, j)A(i) do If d(j) > d(i) + cij then d(j) := d(i) + cij ; pred(j) := i ; if j LIST then add node j to LIST; end; Network Theory and Applications 2010

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

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 = i0 – i1 – i2 - … - ih – ih+1 = j consisting of at most k+1 arcs. Note that the path i0 – i1 – i2 - … - ih is a shortest path to ih using at most k arcs. By induction hypothesis, d(ih) is the shortest distance to ih using at most k arcs after k-th pass of the algorithm. In the (k+1)th pass, we set d(j) = d(ih) + ci(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) + cij for all (i, j)A(i) (cijd 0 maintained) . Hence we do not need to scan A(i) in the next pass. Network Theory and Applications 2010

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 The FIFO label-correcting algorithm solves the shortest path algorithm in O(nm) time. (fastest) Network Theory and Applications 2010

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

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

Similar presentations

OK

Greedy Algorithms Reading Material: Chapter 8 (Except Section 8.5)

Greedy Algorithms Reading Material: Chapter 8 (Except Section 8.5)

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on high voltage engineering lectures Ppt on formal education quotes Ppt on uk economy Ppt on case study of microsoft Ppt on viruses and bacteria Download ppt on query processing and optimization ppt Ppt on black magic in india Ppt on domain name server Jit ppt on manufacturing Ppt on success and failure quotes