SlideShare una empresa de Scribd logo
1 de 53
Dynamic Graph Algorithms - I
Surender Baswana
Department of CSE, IIT Kanpur.
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 algorithmsanimation
A (static) Graph Algorithm
AlgorithmG=(V,E) Solution
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.
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)
A motivating example :
Undirected Connectivity
u
v
a aaabb b b b bc c c cccd d d d
Static
solution:
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]
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]
•
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
Examples of fully dynamic
algorithms
Fully dynamic algorithms for undirected
graphs
1. Connectivity
2. 2-edge connectivity
3. Bi-connectivity
4. Bipartiteness
5. Min. spanning tree
O(polylog n) update time [Holm, Litchenberg, Thorup 1998]
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]
•
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
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]
•
Data structure for dynamic trees
Data structures
• Stacks
• Queues
• Binary heap
• Binary search tree
...
• Fibinaacci heap
• Too elementary
• Limited applications
• Too complex
• Hardly any application !
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.
Balanced Binary Tree : a very powerful data structure
: Additional information
Dynamic Trees
ef
a
u
c
gj
d
b
w v u
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
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)
Dynamic Trees
query 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
Dynamic Trees
query 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
Dynamic Trees
query 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
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 ?
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
b
c
d
e
g
h
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
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
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
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
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
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
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
Fully dynamic algorithm for
connectivity
Fully dynamic randomized algorithm for connectivity with
polylogarithmic update time
Fully dynamic randomized algorithm for connectivity with
polylogarithmic update time
Maintain ET tree for each tree in
the spanning forest
Fully dynamic randomized algorithm for connectivity with
polylogarithmic update time
Maintain ET tree for each tree in
the spanning forest
Fully dynamic randomized algorithm for connectivity with
polylogarithmic update time
A Hierarchical algorithm
1
2
3
2 log
n
Fully dynamic randomized algorithm for
connectivity with O() update time
1
2
A 2-level algorithm
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
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
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 ?
Handling the deletion of a tree edge
2-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
Handling the deletion of a tree edge
Level 1
Level 2
Handling the deletion of a tree edge
Level 1
Level 2
Trivial algorithm at level 2
Random sampling at level 1
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)) time
probability
 
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 Tϵ 2
•
Level 1
Level 2
T2T1
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()
•
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()
•
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
•
Fully dynamic randomized algorithm for connectivity with
polylogarithmic update time
A Hierarchical algorithm
1
2
2 log
n
c
2
Open Problems
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 ?

Más contenido relacionado

La actualidad más candente

19. algorithms and-complexity
19. algorithms and-complexity19. algorithms and-complexity
19. algorithms and-complexity
ashishtinku
 
Es400 fall 2012_lecuture_2_transformation_of_continuous_time_signal.pptx
Es400 fall 2012_lecuture_2_transformation_of_continuous_time_signal.pptxEs400 fall 2012_lecuture_2_transformation_of_continuous_time_signal.pptx
Es400 fall 2012_lecuture_2_transformation_of_continuous_time_signal.pptx
umavijay
 
20151021_DataScienceMeetup_revised
20151021_DataScienceMeetup_revised20151021_DataScienceMeetup_revised
20151021_DataScienceMeetup_revised
rerngvit yanggratoke
 

La actualidad más candente (19)

19. algorithms and-complexity
19. algorithms and-complexity19. algorithms and-complexity
19. algorithms and-complexity
 
Implementation of Thorup's Linear Time Algorithm for Undirected Single Source...
Implementation of Thorup's Linear Time Algorithm for Undirected Single Source...Implementation of Thorup's Linear Time Algorithm for Undirected Single Source...
Implementation of Thorup's Linear Time Algorithm for Undirected Single Source...
 
Large scale logistic regression and linear support vector machines using spark
Large scale logistic regression and linear support vector machines using sparkLarge scale logistic regression and linear support vector machines using spark
Large scale logistic regression and linear support vector machines using spark
 
