Dynamic All Pairs Shortest Paths Based on the following resources: Camil Demetrescu and Giuseppe F. Italiano (2004) A New Approach to Dynamic All Pairs.

Slides:



Advertisements
Similar presentations
Single Source Shortest Paths
Advertisements

all-pairs shortest paths in undirected graphs
Weighted graphs Example Consider the following graph, where nodes represent cities, and edges show if there is a direct flight between each pair of cities.
Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.
an incremental version of A*
Greed is good. (Some of the time)
1 Lecture 5 (part 2) Graphs II Euler and Hamiltonian Path / Circuit Reading: Epp Chp 11.2, 11.3.
October 31, Algorithms and Data Structures Lecture XIII Simonas Šaltenis Nykredit Center for Database Research Aalborg University
November 14, Algorithms and Data Structures Lecture XIII Simonas Šaltenis Aalborg University
CS138A Single Source Shortest Paths Peter Schröder.
Shortest-paths. p2. Shortest-paths problems : G=(V,E) : weighted, directed graph w : E  R : weight function P=
1 Theory I Algorithm Design and Analysis (10 - Shortest paths in graphs) T. Lauer.
CSE 101- Winter ‘15 Discussion Section January 26th 2015.
Introduction to Algorithms 6.046J/18.401J/SMA5503
Combinatorial Algorithms
1 Discrete Structures & Algorithms Graphs and Trees: II EECE 320.
Chapter 23 Minimum Spanning Trees
A Nearly Optimal Algorithm for Approximating Replacement Paths and k Shortest Simple Paths in General Graphs Abhilasha Seth CSCE 669.
Approximation Algorithms: Combinatorial Approaches Lecture 13: March 2.
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 Path Problems
Shortest Paths Definitions Single Source Algorithms –Bellman Ford –DAG shortest path algorithm –Dijkstra All Pairs Algorithms –Using Single Source Algorithms.
Dynamic Shortest Paths Camil Demetrescu University of Rome “La Sapienza” Giuseppe F. Italiano University of Rome “Tor Vergata”
1 8-ShortestPaths Shortest Paths in a Graph Fundamental Algorithms.
Greedy Algorithms Reading Material: Chapter 8 (Except Section 8.5)
Graph Algorithms: Shortest Path We are given a weighted, directed graph G = (V, E), with weight function w: E R mapping.
Shortest Paths Definitions Single Source Algorithms
Greedy Algorithms Like dynamic programming algorithms, greedy algorithms are usually designed to solve optimization problems Unlike dynamic programming.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2004 Lecture 5 Wednesday, 10/6/04 Graph Algorithms: Part 2.
TECH Computer Science Graph Optimization Problems and Greedy Algorithms Greedy Algorithms  // Make the best choice now! Optimization Problems  Minimizing.
Graphs – Shortest Path (Weighted Graph) ORD DFW SFO LAX
Dynamic Single-source Shortest Paths Camil Demetrescu University of Rome “La Sapienza”
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.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
Multiple-Source Shortest Paths in Planar Graphs Allowing Negative Lengths Philip Klein Brown University.
MST Many of the slides are from Prof. Plaisted’s resources at University of North Carolina at Chapel Hill.
Spring 2015 Lecture 11: Minimum Spanning Trees
UNC Chapel Hill Lin/Foskey/Manocha Minimum Spanning Trees Problem: Connect a set of nodes by a network of minimal total length Some applications: –Communication.
Distance sensitivity oracles in weighted directed graphs Raphael Yuster University of Haifa Joint work with Oren Weimann Weizmann inst.
Discrete Structures Lecture 12: Trees Ji Yanyan United International College Thanks to Professor Michael Hvidsten.
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.
Introduction to Algorithms Jiafen Liu Sept
CSE 2331 / 5331 Topic 12: Shortest Path Basics Dijkstra Algorithm Relaxation Bellman-Ford Alg.
Engineering shortest path algorithms (a round trip between theory and experiments) Camil Demetrescu University of Rome “La Sapienza” Giuseppe F. Italiano.
CSE 589 Part VI. Reading Skiena, Sections 5.5 and 6.8 CLR, chapter 37.
Lecture 11 Algorithm Analysis Arne Kutzner Hanyang University / Seoul Korea.
1 Prim’s algorithm. 2 Minimum Spanning Tree Given a weighted undirected graph G, find a tree T that spans all the vertices of G and minimizes the sum.
Introduction to Graph Theory
A Introduction to Computing II Lecture 16: Dijkstra’s Algorithm Fall Session 2000.
Approximation Algorithms based on linear programming.
6/13/20161 Greedy A Comparison. 6/13/20162 Greedy Solves an optimization problem: the solution is “best” in some sense. Greedy Strategy: –At each decision.
TIRGUL 10 Dijkstra’s algorithm Bellman-Ford Algorithm 1.
TU/e Algorithms (2IL15) – Lecture 8 1 MAXIMUM FLOW (part II)
Greedy Algorithms.
Algorithms and Data Structures Lecture XIII
Chapter 5. Optimal Matchings
Enumerating Distances Using Spanners of Bounded Degree
CSE 373: Data Structures and Algorithms
Algorithms and Data Structures Lecture XIII
Lecture 13 Algorithm Analysis
Lecture 13 Algorithm Analysis
Improved dynamic reachability algorithms for directed graphs
Minimum Spanning Tree Algorithms
Lecture 13 Algorithm Analysis
Lecture 13 Algorithm Analysis
Algorithms (2IL15) – Lecture 7
Dynamic Graph Algorithms
Shortest Path Problems
Introduction to Algorithms: Greedy Algorithms (and Graphs)
Graph Algorithms: Shortest Path
Presentation transcript:

