dynamic dfs in undirected graph using segment tree

19
An Alternate Approach for Query Operation on the Data Structure Used for Building Dynamic DFS in Undirected Graphs Presenters: Date, Prutha Memon, Siraj Konagala, Harika CMSC 641 – Research Project (Team 10) Original Paper: Dynamic DFS in Undirected Graphs: breaking the O(m) barrier (SODA’16 Page: 730-739) Authors: Baswana, Surender ; Chaudhury, Shreejit ; Choudhary, Keerti ;

Upload: siraj-memon

Post on 21-Apr-2017

253 views

Category:

Engineering


2 download

TRANSCRIPT

Page 1: Dynamic DFS in Undirected Graph using Segment Tree

An Alternate Approach for Query Operation on the Data Structure Used for Building Dynamic DFS in Undirected

Graphs

Presenters:Date, PruthaMemon, Siraj

Konagala, Harika

CMSC 641 – Research Project (Team 10)

Original Paper: Dynamic DFS in Undirected Graphs: breaking the O(m) barrier (SODA’16 Page: 730-739)

Authors: Baswana, Surender ; Chaudhury, Shreejit ; Choudhary, Keerti ; Khan, Shahbaz

Page 2: Dynamic DFS in Undirected Graph using Segment Tree

CONTENTS Motivation Terminology

Dynamic DFS Segment Tree Components Property

Background Re-rooting Data Structure

Contribution Building Data Structure Alternative Algorithm for Query Operation

Results and Discussion Challenges and Future Scope Conclusion

Page 3: Dynamic DFS in Undirected Graph using Segment Tree

MOTIVATION Baswana et al.[1] present a fully dynamic Depth First Search for handling graphs with

multiple updates. Re-rooting process sets the foundation. Data Structure is crucial for maintaining dynamic DFS tree. For Re-rooting the DFS Tree, we need Query operation gives the nearest edge incident

on vertex currently visited in DFS.

CONTRIBUTION Alternate method for querying the Data Structure

Original algorithm – O(log3n) New algorithm – O(log m * log n)

Implementation of Data Structure with time complexity of O(m log n) Analysis and verification of theoretical vs observed time.

m : Number of Edgesn : Number of Vertices

Page 4: Dynamic DFS in Undirected Graph using Segment Tree

DEPTH-FIRST-SEARCH TRAVERSAL

DB

A

C

E

Graph G

DB

A

C

E

DFS tree T

Page 5: Dynamic DFS in Undirected Graph using Segment Tree

SEGMENT TREE5

2 5

1 2 5 6

0 1 2 3 4 5

18 17 13 19 15 11 20

[0,6][4,6]

[4,5][6,6]

[0,0] [1,1] [2,2] [3,3] [4,4] [5,5]

[0,3]

[0,1] [2,3]

0 1 2 3 4 5 6Array

Page 6: Dynamic DFS in Undirected Graph using Segment Tree

COMPONENTS PROPERTY

r

w

v

T*

e1’

e1

e2’

e2

C1

C2

C1 & C2 - Connected Components

Page 7: Dynamic DFS in Undirected Graph using Segment Tree

RE-ROOTING THE GRAPH Re-rooting Procedure

rma

b

fcd

eg

kl

h

i j

rma

b

f

cd

e gk

lh

i j

Failure of edge (b, f). Partial DFS tree T with unvisited graph T(f), components property allows us to neglect (a, l).

Page 8: Dynamic DFS in Undirected Graph using Segment Tree

RE-ROOTING THE GRAPH (cont.) Re-rooting Procedure (Continued)

rma

b

kc

de g

flh

i j

rma

b

kc

de g

flh

i j

Augmented path(k, f) to T, components property allows us to neglect (l, k).

Final DFS tree of G\{(b, f)}.

Page 9: Dynamic DFS in Undirected Graph using Segment Tree

Perform a Pre-order Traversal of T and store vertices into List L Build a Segment Tree TB whose leaf nodes from left to right represent the

vertices in list L

BUILDING THE DATA STRUCTURE

DFS Tree

xu

vz

yw

s t

x z w s t y u v List L

x z w s t y u v

(x,s)

(z,w)

(w,s)

(s,w)

(t,w)

(z,t)

(w,t)

Segment Tree TB

