# Improved Shortest Path Algorithms for Nearly Acyclic Directed Graphs L. Tian and T. Takaoka University of Canterbury New Zealand 2007.

## Presentation on theme: "Improved Shortest Path Algorithms for Nearly Acyclic Directed Graphs L. Tian and T. Takaoka University of Canterbury New Zealand 2007."— Presentation transcript:

Improved Shortest Path Algorithms for Nearly Acyclic Directed Graphs L. Tian and T. Takaoka University of Canterbury New Zealand 2007

Introduction  What is nearly acyclic directed graphs? (1) Takaoka (1998) explained this using a strongly connected component (sc- component) approach, cyc(G). SC 1 SC 2 e1e1 e2e2 SC 1 e1e1 e2e2 In this example, cyc(G) = 3

Solve the SSSP problem using sc- component decomposition 1.Compute sc-components V r,V r-1, …,V 1 ; 2.for v ∈ V do d[v] ← ∞; 3.d[s] ← 0; 4.for i ← r to 1 do{ 5.Solve the GSS for G i ; 6.for V j such that (V i, V j ) ∈ E do 7. for v ∈ V i and w ∈ V j such that (v, w) ∈ E do 8. d[w] ← min{d[w], d[v] + cost(v,w)}; 9.} The time complexity of this algorithm is O(m + nlogk), where m is the number of edges in a graph and n is the number of vertices. K is the maximum size of sc components

Introduction (continue) (2) Saunders and Takaoka (2005) used a 1-dominator approach to explain that. The SSSP algorithm based on the approach is O(m+rlogr) where r is the number of triggers. AC 1 AC 2 e1e1 e2e2 e3e3 e3e3 AC 1 AC 2 e1e1 e2e2