Dynamic All Pairs Shortest Paths Based on the following resources: Camil Demetrescu and Giuseppe F. Italiano (2004) A New Approach to Dynamic All Pairs Shortest Paths. Journal of the Association for Computing Machinery (JACM), 51(6), C. Demetrescu and G.F. Italiano (2003) A New Approach to Dynamic All Pairs Shortest Paths. STOC’03, C. Demetrescu and G.F. Italiano. Presention on dynamic all pairs shortest paths. Presented by: Qingwu Yang

Dynamic All Pairs Shortest Paths Given a weighted directed graph G=(V,E,w), perform any intermixed sequence of the following operations: return distance from x to y Distance (x,y): update weight of edge (u,v) to w Update (u,v,w): return shortest path from x to y Path (x,y):

Previous work on fully dynamic APSP generalreals? < o(n 3 )O(1) QueryUpdateGraphWeight Update recomputing from scratch general reals O(1) O(n 3 ) ~ O(n C ) ~ [0,C] King 99general[0,C]O(n 2.5 (C log n) 0.5 )O(1)O(n 9/7 log(nC))Henzinger et al. 97planar[0,C] O(n 9/5 log 13/5 n) Fackcharoemphol, Rao 01 planarreals D, Italiano 01generalS realsO(n 2.5 (S log 3 n) 0.5 )O(1)

Contributions of This Paper A completely new approach to dynamic APSP. A fully dynamic algorithm for APSP on general directed graphs with nonnegative real- valued edge weights. Supporting any sequence of operations in O(n 2 log 3 n) amortized time per update, unit worst-case time per distance query, and optimal worst-case time for returning any shortest path.

 (n 2 ) changes per update  (n) +1 +1

A new approach New combinatorial properties of graphs: Locally shortest paths Uniform paths

Definition of Locally shortest paths A path π xy is locally shortest in G if either: π xy consists of a single vertex, or every proper subpath of π xy is a shortest path in G xy π xy xy Locally Shortest NOT Locally Shortest Shortest path Not a shortest path Shortest path