Histogram Operation in Image Processing
Histogram Operation in Image ProcessingHistogram Operation in Image Processing
Histogram Operation in Image Processing
 
Iare ds ppt_3
Iare ds ppt_3Iare ds ppt_3
Iare ds ppt_3
 
Some Developments in Space-Time Modelling with GIS Tao Cheng – University Col...
Some Developments in Space-Time Modelling with GIS Tao Cheng – University Col...Some Developments in Space-Time Modelling with GIS Tao Cheng – University Col...
Some Developments in Space-Time Modelling with GIS Tao Cheng – University Col...
 
Sergei Vassilvitskii, Research Scientist, Google at MLconf NYC - 4/15/16
Sergei Vassilvitskii, Research Scientist, Google at MLconf NYC - 4/15/16Sergei Vassilvitskii, Research Scientist, Google at MLconf NYC - 4/15/16
Sergei Vassilvitskii, Research Scientist, Google at MLconf NYC - 4/15/16
 
Es400 fall 2012_lecuture_2_transformation_of_continuous_time_signal.pptx
Es400 fall 2012_lecuture_2_transformation_of_continuous_time_signal.pptxEs400 fall 2012_lecuture_2_transformation_of_continuous_time_signal.pptx
Es400 fall 2012_lecuture_2_transformation_of_continuous_time_signal.pptx
 
4. operations of signals
4. operations of signals 4. operations of signals
4. operations of signals
 
Learning to discover monte carlo algorithm on spin ice manifold
Learning to discover monte carlo algorithm on spin ice manifoldLearning to discover monte carlo algorithm on spin ice manifold
Learning to discover monte carlo algorithm on spin ice manifold
 
Phase Retrieval: Motivation and Techniques
Phase Retrieval: Motivation and TechniquesPhase Retrieval: Motivation and Techniques
Phase Retrieval: Motivation and Techniques
 
Gradient descent optimizer
Gradient descent optimizerGradient descent optimizer
Gradient descent optimizer
 
Lecture3 Signal and Systems
Lecture3 Signal and SystemsLecture3 Signal and Systems
Lecture3 Signal and Systems
 
SIGNAL OPERATIONS
SIGNAL OPERATIONSSIGNAL OPERATIONS
SIGNAL OPERATIONS
 
Digital signal System
Digital signal SystemDigital signal System
Digital signal System
 
Adaptive dynamic programming algorithm for uncertain nonlinear switched systems
Adaptive dynamic programming algorithm for uncertain nonlinear switched systemsAdaptive dynamic programming algorithm for uncertain nonlinear switched systems
Adaptive dynamic programming algorithm for uncertain nonlinear switched systems
 
An improved spfa algorithm for single source shortest path problem using forw...
An improved spfa algorithm for single source shortest path problem using forw...An improved spfa algorithm for single source shortest path problem using forw...
An improved spfa algorithm for single source shortest path problem using forw...
 
20151021_DataScienceMeetup_revised
20151021_DataScienceMeetup_revised20151021_DataScienceMeetup_revised
20151021_DataScienceMeetup_revised
 
An improved spfa algorithm for single source shortest path problem using forw...
An improved spfa algorithm for single source shortest path problem using forw...An improved spfa algorithm for single source shortest path problem using forw...
An improved spfa algorithm for single source shortest path problem using forw...
 

Destacado

문제는 한글이 잘 구현되는가?
문제는 한글이 잘 구현되는가?문제는 한글이 잘 구현되는가?
문제는 한글이 잘 구현되는가?
Choi Man Dream
 
nhận thiết kế clip quảng cáo giá tốt
nhận thiết kế clip quảng cáo giá tốtnhận thiết kế clip quảng cáo giá tốt
nhận thiết kế clip quảng cáo giá tốt
raul110
 

Destacado (20)

4.1 webminig
4.1 webminig 4.1 webminig
4.1 webminig
 
