Download - Dynamic Graph Algorithms - I
![Page 1: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/1.jpg)
Dynamic Graph Algorithms - I
Surender BaswanaDepartment of CSE, IIT Kanpur.
![Page 2: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/2.jpg)
About this talk
• Prerequisite: a course on data structure and algorithms
• Survey of the results: (not the main objective of the talk)
• Main contents: -- A novel data structure
-- A fully dynamic algorithm for a fundamental graph problem AIM: To give an exposure to the beautiful area of dynamic algorithms
ANIMATION
![Page 3: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/3.jpg)
A (static) Graph Algorithm
AlgorithmG=(V,E) Solution
![Page 4: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/4.jpg)
A dynamic graph algorithm
• For problems involving queries (connectivity, distance,…): initial graph G=(V,E) followed by a sequence
q,u,u,q,u,u,u,q,u,q,q,u, … q: query u: insertion/deletion of edge
Each query has to be answered in an online manner.• For problems that aim to maintain some structure (matching, spanner,
min-cut,…) initial graph G=(V,E) followed by a sequence
u,u,u,u,u,u,u, … The structure has to be maintained in an online manner.
No assumption about the updates.
![Page 5: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/5.jpg)
Dynamic graph algorithm
Aim: Maintain a data structure which can • answer each query efficiently (or maintain the structure), and • process each update efficiently (much faster than the static algo)
Types of dynamic graph algorithms:
• Incremental (only insertion of edges)• Decremental (only deletion of edges)• Fully dynamic (both insertion and deletion of edges)
![Page 6: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/6.jpg)
A motivating example :Undirected Connectivity
u
v
a aaabb b b b bc c c cccd d d d
Static solution:
![Page 7: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/7.jpg)
A motivating example :Undirected Connectivity
• Incremental Algorithm: O(log* n) update time (Disjoint Set Union Algorithm [Tarjan 1975])
• Decremental Algorithm:– O(n) update time [Even and Shiloach, 1981]
– O(log n) update time [Thorup 1997]
![Page 8: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/8.jpg)
A motivating example :Undirected Connectivity
Fully Dynamic Algorithms:1. O() update time [Frederickson, 1982]
2. O() update time [Eppstein, Galil, Italiano, Nissenzweig 1991]
3. O(polylog n) expected update time, O(log n) query time [King and Henzinger 1995]
4. O(polylog n) update time, O(log n) query time [Holm, Litchenberg, Thorup 1998]
![Page 9: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/9.jpg)
Outline of the talk
• Dynamic graph algorithms for some important problems
• Data structure for dynamic trees
• Fully dynamic connectivity with polylog n update time
• Open problems
![Page 10: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/10.jpg)
EXAMPLES OF FULLY DYNAMIC ALGORITHMS
![Page 11: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/11.jpg)
Fully dynamic algorithms for undirected graphs
1. Connectivity2. 2-edge connectivity3. Bi-connectivity4. Bipartiteness5. Min. spanning tree
O(polylog n) update time [Holm, Litchenberg, Thorup 1998]
![Page 12: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/12.jpg)
Fully dynamic algorithms for undirected graphs
• Min-cut – Best static algorithm: O(m polylog n) (Randomized) [Karger, 1996]– Fully dynamic algorithm: O() update time [Thorup, 2001]
• Graph spanner Definition: A subgraph which is sparse and yet preserves all-pairs distances approximately.
– Best static algorithm: O(m) [Halperin, Zwick, 1996]– Fully dynamic algorithm: O(polylog n) update time [Baswana, Khurana, and Sarkar, 2008]
![Page 13: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/13.jpg)
Dynamic algorithms for directed graphs
Maintaining BFS tree under deletion of edges : O(n) time per edge deletion [Even & Shiloach, 1981]
• Unbeaten till date.• Used in many dynamic algorithms for directed graphs.
Not as good bounds as undirected graphs
![Page 14: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/14.jpg)
Dynamic algorithms for directed graphs
Transitive Closure• Incremental algorithm: O(n) update time [Italiano, 1986]• Decremental algorithm: O(n) update time
– Randomized [Roditty and Zwick, 2002]– Deterministic [Lacki, 2011 ]
• Fully Dynamic algorithm: O() update time [Roditty, 2003]
All-pairs Shortest paths• Fully dynamic algorithms:
– Amortized O() update time [Demetrescu and Italiano, 2003]– Worst case O() update time [Thorup, 2005]
![Page 15: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/15.jpg)
DATA STRUCTURE FOR DYNAMIC TREES
![Page 16: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/16.jpg)
Data structures
• Stacks• Queues• Binary heap • Binary search tree ...• Fibinaacci heap
• Too elementary• Limited applications
• Too complex• Hardly any application !
![Page 17: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/17.jpg)
Power of Data structures:An inspirational example
Maintain n records r(1),…,r(n) under the following operations• Add(i,j,x) : Add x to each record from r(i),…,r(j).• All-swap(i,j) : r(i)↔r(j), r(i+1) ↔ r(j-1), r(i+2) ↔ r(j-2).• Report(i) : report record r(i).• Report-min(i,j) : report the smallest record from r(i),…,r(j).
Each operation in O(log n) worst case time.
![Page 18: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/18.jpg)
Balanced Binary Tree : a very powerful data structure
: Additional information
![Page 19: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/19.jpg)
Dynamic Trees
ef
a
u
c
gj
d
b
w v u
![Page 20: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/20.jpg)
Dynamic Trees
Aim : Maintain a forest of trees on n vertices under the following operation. • Link(u,v) : Add an edge between u and v• Cut(u,v) : Delete an edge between u and v
• Update() : Update information associated with nodes/edges• Query() :
– Topological– information associated with a tree, or a path
![Page 21: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/21.jpg)
Data Structures for Dynamic Trees
• ST Tree [Sleator & Tarjan, 1983]
Operations and queries on edges of paths
• ET tree [Henzinger and King, 1995]
Operations and queries on nodes of a tree
• Top tree [Alstrup et al., TALG 2005] (generalization of Topology Tree [Frederickson, 1982])
Topological properties (diameter, center)
![Page 22: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/22.jpg)
Dynamic Treesquery and updates on trees
Operations :• Link(u,v)• Cut(u,v)
• Update-weight-node(v,a): weight(v) a
• Add-weight-tree(v,x): add x to weight of each node of tree of v
• ReportMin(u):
report min weight in the entire tree containing u
a
u
c
g
ef
j
d
b
w v u
5
12-3
741
172
32
3
44 67 15
![Page 23: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/23.jpg)
Dynamic Treesquery and updates on trees
ReportMin(v) = 12
Operations :• Link(u,v)• Cut(u,v)
• Update-weight-node(v,a): weight(v) a
• Add-weight-tree(v,x): add x to weight of each node of tree of v
• ReportMin(u):
report min weight in the entire tree containing u
a
u
c
g
ef
j
d
b
w v u
5
12-3
741
172
32
3
44 67 15
![Page 24: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/24.jpg)
Dynamic Treesquery and updates on trees
ReportMin(v) changes …
Operations :• Link(u,v)• Cut(u,v)
• Update-weight-node(v,a): weight(v) a
• Add-weight-tree(v,x): add x to weight of each node of tree of v
• ReportMin(u):
report min weight in the entire tree containing u
a
u
c
g
ef
j
d
b
w v u
5
12-3
741
172
32
3
44 67 1
![Page 25: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/25.jpg)
Euler tour tree :A data structure for
dynamic trees a b ce
f
g
h d
b-c-d-c-b-a-e-f-e-g-e-h-e-a-b
b d b e e
c
c
a
f
e
g
h
a
e b
How to transform a tree into a one dimensional data
structure ?
![Page 26: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/26.jpg)
Euler tour tree :A data structure for
dynamic trees
: minimum value of all nodes in the subtree.
a b ce
f
g
h d
b-c-d-c-b-a-e-f-e-g-e-h-e-a-b
b d b e e
c
c
a
f
e
g
h
a
e b
a
f
bc
de
gh
![Page 27: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/27.jpg)
Euler tour tree :A data structure for
dynamic trees a b ce
f
g
h d
b-c-d-c-b-a- e-f-e-g-e-h-e -a-b
![Page 28: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/28.jpg)
Euler tour tree :A data structure for
dynamic trees a b ce
f
g
h d
b-c-d-c-b-a-e-f-e-g-e-h-e-a-b
![Page 29: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/29.jpg)
Euler tour tree :A data structure for
dynamic trees a b ce
f
g
h d
a-bb-c-d-c-b-a
e-f-e-g-e-h-e
T1 T2
T1
![Page 30: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/30.jpg)
Euler tour tree :A data structure for
dynamic trees a b ce
f
g
h d
a-bb-c-d-c-b-a
T1 T2
T1
T1
e-f-e-g-e-h-e
![Page 31: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/31.jpg)
Euler tour tree :A data structure for
dynamic trees a b ce
f
g
h d
a-bb-c-d-c-b-a
e-f-e-g-e-h-e
T1 T2
T1
T1
![Page 32: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/32.jpg)
Euler tour tree :A data structure for
dynamic trees a b ce
f
g
h d
a-bb-c-d-c-b-a
e-f-e-g-e-h-e
T1 T2
T1
T1
![Page 33: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/33.jpg)
Euler tour tree :A data structure for
dynamic trees
• Split(T,(e,a))
• Merge(T1,T2,(u,v))
• Change-origin(T,x) : change the origin of Euler tour to vertex x.
a b ce
f
g
h d
b-c-d-c-b-a-be-f-e-g-e-h-e
T1 T2
T1
T1
T2
T2
![Page 34: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/34.jpg)
FULLY DYNAMIC ALGORITHM FOR CONNECTIVITY
![Page 35: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/35.jpg)
Fully dynamic randomized algorithm for connectivity with polylogarithmic update time
![Page 36: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/36.jpg)
Fully dynamic randomized algorithm for connectivity with polylogarithmic update time
Maintain ET tree for each tree in the spanning forest
![Page 37: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/37.jpg)
Fully dynamic randomized algorithm for connectivity with polylogarithmic update time
Maintain ET tree for each tree in the spanning forest
![Page 38: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/38.jpg)
Fully dynamic randomized algorithm for connectivity with polylogarithmic update time
A Hierarchical algorithm
1
2
3
2 log n
![Page 39: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/39.jpg)
Fully dynamic randomized algorithm for connectivity with O() update time
1
2
A 2-level algorithm
![Page 40: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/40.jpg)
Decremental O() update time algorithm for connectivity
Key tools in addition to ET tree data structure:
• Trivial algorithm (for handling deletion of a tree edge) : Let (u,v) be a tree edge in the spanning forest. Let its deletion creates trees T1 and T2. Let µ be the number of non-tree edges incident on T2. Replacement edge can be found in time O(µ log n) time.
• Random sampling
![Page 41: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/41.jpg)
The role of random sampling
• Exercise: If none of 2k log n balls is blue, then with probability , the fraction of blue balls is less than 1/k.
Uniform random sampling with replacement
![Page 42: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/42.jpg)
Handling the deletion of a tree edge
T2T1 T
T2
How to augment ET-tree to sample an edge ?
Few samplings needed if the
fraction of blue edges is large
What if fraction of blue edges is small ?
![Page 43: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/43.jpg)
Handling the deletion of a tree edge2-Level approach
• A partition of E into two levels : (E1, E2) In the beginning, E1 = E and E1 = Ø • F1 : spanning forest of E1
• F2 : spanning forest of E, F1 is subset of F2
Level 1
Level 2
![Page 44: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/44.jpg)
Handling the deletion of a tree edge
Level 1
Level 2
![Page 45: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/45.jpg)
Handling the deletion of a tree edge
Level 1
Level 2
Trivial algorithm at level 2
Random sampling at level 1
![Page 46: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/46.jpg)
Algorithm for handling deletion of a tree edge
If (e ϵ F2 \ F1) scan non-tree edges at level 2 to find replacement edge.Else Let T be the tree to which e belongs; (T1,T2) Split(T,e); Repeat k log n times { (u,v) Sample-edge(T2); If (u,v) is a cut-edge { add (u,v) to F1; Merge(T1,T2, (u,v)); return; } } Scan all non-tree edges incident on T2; If less than 1/k fraction are cut-edges move all edges of cut(T1,T2) to Level 2 and add one of them to F2. Else add an edge of cut(T1,T2) to F1
O(µ2) time
O(k logn) time
O(µ1(T2)) timeprobability
![Page 47: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/47.jpg)
Bounding µ2 (number of non-tree edges at level 2)
Upon splitting T into T1 and T2, how many edges are passed to level 2 ?
≤ charge to each ϵ T2
Level 1
Level 2
T2T1
![Page 48: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/48.jpg)
Analysis
• A vertex v is processed only O(log n) times. Whenever v is processed
The processing cost of v is O(deg(v)) The number of edges that move to level 2 is less than
Hence µ2 , the number of edges at level 2 is O(log n)
• Processing cost per update : log n + k + O(m) = O()
![Page 49: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/49.jpg)
Transforming to fully dynamic environment
• Add every newly inserted edge to level 2.
• Periodically rebuild the data structure after every () insertions.
Expected amortized time per update : O()
![Page 50: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/50.jpg)
Fully dynamic randomized algorithm for connectivity with polylogarithmic update time
• A partition of E into 2log n levels : (E1, E2, …) In the beginning, E1 = E and Ei = Ø for all i>1• F1 : spanning forest of E1
• Fi : spanning forest of • Fi-1 is subset of Fi for all i>1
![Page 51: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/51.jpg)
Fully dynamic randomized algorithm for connectivity with polylogarithmic update time
A Hierarchical algorithm
1
2
2 log n
c
2
![Page 52: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/52.jpg)
OPEN PROBLEMS
![Page 53: Dynamic Graph Algorithms - I](https://reader035.vdocument.in/reader035/viewer/2022062411/56816743550346895ddbf82f/html5/thumbnails/53.jpg)
Open problems
• Amortized cost versus worst case bounds
• Specific problems : Min-cut, s-t min cut, max-flow, …
• Specific graph family : Planar graphs
• Better lower bounds ?