Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


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

1 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), 968-992. 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

2 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):

3 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 2.575 C 0.681 ) ~ [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)

4 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.

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

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

7 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

8 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

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

10 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

11 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…

12 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

13 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.

14 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

15 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

16 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.

17 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.

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

19 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

20 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!

21 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

22 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...

23 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…

24 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.

25 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(π)).

26 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 ).

27 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.

28 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.

29 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.

30 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.

31 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

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

33 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)

34  (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. 100 90 # h paths =  (n 2 )+  (n 2 ) 100 90 80 +  (n 2 ) 100 90 80 70 =  (n 3 )  (n)

35 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 = 100 90  (n 2 ) 90 100 90  (n 2 ) 100 90 80 100 80 100 90 80  (n 2 ) 100 90 80 70 100 90 70 100 90 80 70 0 (in general, O(n 2 ))

36 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…

37 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

38 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

39 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.

40 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.)


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

Similar presentations


Ads by Google