160607 14 sw교육_강의안
160607 14 sw교육_강의안160607 14 sw교육_강의안
160607 14 sw교육_강의안
 
5.2 divede and conquer 03
5.2 divede and conquer 035.2 divede and conquer 03
5.2 divede and conquer 03
 
РЕКЛАМНЫЕ МОДЕЛИ
РЕКЛАМНЫЕ МОДЕЛИРЕКЛАМНЫЕ МОДЕЛИ
РЕКЛАМНЫЕ МОДЕЛИ
 
1.9 b trees 02
1.9 b trees 021.9 b trees 02
1.9 b trees 02
 
평범한 이야기[Intro: 2015 의기제]
평범한 이야기[Intro: 2015 의기제]평범한 이야기[Intro: 2015 의기제]
평범한 이야기[Intro: 2015 의기제]
 
4.2 bst 02
4.2 bst 024.2 bst 02
4.2 bst 02
 
1.9 b trees eg 03
1.9 b trees eg 031.9 b trees eg 03
1.9 b trees eg 03
 
4.2 bst 03
4.2 bst 034.2 bst 03
4.2 bst 03
 
5.4 randomized datastructures
5.4 randomized datastructures5.4 randomized datastructures
5.4 randomized datastructures
 
RESUME-ARITRA BHOWMIK
RESUME-ARITRA BHOWMIKRESUME-ARITRA BHOWMIK
RESUME-ARITRA BHOWMIK
 
2.4 mst prim &kruskal demo
2.4 mst  prim &kruskal demo2.4 mst  prim &kruskal demo
2.4 mst prim &kruskal demo
 
문제는 한글이 잘 구현되는가?
문제는 한글이 잘 구현되는가?문제는 한글이 잘 구현되는가?
문제는 한글이 잘 구현되는가?
 
Salario minimo basico
Salario minimo basicoSalario minimo basico
Salario minimo basico
 
nhận thiết kế clip quảng cáo giá tốt
nhận thiết kế clip quảng cáo giá tốtnhận thiết kế clip quảng cáo giá tốt
nhận thiết kế clip quảng cáo giá tốt
 
4.4 hashing02
4.4 hashing024.4 hashing02
4.4 hashing02
 
2.4 mst kruskal’s
2.4 mst  kruskal’s 2.4 mst  kruskal’s
2.4 mst kruskal’s
 
Online Trading Concepts
Online Trading ConceptsOnline Trading Concepts
Online Trading Concepts
 
trabajo de cultural
trabajo de culturaltrabajo de cultural
trabajo de cultural
 
5.4 randamized algorithm
5.4 randamized algorithm5.4 randamized algorithm
5.4 randamized algorithm
 

Similar a 5.3 dyn algo-i

Mit15 082 jf10_lec01
Mit15 082 jf10_lec01Mit15 082 jf10_lec01
Mit15 082 jf10_lec01
Saad Liaqat
 
19. algorithms and-complexity
19. algorithms and-complexity19. algorithms and-complexity
19. algorithms and-complexity
showkat27
 
Sampling and Reconstruction (Online Learning).pptx
Sampling and Reconstruction (Online Learning).pptxSampling and Reconstruction (Online Learning).pptx
Sampling and Reconstruction (Online Learning).pptx
HamzaJaved306957
 
Stack squeues lists
Stack squeues listsStack squeues lists
Stack squeues lists
James Wong
 
Stacksqueueslists
StacksqueueslistsStacksqueueslists
Stacksqueueslists
Fraboni Ec
 
Stacks queues lists
Stacks queues listsStacks queues lists
Stacks queues lists
Tony Nguyen
 

Similar a 5.3 dyn algo-i (20)

Q
QQ
Q
 
