Dynamic Graph Algorithms III Surender Baswana Visiting Professor till 31st May 2020 Heinz Nixdorf Institute & Department of Computer Science (Algorithms and Complexity Group) sbaswana@campus.uni-paderborn.de sbaswana@gmail.com
Dynamic DFS tree problem
Revisiting DFS traversal Part I Revisiting DFS traversal
DFS traversal A recursive way to traverse the graph DFS(v) { Visited(v) ← true; For each neighbor w of v { { DFS(w) ; } DFS-traversal(G) { For each vertex vϵ V Visited(v)← false; For each vertex v ϵ V If (Visited(v ) = false) DFS(v); v z y c d b f g h u w r s if (Visited(w) = false) ……..; ……..; A DFS tree rooted at v
DFS traversal Applications: Connected components of a graph. a milestone in the area of graph algorithms Applications: Connected components of a graph. Finding articulation points in a graph. Finding bridges in a graph. Planarity testing of a graph Strongly connected components of a directed graph. O(𝑚+𝑛) time
How will an edge appear in DFS traversal ?
How will an edge appear in DFS traversal ? It can never happen u x y
DFS traversal from a non-root vertex? y f b h v w d g x y z s c
Flexibility versus restriction h v w d g x y z s c
Problem: Dynamic DFS tree Part II Problem: Dynamic DFS tree
Dynamic DFS tree Problem: Preprocess a given graph 𝐺=(𝑉,𝐸) to build a data structure s.t. for any online sequence of edge insertion/deletion a DFS tree can be maintained efficiently.
Partially dynamic algorithms Directed Acyclic Graph (DAG): Undirected Graphs: Problem Total Update time Reference Incremental 𝑂(𝑚𝑛) Franciosa et al. (ESA 1996) Decremental 𝑂 𝑚𝑛 log 𝑛 (expected) B and Choudhary (MFCS 2015) Problem Total Update time Reference Incremental 𝑂(𝑚𝑛) Franciosa et al. (1997) Emphasize on the slide Notice the following: Firstly the only known results are partially dynamic Problem Total Update time Reference Incremental 𝑂( 𝑛 2 ) B and Khan (ICALP 2014)
Fully dynamic algorithms Undirected Graphs: Problem Time per Update Reference Fully Dynamic* 𝑶( 𝑚𝑛 log 2.5 𝑛 ) B, Chaudhury, Choudhary, Khan (SODA 2016) Simple enough to be taught at Undergrad course on algorithms. Recent, unpublished, joint work with Shiv Gupta and Ayush Tulsyan at IITK 𝑶( 𝑚𝑛 log 𝑛 ) * Supports both edge and vertex updates.
Familiarizing with the dynamic DFS tree problem Part III Familiarizing with the dynamic DFS tree problem
Insertion of an edge u y x Reroot this subtree at y
Deletion of an edge x y v Reroot this subtree at v
A novel decomposition of a tree Part IV A novel decomposition of a tree
Heavy path decomposition of tree
Heavy path decomposition of tree
Heavy path decomposition of tree
Heavy path decomposition of tree
Heavy path decomposition of tree
Shallow Tree 𝑝 1 𝑝 2 𝑝 3 𝑝 4 𝑝 6 𝑝 5 A tree of arbitrary height Heavy path decomposition Shallow Tree 𝑝 1 𝑝 2 𝑝 3 𝑝 4 𝑝 6 𝑝 5
Algorithm for Rerooting a DFS tree Part V Algorithm for Rerooting a DFS tree
𝑝 T
𝑝
Exploit Flexibility of DFS 𝑝
How to ensure fewer edges in a reduced adjacency list ? Time to respect the Restriction of DFS Idea: 𝑣 Compute a reduced adjacency list for each vertex 𝑣 in a lazy manner 𝑝
More insight into DFS traversal Part VI More insight into DFS traversal
u Observation 1 Redundant v w x Connected components
Observation 2 Redundant v Redundant u w x Connected components
Resuming the algorithm for Rerooting a DFS tree Part VII Resuming the algorithm for Rerooting a DFS tree
For each 𝑢 on 𝒑, For each ancestor path of 𝒑 Add only one edge to Adj(𝑢) No. of edges added to Adj(𝑢): O(log 𝑛) Observation 2 𝑣 𝑝
But before that, can you figure out the entire algorithm now ? For each descendant 𝑥 of 𝒑, edge incident on 𝒑 Add (𝑥,𝑤) to Adj(𝑤) No. of edges added by 𝑥 to its ancestors ? (𝑥,𝑤) nearest to 𝑣. Seems many Observation 1 Data Structure for each vertex 𝑥 : But before that, can you figure out the entire algorithm now ? Edges to ancestors in sorted order 𝑣 𝑤 𝑝 𝑥
Begin with the heavy path decomposition of the original DFS tree. Traverse the longer portion of the path Populate reduced adj. list of traversed path Do DFS starting from most recently visited vertex You might enter another path Do DFS traversal from the most recently visited vertex Do DFS traversal from the most … 𝑝 1 (say 𝑝 2 ) 𝑝 7 Begin with the heavy path decomposition of the original DFS tree. 𝑝 6 (say 𝑝 7 ) 𝑝 1 𝑝 3 𝑝 2 New root 𝑝 5 𝑝 4
Algorithm can be seen as a walk on the shallow tree 𝑝 7 𝑝 6 𝑝 1 𝑝 2 𝑝 3 𝑝 4 𝑝 5
For each descendant 𝑥 of 𝒑, edge incident on 𝒑 Add (𝑥,𝑤) to Adj(𝑤) No. of edges added by 𝑥 to its ancestors ? (𝑥,𝑤) nearest to 𝑣. Seems many O( log 2 𝑛) Observation 1 𝑣 𝑤 𝑝 𝑥
Theorem: A DFS tree 𝑇 of a given graph 𝐺=(𝑉,𝐸) can be preprocessed in O(𝑚) time to build a data structure of O(𝑚) size s.t. for any vertex 𝑣∈𝑉, a DFS tree rooted at 𝑣 can be reported in O(𝑛 log 2 𝑛) time. Thefault tolerant DFS tree problem and fully dynamic DFS tree problem can be solved by “just epsilon” modification to the above algorithm for rerooting . The entire paper is available at Arxiv: Surender Baswana, Shiv Kumar Gupta, Ayush Tulsyan: Fault Tolerant and Fully Dynamic DFS in Undirected Graphs: Simple Yet Efficient. CoRR abs/1810.01726 (2018)