Page 10: Dynamic DFS in Undirected Graph using Segment Tree

BUILDING THE DATA STRUCTURE (cont.) Augment BST in every node of TB Edges in BST should be sorted using second endpoint in L

x z w s t y u v

Segment Tree TB

[w-s]

(s,w)

(t,w)(w,s)

(z,w)

(x,s)

BST stored at segment tree node [w-s]

(x,s) (z,w) (w,s) (s,w) (t,w)

Edge-list sorted according to List Lx z w s t y u v List L

Page 11: Dynamic DFS in Undirected Graph using Segment Tree

QUERY OPERATIONFor any three vertices w, x, y € T, where Path(x, y) is an ancestor-descendant path in T Query(T(w), x, y) : among all the edges from T(w) that are incident on path(x, y) in G+U, returns an edge that is incident nearest to x on path(x, y).

Original Algorithm:

1. T (w) can be expressed as a union of O(log n) disjoint subtrees in Segment Tree

2. Path (x, y) divided into O(log n) subpaths where every subpath is an interval in List L

3. Find the edge by executing query on BST in O(log n) time.Overall Complexity: O(log3n)

Page 12: Dynamic DFS in Undirected Graph using Segment Tree

ALGORITHM FOR QUERY OPERATION

Among all the edges from w that are incident on Path (x,y) in G, return an edge incident nearest to x on Path(x,y)

1. Find path between x and y. Let us call it Path Vector and insert in sorted order by list L.

2. Find nodes belong to T(w). Let us call it Tree Vector.

3. Scan Binary Search Tree of Root of Segment Tree which will have all the edges in Sorted order by a list L.

a. Check for edge starting from a node present in Path Vector.

b. Check for edge ending with a node present in Tree Vector.

c. Choose the edge which is closer to x i.e. minimum value of index of list L.

x

u

v

z

yw

st

Path Vector

Tree Vector

x z w s t y u v List L

Query (T (w), x, y)

Time Complexity : O(log m * log n)

Page 13: Dynamic DFS in Undirected Graph using Segment Tree

ANALYSIS1. Assumption: Random Graphs with no parallel edges or self loops2. Vertex Range: 5 to 10003. Edge Range: 4 to 25004. Coefficient calculated using Growth Rate5. Coefficients for Building Data Structure:

Expected: 7.51 Observed: 6.496. Coefficients for Query Operation:

Expected: 4.24 Observed: 4.41

Page 14: Dynamic DFS in Undirected Graph using Segment Tree

ANALYSIS (cont.)

BUIDLING DATA STRUCTURE

Page 15: Dynamic DFS in Undirected Graph using Segment Tree

ANALYSIS (cont.)

QUERY OPERATION

Page 16: Dynamic DFS in Undirected Graph using Segment Tree

CHALLENGES Understanding how the Query operation works How to handle BST inside a Static Segment Tree with linear Merge operation

FUTURE WORK Implement Query to handle multiple updates

Page 17: Dynamic DFS in Undirected Graph using Segment Tree

CONCLUSION Built Data Structure for maintaining Dynamic DFS Implemented Data Structure with Static Segment Tree and BST with time

complexity of O(m log n) Implemented an algorithm for Query operation with a time complexity of O

(log m * log n) Analyzed its time complexity and the correctness experimentally

m : Number of Edgesn : Number of Vertices

https://github.com/simemon/DAA

Page 18: Dynamic DFS in Undirected Graph using Segment Tree

REFERENCES [1] Surender Baswana and Keerti Choudhary. On dynamic DFS tree in

directed graphs. In MFCS, Proceedings, Part II, pages 102–114, 2015. [2] Surender Baswana and Shahbaz Khan. Incremental algorithm for

maintaining DFS tree for undirected graphs. In ICALP, Proceedings, Part I, pages 138–149, 2014.

[3] Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. Introduction to Algorithms (3. ed.). MIT Press, 2009.

[4] Surender Baswana and Neelesh Khanna. Approximate shortest paths avoiding a failed vertex: Near optimal data structures for undirected unweighted graphs. Algorithmica, 66(1):18–50, 2013.

https://kartikkukreja.wordpress.com/2014/11/09/a-simple-approach-to-segment-trees/

Page 19: Dynamic DFS in Undirected Graph using Segment Tree

THANK YOU