DIGITAL IMAGE PROCESSING - Day 4 Image Transform
DIGITAL IMAGE PROCESSING - Day 4 Image TransformDIGITAL IMAGE PROCESSING - Day 4 Image Transform
DIGITAL IMAGE PROCESSING - Day 4 Image Transform
 
Introduction to data structures and complexity.pptx
Introduction to data structures and complexity.pptxIntroduction to data structures and complexity.pptx
Introduction to data structures and complexity.pptx
 
Mit15 082 jf10_lec01
Mit15 082 jf10_lec01Mit15 082 jf10_lec01
Mit15 082 jf10_lec01
 
19. algorithms and-complexity
19. algorithms and-complexity19. algorithms and-complexity
19. algorithms and-complexity
 
Review session2
Review session2Review session2
Review session2
 
Week2-stacks-queues.pptx
Week2-stacks-queues.pptxWeek2-stacks-queues.pptx
Week2-stacks-queues.pptx
 
Real-Time Top-R Topic Detection on Twitter with Topic Hijack Filtering
Real-Time Top-R Topic Detection on Twitter with Topic Hijack FilteringReal-Time Top-R Topic Detection on Twitter with Topic Hijack Filtering
Real-Time Top-R Topic Detection on Twitter with Topic Hijack Filtering
 
Sampling and Reconstruction (Online Learning).pptx
Sampling and Reconstruction (Online Learning).pptxSampling and Reconstruction (Online Learning).pptx
Sampling and Reconstruction (Online Learning).pptx
 
Stack squeues lists
Stack squeues listsStack squeues lists
Stack squeues lists
 
Stacks queues lists
Stacks queues listsStacks queues lists
Stacks queues lists
 
Stacksqueueslists
StacksqueueslistsStacksqueueslists
Stacksqueueslists
 
Stacks queues lists
Stacks queues listsStacks queues lists
Stacks queues lists
 
Stacks queues lists
Stacks queues listsStacks queues lists
Stacks queues lists
 
Stacks queues lists
Stacks queues listsStacks queues lists
Stacks queues lists
 
SP_BEE2143_C1.pptx
SP_BEE2143_C1.pptxSP_BEE2143_C1.pptx
SP_BEE2143_C1.pptx
 
Asymptotics 140510003721-phpapp02
Asymptotics 140510003721-phpapp02Asymptotics 140510003721-phpapp02
Asymptotics 140510003721-phpapp02
 
Noisy optimization --- (theory oriented) Survey
Noisy optimization --- (theory oriented) SurveyNoisy optimization --- (theory oriented) Survey
Noisy optimization --- (theory oriented) Survey
 
Chap12 slides
Chap12 slidesChap12 slides
Chap12 slides
 
Learning to Reconstruct
Learning to ReconstructLearning to Reconstruct
Learning to Reconstruct
 

Más de Krish_ver2

Más de Krish_ver2 (20)

5.5 back tracking
5.5 back tracking5.5 back tracking
5.5 back tracking
 
5.5 back track
5.5 back track5.5 back track
5.5 back track
 
5.5 back tracking 02
5.5 back tracking 025.5 back tracking 02
5.5 back tracking 02
 
5.4 randomized datastructures
5.4 randomized datastructures5.4 randomized datastructures
5.4 randomized datastructures
 
5.3 dynamic programming 03
5.3 dynamic programming 035.3 dynamic programming 03
5.3 dynamic programming 03
 
5.3 dynamic programming
5.3 dynamic programming5.3 dynamic programming
5.3 dynamic programming
 
5.2 divede and conquer 03
5.2 divede and conquer 035.2 divede and conquer 03
5.2 divede and conquer 03
 
5.2 divide and conquer
5.2 divide and conquer5.2 divide and conquer
5.2 divide and conquer
 
5.1 greedyyy 02
5.1 greedyyy 025.1 greedyyy 02
5.1 greedyyy 02
 
5.1 greedy
5.1 greedy5.1 greedy
5.1 greedy
 
5.1 greedy 03
5.1 greedy 035.1 greedy 03
5.1 greedy 03
 