Restricted Depth First Search for 1-dominator decomposition 1.function AcyclicSetA(u){ 2. VertexSet A, L; 3. procedure rdfs(v){ 4. A ← A + {v}; 5. for each w ∈ OUT(A) do{ 6. if w  L then L ← L + {w}; // w is visited 7. inCount[w] ← inCount[w] – 1; 8. if inCount[w] = 0 then rdfs(w); // w is unlocked 9. } 10. } 11. A ← ; L ← {u}; 12. inCount[u] ← inCount[u] + 1; // prevents re-traversal of u 13. rdfs(u); 14. VertexSet B ← L – A; // boundary vertices 15. for each w ∈ L do inCount[w] ← |IN(w)|; 16. return (A,D); 17.}

Computing the 1-Dominator Set 1.for all v ∈ V do inCount[v] ← |IN(v)|; 2.for all v ∈ V do vertexType[v] ← unknown; 3.a queue Q ← {s}; 4.while Q ≠  do{ 5. Remove the next vertex u from Q; 6. if vertexType[u] = unknown then { 7. (A, B) ← AcyclicSetA(u); 8. for each v ∈ A do Let AC[v] refer to A; 9. for each v ∈ A do vertexType[v] ← nontrigger; 10. vertexType[u] ← trigger; 11. for each v ∈ B do 12. if vertexType[v] = unknown and v  Q then Add v to Q; 13. } 14.}

SSSP Algorithm using Acyclic Decomposition 1.procedure decreaseKey(u){ 2. for each v ∈ AC[u] in topological order do 3. for each w ∈ OUT[v] and w  S do 4. d[w] ← min{d[w], d[v] + cost(v,w)}; 5.} 6.for all v ∈ V do d[v] ← ∞ ; 7.solution set S ← ; 8.insert all triggers into frontier set F; 9.d[s] ← 0; // s is the source vertex 10.if s is not a trigger then decreaseKey(s); 11.while F is not empty do{ 12. find u from F with minimum key and delete u from F; 13. S ← {u}; 14. decreaseKey(u); 15.}

Higher-Order Approach  This approach extends the technique of sc-component decomposition, denoted by cyc h (G). cyc 1 (G) cyc 2 (G) In the second order decomposition, it eats the black node and then decomposes the subgraph.

Higher-Order SSSP Algorithm 1.procedure Dynamic(G, SV){ 2. Compute h th order sc-components V h r, V h r-1, …,V h 1 ; 3. for i ← r to 1 do{ 4. for V h j such that (V h i, V h j ) ∈ E h do 5. for v ∈ V h i and w ∈ V h j such that (v, w) ∈ E do 6. d[w] ← min{d[w], d[v] + cost(v,w)}; 7. v min ← w that gives min{d[w] | w ∈ V h i-1 }; 8. SV ← {v min }; 9. if (|G h i-1 |>c 1 ) and (h+1< c 2 ) 10. then { h ← h+1; Dynamic(G h i-1 ; SV); } 11. else solve the GSS for G h i-1 ; 12. } 13.} 14.for all v ∈ V do d[v] ← ∞; 15.d[s] ← 0; // s is the source vertex 16.Dynamic(G, {s});

Hierarchical Approach  This approach is based on modifications of the sc-component and 1-dominator approaches. AC 3 AC 1 AC 2 AC 4 AC 5 SC 1 SC 2

Hierarchical Decomposition Algorithm 1. function HierarchySets(v 0 ) { 2. procedure hdfs(v) { 3.(A, B) ← AcyclicSet(v); 4. Let AC[v] refer to A; 5. vertexType[v] ← trigger ; 6. for all u ∈ A do vertexType[u] ← non-trigger; 7.for all u ∈ B do 8. if visitNum[u] = 0 do{ 9. c ← c + 1 ; visitNum[u] ← c ; lowlink[u] ← c; 10. T ← T + {u} ; 11. hdfs(u) ; // search from unvisited v ∈ B 12. if u ∈ T then lowlink[v] ← min(lowlink[u],lowlink[v] ); 13. else lowlink[v] ← min(lowlink[v], vsistNum[u] ); //update lowlink[v] from connected triggers 14. } 15. if lowlink[v] = visitNum[v] and v ∈ T do { 16. VertexSet C ← pop up vertices from T until v; 17. p ← p + 1; // count sc-components 18. Let SC[p] refer to C; 19. } 20. } 21. VertexSet AC ← , SC ← , T ← ; 22. for all v ∈ V do { 23. inCount[v] ← |IN(v)|; vertexType[v] ← unknown; 24. visitNum[v] ← 0; lowlink[v] ← ; 25. } 26. p ← 0; c ← 0; 27. for all unvisited v 0 ∈ V do { 28. c ← c + 1; visitNum[v 0 ] ← c; lowlink[v 0 ] ← c; 29. T ← T + v 0 ; 30. hdfs(v 0 ); 31. } 32. return(AC, SC, p); 33. }

1-2-dominator sets  Difficulty on 2-dominator sets:  A 1-2-dominator set is a generalization of the 1-dominator set. u1u1 u2u2 u3u3 v1v1 v2v2 V j+1 v3v3 vjvj V j+2 V 2j-1 u1u1 u2u2 u3u3 v1v1 v2v2 V j+1 v3v3 vjvj V j+2 V 2j-1

Restricted Depth First Search for 1-2-dominator decomposition 1.function AcyclicSetA(u){ 2. VertexSet A, L; 3. procedure rdfs(v){ 4. A ← A + {v}; 5. for each w ∈ OUT(A) do{ 6. if w  L then L ← L + {w}; // w is visited 7. inCount[w] ← inCount[w] – 1; 8. if inCount[w] = 0 then rdfs(w); // w is unlocked 9. } 10. } 11. A ← ; L ← {u}; 12. inCount[u] ← inCount[u] + 1; // prevents re-traversal of u 13. rdfs(u); 14. VertexSet B ← L – A; // boundary vertices 15. for each w ∈ B do { 15.1 inc(v,w) ← |IN(w)| – inCount[w]; 15.2 BS[v] ← (w, inc(v,w)); 15.3 inCount[w] ← |IN(w)|; 15.4 } 16. return (A,B); 17. }

1-2-Dominator Set Algorithm 1. procedure gdfs(u 1, u 2, v) { 2. for all w ∈ BS[v] do { 3. inCount[w] ← inCount[w] - inc(v, w) ; 4. if inCount[w] = 0 do { // w is unlocked 5. T 1 ← T 1 - {w} ; // 1-dominator set T 1 6. AC[u 1 ] ← AC[u 1 ] + {w}; 7. AC[u 2 ] ← AC[u 2 ] + {w}; 8. gdfs(u 1, u 2, w); 9. } 10. } 11. } /***** main program *****/ 12. Compute 1-dominator set T 1 ; 13. for u 1 ∈ T 1 do{ 14. inCount[u 1 ] ← inCount[u 1 ] + 1; 15. for all v ∈ BS[u 1 ] do inCount[v] ← inCount[v] - inc(u 1, v); 16 for u 2 ∈ T 1 - {T 1 } do { 17. inCount[u 1 ] ← inCount[u 2 ] + 1; 18. gdfs(u 1, u 2, u 2 ); 19. } 20. T 1 ← T 1 - {u 1 } ; 21. for all v ∈ BS[u 1 ] do inCount[v] ← |IN(v)|; 22. }

SSSP Algorithm using Acyclic Decomposition 1.procedure decreaseKey(u){ 2. for each v ∈ AC[u] in topological order do 3. for each w ∈ OUT[v] and w  S do 4. d[w] ← min{d[w], d[v] + cost(v,w)}; 5.} 6.for all v ∈ V do d[v] ← ∞ ; 7.solution set S ← ; 8.insert all triggers into frontier set F; 9.d[s] ← 0; // s is the source vertex 10.if s is not a trigger then decreaseKey(s); 11.while F is not empty do{ 12. find u from F with minimum key and delete u from F; 13. S ← {u}; 14. decreaseKey(u); 15.}

Future research  1-2-...-k domnator approach: Acyclic structures are dominated by up to k trigger vertices  All Pairs with 1-dominator set O(mn + r 2 log r) General feedback set approach for all pairs: If we have a feedback vertex set of size r, the best time is O(mn + r 3 ). Conjecture O(mn + r 2 log r)?

Similar presentations