Chapter 5 Shortest Paths: Label-Correcting Algorithms

Slides:



Advertisements
Similar presentations
Single Source Shortest Paths
Advertisements

§3 Shortest Path Algorithms Given a digraph G = ( V, E ), and a cost function c( e ) for e  E( G ). The length of a path P from source to destination.
15.082J & 6.855J & ESD.78J Shortest Paths 2: Bucket implementations of Dijkstra’s Algorithm R-Heaps.
MINIMUM COST FLOWS: NETWORK SIMPLEX ALGORITHM A talk by: Lior Teller 1.
Chapter 6 Maximum Flow Problems Flows and Cuts Augmenting Path Algorithm.
15.082J, 6.855J, and ESD.78J Sept 16, 2010 Lecture 3. Graph Search Breadth First Search Depth First Search Intro to program verification Topological Sort.
Chapter 7 Maximum Flows: Polynomial Algorithms
Chapter 5 Routing Algorithm in Networks. How are message routed from origin to destination? 1) Circuit-Switching → telephone net. Dedicated bandwidth.
Jim Anderson Comp 122, Fall 2003 Single-source SPs - 1 Chapter 24: Single-Source Shortest Paths Given: A single source vertex in a weighted, directed graph.
Shortest Paths Definitions Single Source Algorithms –Bellman Ford –DAG shortest path algorithm –Dijkstra All Pairs Algorithms –Using Single Source Algorithms.
Data Structures, Spring 2004 © L. Joskowicz 1 Data Structures – LECTURE 15 Shortest paths algorithms Properties of shortest paths Bellman-Ford algorithm.
Tirgul 7 Review of graphs Graph algorithms: – BFS (next tirgul) – DFS – Properties of DFS – Topological sort.
1 Shortest Path Algorithms. 2 Routing Algorithms Shortest path routing What is a shortest path? –Minimum number of hops? –Minimum distance? There is a.
Minimum Spanning Trees. Subgraph A graph G is a subgraph of graph H if –The vertices of G are a subset of the vertices of H, and –The edges of G are a.
NetworkModel-1 Network Optimization Models. NetworkModel-2 Network Terminology A network consists of a set of nodes and arcs. The arcs may have some flow.
Computational Methods for Management and Economics Carla Gomes
Theory of Computing Lecture 7 MAS 714 Hartmut Klauck.
& 6.855J & ESD.78J Algorithm visualizations Modified Label Correcting Algorithm.
15.082J, 6.855J, and ESD.78J September 21, 2010 Eulerian Walks Flow Decomposition and Transformations.
Graphs – Shortest Path (Weighted Graph) ORD DFW SFO LAX
Chapter 4 Shortest Path Label-Setting Algorithms Introduction & Assumptions Applications Dijkstra’s Algorithm.
Jim Anderson Comp 122, Fall 2003 Single-source SPs - 1 Chapter 24: Single-Source Shortest Paths Given: A single source vertex in a weighted, directed graph.
Operations Research Assistant Professor Dr. Sana’a Wafa Al-Sayegh 2 nd Semester ITGD4207 University of Palestine.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
Chapter 24: Single-Source Shortest Paths Given: A single source vertex in a weighted, directed graph. Want to compute a shortest path for each possible.
15.082J & 6.855J & ESD.78J September 23, 2010 Dijkstra’s Algorithm for the Shortest Path Problem.
Introduction to Algorithms Jiafen Liu Sept
The single-source shortest path problem (SSSP) input: a graph G = (V, E) with edge weights, and a specific source node s. goal: find a minimum weight (shortest)
1 1 © 2003 Thomson  /South-Western Slide Slides Prepared by JOHN S. LOUCKS St. Edward’s University.
1 Network Models Transportation Problem (TP) Distributing any commodity from any group of supply centers, called sources, to any group of receiving.
Chapter 3 Algorithms Complexity Analysis Search and Flow Decomposition Algorithms.
Chapter 8 Maximum Flows: Additional Topics All-Pairs Minimum Value Cut Problem  Given an undirected network G, find minimum value cut for all.
and 6.855J March 6, 2003 Maximum Flows 2. 2 Network Reliability u Communication Network u What is the maximum number of arc disjoint paths from.
Supplementary: Feasible Labels and Linear Programming  Consider the LP formulation of the shortest s-t path problem: (P) Minimize  (i, j)  A c ij x.
15.082J & 6.855J & ESD.78J September 30, 2010 The Label Correcting Algorithm.
Suppose G = (V, E) is a directed network. Each edge (i,j) in E has an associated ‘length’ c ij (cost, time, distance, …). Determine a path of shortest.
EMIS 8374 Shortest Path Trees Updated 11 February 2008 Slide 1.
EMIS 8374 The Ford-Fulkerson Algorithm (aka the labeling algorithm) Updated 4 March 2008.
Data Structures and Algorithm Analysis Graph Algorithms Lecturer: Jing Liu Homepage:
1 Maximum Flows CONTENTS Introduction to Maximum Flows (Section 6.1) Introduction to Minimum Cuts (Section 6.1) Applications of Maximum Flows (Section.
1 GRAPHS – Definitions A graph G = (V, E) consists of –a set of vertices, V, and –a set of edges, E, where each edge is a pair (v,w) s.t. v,w  V Vertices.
CSC317 1 At the same time: Breadth-first search tree: If node v is discovered after u then edge uv is added to the tree. We say that u is a predecessor.
School of Computing Clemson University Fall, 2012
St. Edward’s University
Shortest Paths CONTENTS Introduction to Shortest Paths (Section 4.1)
Shortest Path from G to C Using Dijkstra’s Algorithm
Chapter 5. Optimal Matchings
EMIS 8374 Dijkstra’s Algorithm Updated 18 February 2008
Dijkstra’s Algorithm for the Shortest Path Problem
Shortest Path.
Dijkstra’s Algorithm for the Shortest Path Problem
Lecture 4 Graph Search.
Lectures on Graph Algorithms: searching, testing and sorting
3.4 Push-Relabel(Preflow-Push) Maximum Flow Alg.
Lecture 13 Algorithm Analysis
Lecture 13 Algorithm Analysis
EMIS 8374 Shortest Path Problems: Introduction Updated 9 February 2008
Shortest-Path Property 4.1
Lecture 13 Algorithm Analysis
2.2 Shortest Paths Def: directed graph or digraph
Lecture 13 Algorithm Analysis
Shortest Path Problems
and 6.855J March 6, 2003 Maximum Flows 2
EMIS 8374 Search Algorithms Updated 9 February 2004
The Ford-Fulkerson Algorithm
and 6.855J Dijkstra’s Algorithm
CSE 417: Algorithms and Computational Complexity
Implementation of Dijkstra’s Algorithm
EMIS 8374 Search Algorithms Updated 12 February 2008
Max Flows 3 Preflow-Push Algorithms
Presentation transcript:

Chapter 5 Shortest Paths: Label-Correcting Algorithms

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) + cij for all (i, j)  A. (5.1) Pf) ) Suppose that d(j), jN 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

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

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

(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. cd0 X cd0 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

-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).  iN(2nC)|A(i)| = O(nmC) time Network Theory and Applications 2010

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

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

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

(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

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

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