4.4 hashing
4.4 hashing4.4 hashing
4.4 hashing
 
4.4 hashing ext
4.4 hashing  ext4.4 hashing  ext
4.4 hashing ext
 
4.4 external hashing
4.4 external hashing4.4 external hashing
4.4 external hashing
 
4.2 bst
4.2 bst4.2 bst
4.2 bst
 
4.1 sequentioal search
4.1 sequentioal search4.1 sequentioal search
4.1 sequentioal search
 
3.9 external sorting
3.9 external sorting3.9 external sorting
3.9 external sorting
 
3.8 quicksort
3.8 quicksort3.8 quicksort
3.8 quicksort
 
3.8 quick sort
3.8 quick sort3.8 quick sort
3.8 quick sort
 
3.8 quicksort 04
3.8 quicksort 043.8 quicksort 04
3.8 quicksort 04
 

Último

Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Último (20)

psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 

5.3 dyn algo-i

  • 1. Dynamic Graph Algorithms - I Surender Baswana Department of CSE, IIT Kanpur.
  • 2. 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 algorithmsanimation
  • 3. A (static) Graph Algorithm AlgorithmG=(V,E) Solution
  • 4. 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.
  • 5. 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)
  • 6. A motivating example : Undirected Connectivity u v a aaabb b b b bc c c cccd d d d Static solution:
  • 7. 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]
  • 8. 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] •
  • 9. 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
  • 10. Examples of fully dynamic algorithms
  • 11. Fully dynamic algorithms for undirected graphs 1. Connectivity 2. 2-edge connectivity 3. Bi-connectivity 4. Bipartiteness 5. Min. spanning tree O(polylog n) update time [Holm, Litchenberg, Thorup 1998]
  • 12. 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] •
  • 13. 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
  • 14. 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] •
  • 15. Data structure for dynamic trees
  • 16. Data structures • Stacks • Queues • Binary heap • Binary search tree ... • Fibinaacci heap • Too elementary • Limited applications • Too complex • Hardly any application !
  • 17. 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.
  • 18. Balanced Binary Tree : a very powerful data structure : Additional information
  • 20. 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
  • 21. 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)
  • 22. Dynamic Trees query 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
  • 23. Dynamic Trees query 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
  • 24. Dynamic Trees query 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
  • 25. 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 ?
  • 26. 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 b c d e g h
  • 27. 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
  • 28. 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
  • 29. 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
  • 30. 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
  • 31. 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
  • 32. 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
  • 33. 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
  • 34. Fully dynamic algorithm for connectivity
  • 35. Fully dynamic randomized algorithm for connectivity with polylogarithmic update time
  • 36. Fully dynamic randomized algorithm for connectivity with polylogarithmic update time Maintain ET tree for each tree in the spanning forest
  • 37. Fully dynamic randomized algorithm for connectivity with polylogarithmic update time Maintain ET tree for each tree in the spanning forest
  • 38. Fully dynamic randomized algorithm for connectivity with polylogarithmic update time A Hierarchical algorithm 1 2 3 2 log n
  • 39. Fully dynamic randomized algorithm for connectivity with O() update time 1 2 A 2-level algorithm
  • 40. 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
  • 41. 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
  • 42. 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 ?
  • 43. Handling the deletion of a tree edge 2-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
  • 44. Handling the deletion of a tree edge Level 1 Level 2
  • 45. Handling the deletion of a tree edge Level 1 Level 2 Trivial algorithm at level 2 Random sampling at level 1
  • 46. 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)) time probability  
  • 47. 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 Tϵ 2 • Level 1 Level 2 T2T1
  • 48. 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() •
  • 49. 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() •
  • 50. 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 •
  • 51. Fully dynamic randomized algorithm for connectivity with polylogarithmic update time A Hierarchical algorithm 1 2 2 log n c 2
  • 53. 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 ?