Properties of Locally shortest paths In a locally shortest path, all proper subpaths are shortest paths: however, the path itself may not necessarily be shortest. xπ xy y Shortest path Locally shortest path Shortest path uv

Locally shortest paths Properties of Locally shortest paths Theorem I Shortest paths  Locally shortest paths Shortest paths

Properties of Locally shortest paths For the sake of simplicity, we assume that no two paths in the graph have the same weight. (Ties can be broken by adding a tiny fraction to the weight of each edge) Theorem II Locally shortest paths π xy are internally vertex-disjoint xy π1π1 π3π3 π2π2

Properties of Locally shortest paths Theorem III There are at most n-1 Locally shortest paths connecting x,y xy This is a consequence of vertex-disjointess…

Properties of Locally shortest paths Theorem IV If shortest paths are unique in G, then there can be at most m·n locally shortest paths in G. x y v ≤ m choices≤ n choices × ≤mn

Dynamic graphs We call dynamic graph a sequence of graphs such that, for any t, G t-1 and G t differ in the weight of exactly one edge, 0≤t≤k.

Locally shortest paths in dynamic graphs An Locally shortest path in G t is appearing if it is not Locally shortest in G t-1 xy xy GtGt G t-1 u v u v p q p q

Locally shortest paths in dynamic graphs A Locally shortest path in G t is disappearing if it is not Locally shortest in G t+1 G t+1 GtGt xy xy uv uv p p q q

Locally shortest paths in dynamic graphs Proof A path can stop being locally shortest only if any of its proper subpaths stops being shortest. In case of increases, this can happen only if the subpath contains the updated vertex, say vertex v. By theorem II, at most O(n 2 ) shortest paths contain v as an internal vertex. At most O(n 2 ) locally shortest paths starting or ending at v. Theorem V Let G be a graph subject to a sequence of vertex updates. If shortest paths are unique in G, then in the worst case at most O(n 2 ) paths can stop being locally shortest due to a vertex increase.

Locally shortest paths in dynamic graphs Proof of (2) Assume that initially there are x 0 locally shortest paths. x 0 = O(mn). Assume that there are k updates, k≥m/n. By Theorem V, O(k n 2 ) paths can stop being locally shortest. x k ≤ mn. Assume the total number of paths that start being locally shortest is y. x 0 - O(k n 2 )+ y ≤ x k y ≤ O(k n 2 )+ x k - x 0 = O(k n 2 ) + O(mn)-O(mn) = O(k n 2 ) + O(mn)= O(k n 2 ) y/k ≤ O(n 2 ) Theorem VI Let G be a graph subject to a sequence Σ of increase-only vertex updates and let m be the maximum number of edges in G throughout the sequence Σ. If shortest paths are unique in G, then the number of paths that start being locally shortest after each update is: (1)O(mn) in the worst case. (2)O(n 2 ) amortized over Ω(m/n) updates.

Locally shortest paths in dynamic graphs The weights of Locally shortest paths that disappear and then reappear do not change… xy xy What about fully dynamic sequences?

Shortest paths and edge weight updates How does a shortest path change after an update? The shortest path is the same, but has different weight: xy  The shortest path is different (update = decrease): xy -- EASY

Shortest paths and edge weight updates The shortest path is different (update = increase): xy ++ HARD ab If we look closer, we realize that the new shortest path from a to b was already Locally shortest before the update!

A new approach to dynamic APSP Are we done? Main idea: For each pair x,y, maintain in a data structure Locally shortest paths connecting x to y The combinatorial properties of Locally shortest paths imply that only a small piece of information needs to be updated at each time… NO

xy How to pay only once? xy xy This path stays the same while flipping between Locally shortest and non-Locally shortest: We would like to have an update algorithm that pays only once for it over the whole sequence...

xy Looking at the substructure xy …but if we removed the edge it would get a shortest path again! may resurrect! This path remains a shortest path after the insertion This path is no longer a shortest path after the insertion…

