Dynamic graph algorithms with applications Mikkel Thorup AT&T Labs{Research
Dynamic data structures in static problems Standard example: priority queue in greedy algorithm such as Dijkstra's single source shortest path algorithm. Here we consider dynamic graph algorithms maintaining properties and objects in a changing graph. 2
Dynamic graph algorithms Updates w delete (,w) w insert (,w) Connectiity disconnected? connected (,w) w w 2-edge-connectiity bridge? 2-edge-connected (,w) w w Biconnectiity articulatiion point? biconnectied (,w) w Minimum spanning tree (MST) Update MST during insertion and deletion 3
Applications Constructing tree from homeomorphic subtrees c b a b c d a b c d Unique perfect matching We shall also talk about dynamic shortest paths and their applications. 4
Connectiity of G = (V E), jv j = n, during m updates, starting E =. Maintain spanning forest F (for dynamic forest F \eerything" takes O(log n) time) insert(( w)) if and w disconnected in F, F := F [ f( w)g delete(( w)) if ( w) 2 F, seek replacement edge from E reconnecting F n f( w)g? 5
Introduce leels ` : E! f0 ::: blog 2 ncg G i = (V fe 2 E : `(e) ig) (i) F `-maximal spanning forest ) F i = F \ G i spanning forest of G i (ii) Components of G i contain n=2 i ertices. Idea: amortize oer leel increases Insert(( w)): `(( w)) := 0. If and w disconnected in F, F [ f( w)g Delete(e): If e 2 F, F := (F nfeg) [ Replace(e) 6
Replace(e) For i := `(e) downto 0 do no replacement edge on leel > i T T 2 T < - T 2 leel i replacement connect T and T 2 jt j n=2 i+ For all leel i edges f 2 T : `(f) := i+. Consider leel i edges ( w), 2 T, one by one: If w 62 T, return f( w)g. Else `(( w)) := i +. Return Each statement iterated m log 2 n times ^ each statement supported in O(log n) time ) O(m log 2 n) total time. 7
Decremental MST of G = (V E), jv j = n, jej = m. Maintain minimum spanning forest F delete(( w)) if ( w) 2 F, seek lightest replacement from E reconnecting F nf( w)g Introduce leels ` : E! f0 ::: blog 2 ncg G i = (V fe 2 E : `(e) ig) (i) F `-maximal spanning forest ) F i = F \ G i spanning forest of G i (ii) Components of G i contain n=2 i ertices. Initially F minimum spanning forest and 8e 2 E : `(e) = 0 Delete(e): if e 2 F, F := (F nfeg) [ Replace(e) 8
Replace(e) For i := `(e) downto 0 do T T 2 T < - T 2 For all leel i edges f 2 T : `(f) := i+. Consider leel i edges ( w), 2 T, one by one, in order of increasing weight: If w 62 T, return f( w)g. Else `(( w)) := i +. Return! fully-dynamic polylogarimic MST using general reduction of Henzinger and King (ICALP'97). 9
2-edge-connectiity of G = (V E), jv j = n, during m updates, starting with E =. Maintain spanning forest F ( w) 2 E coers path w from to w in F Lem x and y 2-edge connected () x y coered. 0
Introduce leels ` : E n F! f0 ::: blog 2 ncg G i = (V F [ fe 2 E : `(e) ig) con- (i) 2-edge connected components of G i tain n=2 i ertices. For each f 2 F maintain highest leel of coering edge, denoted c(f). If f bridge, c(f) = ;. Connected(x y): 8e 2 x y : c(e) 0. Insert(( w)) If and w disconnected in F, F [ f( w)g. c(( w)) := ;. Else `(( w)) := 0 call Coer`(( w)) Coer(( w)) For all f 2 w with c(f) < `(( w)), c(f) := ( w).
Delete(e) if e 2 F, swap e in F with coering edge f on highest leel (c(f) `(e)) := (`(f) c(e)) e := f Recoer(e) 4 2 5 3 Coer only called O(m log n) times, each at polylogarithmic cost using data structures for dynamic forests. 2
Applications 3
Constructing tree from homeomorphic subtrees c b a b c d a b c d Reduction to decremental connectiity by Henzinger, King, and Warnow (SODA'96) Small trees represented as triples ((a b) c) 2 T with a b c 2 A. Obs If ((a b) c) 2 T, a and b must descend from same child of root. Make child for each component of G = (A f(a b) : ((a b) c) 2 T g) This resoles all triples ((a b) c) with c disconnected from b (and a) in G. Grandchildren found by remoing edge (a b) for each resoled triple ((a b) c). 4
Unique perfect matchings Reduction to decremental 2-edge connectiity by Gabow, Kaplan, and Tarjan (STOC'99) Lem (Kotzig 959) A unique perfect matching has a bridge. Constructing unique perfect matching, if any M := While component C of G has bridge ( w) If components of C n f( w)g both hae odd number of ertices, M := M [ f( w)g. Delete all edges incident to and w from G. Elseif components of C n f( w)g both hae een number of ertices, Delete ( w) from G. Else G has no perfect matching. EXIT. If G empty, return M Else G has no perfect matching. 5
...another application Thm (Petersen 89) Eery bridgeless 3- regular graph has a perfect matching. Biedl, Bose, Demaine, and Lubiw (SODA'99) hae used dynamic 2-edge connectiity to construct such a perfect matching in ~ O(n) time, improing oer the bound the ~ O(n 3=2 ) obtained using the general time bound for matching when m = O(n). 6
Shortest paths: some techniques Ramalingam and Reps suggested lazy Dijkstra for single source shortest paths. Running time proportional to # edges incident to ertices changing distance from source. Works great in practice. Recent break-through by Demetrescu and Italiano on all pairs-shortest path: Each ertex update supported in ~ O(n 2 ) time. Works een better in practice. Current best has update time O(n 2 (log n + log 2 (m=n)) and works for arbitrary weights [Thorup]. 7
Internet trac engineering Demand of for (s t) and (u ) General routing: max load 2/3 s t u Shortest path routing: max load or 3/4 s t u s 5 t 0 0 u 3 8
Optimizing shortest path routing with dynamic shortest paths [Fortz Thorup] Finding weights minimizing max utilization (load/capacity) within factor 3/2 is NP-hard. Cisco default: link weight inerse of capacity. Local search heuristics Iteratiely change a weight that reduces maxutilization. When inner loop tries a weight change, new shortest path routes are found and ealuated. Ramalingam and Reps gae speed-up by factor 5 with 00 nodes and 300 edges. Gained 50% oer Cisco default on AT&T IP backbone. Got within few percent of optimal general routing. 9
Concluding remarks Talked about dynamic graph algorithms and their applications in soling static problems Similar to priority queues in greedy algorithms Challenge: dynamic reachability between xed s and t for sparse graphs! better augmenting paths max-ow algorithms. 20