Breaking Ties If shortest paths in the graph are not unique, the properties of locally shortest paths don’t hold. Using an arbitrary tie-breaking strategy may lead to incorrect results.

Breaking Ties – Basic idea Without loss of generality, assume that V = {1, 2, …, n}. Assign to each edge (u, v) a unique number ID(u, v) (e.g. ID(u, v)=u+nv). For each path π, define ID(π) as the maximum ID of its edges. For a path π, extended weight ew(π) = (w(π), ID(π)).

Breaking Ties – Comparing two ew’s Compare the extended weights of two paths π 1 and π 2 ew(π 1 ) ≤ ew(π 2 ) if and only if (1)w(π 1 ) < w(π 2 ) or (2) w(π 1 ) = w(π 2 ) and ID(π 1 ) ≤ ID(π 2 ).

Breaking Ties Definition of S ew Let G be a graph with real-valued edge weights and let ew be the extended weight function. We define S ew as follows: Note: S ew contains every path in G that has minimum extended weight and whose subpaths have minimum extended weight as well.

Breaking Ties Lemma I For each pair of vertices x and y in G, there can be at most one path connecting them. Lemma II For each pair of vertices x and y in G, there is a path. S ew contains exactly one shortest path between each pair of vertices connected in G. |S ew | ≤ n 2. S ew is a complete set of unique shortest paths in G. We can always ensure uniqueness of shortest paths by dealing with paths in S ew.

Historical paths Definition of Historical paths Let π xy be a path in G at time t, and let t’ ≤ t be the time of the latest vertex update on π xy. We say that π xy is HISTORICAL at time t if it has been a shortest path at least once in the time interval [t’, t]. Note: A shortest path is also a historical path. Although it may stop being a shortest path at some point, it keeps on being a historical path until a vertex update occurs on it.

Locally historical paths Definition of Locally historical paths We say that a path π xy is Locally Historical in G at time t if either: (i)π xy consists of a single vertex, or (ii)Every proper subpath of π xy is a historical path in G at time t.

Locally historical paths vs. Locally shortest paths shortest path x y π xy Locally shortest path shortest or historical path x y π xy Locally historical path Relaxed notion of Locally historical: Subpaths do not need to be shortest at the same time

Locally historical paths Properties of Locally historical paths Theorem Locally shortest paths  Locally historical paths Locally shortest paths Shortest paths

Properties of Locally historical paths Theorem O(zn 2 ) historical paths at any time O(zn 2 ) new Locally historical paths per update (Assume there are at most z historical paths between each pair of vertices)

 (n) 100 How many historical paths can we have? A lot! We can construct a dynamic graph with  (n 3 ) historical paths at any time, amortized # h paths =  (n 2 )+  (n 2 )  (n 2 ) =  (n 3 )  (n)

Reducing # of historical paths: Smoothing At each update we pick an edge with the maximum number of historical paths passing through it, and we remove and reinsert it  (n) 100 # h paths =  (n 2 )  (n 2 )  (n 2 ) (in general, O(n 2 ))

A new approach to dynamic APSP (II) Main idea: For each pair x,y, maintain in a data structure the Locally historical paths connecting x to y The combinatorial properties of Locally historical paths imply that, if we do smoothing, we have only O(n 2 ) new Locally historical paths per update, amortized…

Handling the hard case The shortest path is different (update = increase): xy ++ If we maintain Locally historical paths using priority queues, we can find this path in O(1) time! EASY

The update algorithm Remove from the data structure all Locally historical paths containing the updated edge 1 Use remaining Locally historical paths to find an upper bound to the distances after the update 2 Propagate changes in waves from the updated edge, finding the new Locally historical paths and the new distances 3

Conclusions Locally historical paths are the heart of dynamic shortest paths O(n 2 log 3 n) amortized time per fully-update operationDistance and path query in optimal time.

Homework – 4 Formulate a practical problem as a fully dynamic all pairs shortest paths problem. (please don’t use railway or highway systems as examples.)