Incremental 2-Edge-Connectivity In Directed Graphs

Loukas Georgiadis Giuseppe F. Italiano Nikos Parotsidis

University of Ioannina University of Rome University of Rome Greece Tor Vergata Tor Vergata Italy Italy

ICALP 2016, Rome Outline

 Definitions • 2-edge-connectivity in undirected graphs • 2-edge-connectivity in directed graphs • Problem definition • Known algorithm and our result  High-level idea  Basic ingredients • Dominators • Auxiliary components  Tools  Conclusion

ICALP 2016, Rome Outline

 Definitions • 2-edge-connectivity in undirected graphs • 2-edge-connectivity in directed graphs • Problem definition • Known algorithm and our result  High-level idea  Basic ingredients • Dominators • Auxiliary components  Tools  Conclusion

ICALP 2016, Rome Undirected: Connected components

Let 퐺 = (푉, 퐸) be a undirected graph. • 퐺 is connected if there is a path between any two vertices. • The connected components of 퐺 are its maximal connected subgraphs.

ICALP 2016, Rome Undirected: Connected components

Let 퐺 = (푉, 퐸) be a connected undirected graph. • An edge is a bridge, if its removal increases the number of connected components.

ICALP 2016, Rome Undirected: Connected components

Let 퐺 = (푉, 퐸) be a connected undirected graph. • An edge is a bridge, if its removal increases the number of connected components.

ICALP 2016, Rome Undirected: Connected components

By Menger’s theorem, two vertices are 2-edge- connected iff the removal of any bridge leaves them in the same connected .

ICALP 2016, Rome Undirected: Connected components

By Menger’s theorem, two vertices are 2-edge- connected iff the removal of any bridge leaves them in the same connected component.

ICALP 2016, Rome Undirected: Connected components

By Menger’s theorem, two vertices are 2-edge- connected iff the removal of any bridge leaves them in the same connected component.

Two vertices are 2-edge-connected if there are two edge-disjoint paths between them.

ICALP 2016, Rome Undirected: Connected components

By Menger’s theorem, two vertices are 2-edge- connected iff the removal of any bridge leaves them in the same connected component.

Two vertices are 2-edge-connected if there are two edge-disjoint paths between them.

ICALP 2016, Rome Undirected: Connected components

By Menger’s theorem, two vertices are 2-edge- connected iff the removal of any bridge leaves them in the same connected component.

Two vertices are 2-edge-connected if there are two edge-disjoint paths between them.

The 2-edge-connected blocks of G are its maximal subsets 퐵 ⊆ 푉 s.t. 푢 and 푣 are 2-edge-connected ∀푢, 푣 ∈ 퐵

ICALP 2016, Rome Undirected: Connected components

By Menger’s theorem, two vertices are 2-edge- connected iff the removal of any bridge leaves them in the same connected component.

Two vertices are 2-edge-connected if there are two edge-disjoint paths between them

The 2-edge-connected blocks of G are its maximal subsets 퐵 ⊆ 푉 s.t. 푢 and 푣 are 2-edge-connected ∀푢, 푣 ∈ 퐵

 푂(푚 + 푛) time algorithm [Tarjan 1972]

ICALP 2016, Rome Outline

 Definitions • 2-edge-connectivity in undirected graphs • 2-edge-connectivity in directed graphs • Problem definition • Known algorithm and our result  High-level idea  Basic ingredients • Dominators • Auxiliary components  Tools  Conclusion

ICALP 2016, Rome Directed: Strongly connected components

A B Let 퐺 = (푉, 퐸) be a directed graph. • 퐺 is strongly connected if there is a directed path C D from each vertex to every other vertex. • The strongly connected components of 퐺 are its maximal strongly connected subgraphs. E F

G H

I J

ICALP 2016, Rome Directed: Strongly connected components

A B Let 퐺 = (푉, 퐸) be a directed graph. • 퐺 is strongly connected if there is a directed path C D from each vertex to every other vertex. • The strongly connected components of 퐺 are its maximal strongly connected subgraphs. E F

G H

I J

ICALP 2016, Rome Directed: 2-edge-connectivity

A B Let 퐺 = 푉, 퐸 be a strongly connected directed graph. C D • An edge 푒 ∈ 퐸 is a strong bridge if its removal increases the strongly connected components of 퐺.

E F

G H

I J

ICALP 2016, Rome Directed: 2-edge-connectivity

A B Let 퐺 = 푉, 퐸 be a strongly connected directed graph. C D • An edge 푒 ∈ 퐸 is a strong bridge if its removal increases the strongly connected components of 퐺.

E F

G H

I J

ICALP 2016, Rome Directed: 2-edge-connectivity

A B Let 퐺 = 푉, 퐸 be a strongly connected directed graph. C D • An edge 푒 ∈ 퐸 is a strong bridge if its removal increases the strongly connected components of 퐺.

E F

G H

I J

ICALP 2016, Rome Directed: 2-edge-connectivity

A B By Menger’s Theorem, vertices 푢 and 푣 are 2-edge connected if and only if the removal of any strong bridge C D leaves them in same strongly connected component.

Vertices 푢 and 푣 are 2-edge connected if there are E F two edge-disjoint paths from 푢 to 푣 and two edge- disjoint paths from 푣 to 푢. G H

I J

ICALP 2016, Rome Directed: 2-edge-connectivity

A B By Menger’s Theorem, vertices 푢 and 푣 are 2-edge connected if and only if the removal of any strong bridge C D leaves them in same strongly connected component.

Vertices 푢 and 푣 are 2-edge connected if there are E F two edge-disjoint paths from 푢 to 푣 and two edge- disjoint paths from 푣 to 푢. G H

I J

ICALP 2016, Rome Directed: 2-edge-connectivity

A B By Menger’s Theorem, vertices 푢 and 푣 are 2-edge connected if and only if the removal of any strong bridge C D leaves them in same strongly connected component.

Vertices 푢 and 푣 are 2-edge connected if there are E F two edge-disjoint paths from 푢 to 푣 and two edge- disjoint paths from 푣 to 푢. G H

I J

ICALP 2016, Rome Directed: 2-edge-connectivity

A B By Menger’s Theorem, vertices 푢 and 푣 are 2-edge connected if and only if the removal of any strong bridge C D leaves them in same strongly connected component.

Vertices 푢 and 푣 are 2-edge connected if there are E F two edge-disjoint paths from 푢 to 푣 and two edge- disjoint paths from 푣 to 푢. G H

I J

ICALP 2016, Rome Directed: 2-edge-connectivity

A B By Menger’s Theorem, vertices 푢 and 푣 are 2-edge connected if and only if the removal of any strong bridge C D leaves them in same strongly connected component.

Vertices 푢 and 푣 are 2-edge connected if there are E F two edge-disjoint paths from 푢 to 푣 and two edge- disjoint paths from 푣 to 푢. G H

I J

ICALP 2016, Rome Directed: 2-edge-connectivity

A B By Menger’s Theorem, vertices 푢 and 푣 are 2-edge connected if and only if the removal of any strong bridge C D leaves them in same strongly connected component.

Vertices 푢 and 푣 are 2-edge connected if there are E F two edge-disjoint paths from 푢 to 푣 and two edge- disjoint paths from 푣 to 푢. G H A 2-edge-connected block of 퐺 is a maximal subset 퐵 ⊆ 푉 s. t. 푢 and 푣 are 2-edge connected for all I J 푢, 푣 ∈ 퐵.

ICALP 2016, Rome Directed: 2-edge-connectivity

A B By Menger’s Theorem, vertices 푢 and 푣 are 2-edge connected if and only if the removal of any strong bridge C D leaves them in same strongly connected component.

Vertices 푢 and 푣 are 2-edge connected if there are E F two edge-disjoint paths from 푢 to 푣 and two edge- disjoint paths from 푣 to 푢. G H A 2-edge-connected block of 퐺 is a maximal subset 퐵 ⊆ 푉 s. t. 푢 and 푣 are 2-edge connected for all I J 푢, 푣 ∈ 퐵.

 푂(푚 + 푛) time algorithm [Georgiadis, Italiano, Laura, P. 2015] ICALP 2016, Rome Outline

 Definitions • 2-edge-connectivity in undirected graphs • 2-edge-connectivity in directed graphs • Problem definition • Known algorithm and our result  High-level idea  Basic ingredients • Dominators • Auxiliary components  Tools  Conclusion

ICALP 2016, Rome Problem definition

Graph + data structure

ICALP 2016, Rome Problem definition

Are 푢 and 푣 2- edge-connected

Graph + data structure

ICALP 2016, Rome Problem definition

Are 푢 and 푣 2- edge-connected

Yes/No

Graph + data structure

ICALP 2016, Rome Problem definition

What are the 2- edge-connected blocks in 퐺

Graph + data structure

ICALP 2016, Rome Problem definition

What are the 2- edge-connected blocks in 퐺

{푎, 푏, 푑}, {푐, 푒}, {푓}

Graph + data structure

ICALP 2016, Rome Problem definition

Graph + data structure

ICALP 2016, Rome Problem definition

Insert (x,y)

Graph + data structure

ICALP 2016, Rome Problem definition

Insert (x,y)

Graph + data structure

ICALP 2016, Rome Problem definition

Are 푢 and 푣 2- edge-connected

Graph + data structure

ICALP 2016, Rome Problem definition

Are 푢 and 푣 2- edge-connected

Yes/No

Graph + data structure

ICALP 2016, Rome Problem definition

Goal: Update time faster that recomputing Fast query time

Graph + data structure

ICALP 2016, Rome Dynamic graph algorithms

Problem Undirected graphs Directed graphs Connectivity/ Yes Yes Transitive closure Connected components/ Yes Yes Strongly connected components APSP Yes Yes DFS Yes (only on DAGs) MST Yes ? 2-edge-connectivity Yes ? 2-vertex-connectivity Yes ?

ICALP 2016, Rome Incremental 2-edge-connectivity Undirected VS Directed

Block tree structure

ICALP 2016, Rome Incremental 2-edge-connectivity Undirected VS Directed

Block tree structure

ICALP 2016, Rome Incremental 2-edge-connectivity Undirected VS Directed

Block tree structure

ICALP 2016, Rome Incremental 2-edge-connectivity Undirected VS Directed

Block tree structure No tree structure is possible

ICALP 2016, Rome Incremental 2-edge-connectivity Undirected VS Directed

Block tree structure No tree structure is possible

ICALP 2016, Rome Incremental 2-edge-connectivity Undirected VS Directed

Block tree structure No tree structure is possible

ICALP 2016, Rome Outline

 Definitions • 2-edge-connectivity in undirected graphs • 2-edge-connectivity in directed graphs • Problems definition • Known algorithm and our result  High-level idea  Basic ingredients • Dominators • Auxiliary components  Tools  Conclusion

ICALP 2016, Rome Simple-minded solutions

Update time Query time

Never update 푂(1) per insertion 푂(푚 + 푛)

Always update 푂(푚 + 푛) per insertion 푂(1)

ICALP 2016, Rome Our algorithm

Update time Query time

Never update 푂(1) per insertion 푂(푚 + 푛)

Always update 푂(푚 + 푛) per insertion 푂(1)

Our algorithm 푂(푚푛) total time 푂(1)

ICALP 2016, Rome Outline

 Definitions • 2-edge-connectivity in undirected graphs • 2-edge-connectivity in directed graphs • Problems definition • Known algorithm and our result  High-level idea  Basic ingredients • Dominators • Auxiliary components  Tools  Conclusion

ICALP 2016, Rome High-level idea

Dominator tree

푂 푛 time 2-edge- Labeling algorithm connected blocks

Auxiliary components

ICALP 2016, Rome Dominators

Flow graph 퐺 푠 = (푉, 퐴, 푠) : all vertices are reachable from start vertex 푠

푣 dominates 푤 if all paths from 푠 to 푤 contain 푣 푠

푑표푚 푤 = set of vertices that dominate 푤 푣

ICALP 2016, Rome Dominators

푣 dominates 푤 if all paths from 푠 to 푤 contain 푣

퐺(푠) 퐷(푠) = tree of 퐺(푠) 푠 푠

푎 푒 푎 푏 푐 푑 푏 푓 = 푑(푔)

푐 푒 푔

푑 푓

ICALP 2016, Rome Dominators

푣 dominates 푤 if all paths from 푠 to 푤 contain 푣

퐺(푠) 퐷(푠) = dominator tree of 퐺(푠) 푠 푠

푎 푒 푎 푏 푐 푑 푏 푓 = 푑(푔)

푐 푒 푔

푑 푓

ICALP 2016, Rome Dominators

푣 dominates 푤 if all paths from 푠 to 푤 contain 푣

퐺(푠) 퐷(푠) = dominator tree of 퐺(푠) 푠 푠

푎 푒 푎 푏 푐 푑 푏 푓 = 푑(푔)

푐 푒 푔

푑 푓

ICALP 2016, Rome Dominators

푣 dominates 푤 if all paths from 푠 to 푤 contain 푣

퐺(푠) 퐷(푠) = dominator tree of 퐺(푠) 푠 푠

푎 푒 푎 푏 푐 푑 푏 푓 = 푑(푔)

푐 푒 푔

푑 푓

ICALP 2016, Rome Dominators

푣 dominates 푤 if all paths from 푠 to 푤 contain 푣

퐺(푠) 퐷(푠) = dominator tree of 퐺(푠) 푠 푠

푎 푒 푎 푏 푐 푑 푏 푓 = 푑(푔)

푐 푒 푔

푑 푓

ICALP 2016, Rome Dominators

푣 dominates 푤 if all paths from 푠 to 푤 contain 푣

퐺(푠) 퐷(푠) = dominator tree of 퐺(푠) 푠 푠

푎 푒 푎 푏 푐 푑 푏 푓 = 푑(푔)

푐 푒 푔

푑 푓 O(푚푎(푚, 푛))-time algorithm: [Lengauer and Tarjan ’79] O(푚 + 푛)-time algorithms: 푔 [Alstrup, Harel, Lauridsen, and Thorup ‘97] Exploiting dominator tree

퐷 푠 푠

푏 푙 푎 푐 푎 푏 푘 푓 ℎ 푔 푚 푑 푒 푑 푖 푗

푓 푐 푒 푔 ℎ

푘 푙 푖 푗

ICALP 2016, Rome Exploiting dominator tree

퐷 푠 푠

푏 푙 푎 푐 푎 푏 푘 푓 ℎ 푔 푚 푑 푒 푑 푖 푗

푓 푐 푒 푔 ℎ • All paths from 푠 to 푐 contain 푙, 푓, 푑 푘 푙 푖 푗

ICALP 2016, Rome Exploiting dominator tree

퐷 푠 푠

푏 푙 푎 푐 푎 푏 푘 푓 ℎ 푔 푚 푑 푒 푑 푖 푗

푓 푐 푒 푔 ℎ • All paths from 푠 to 푐 contain 푙, 푓, 푑 푘 푙 • All paths from 푠 to 푐 contain the 푖 푗 strong bridges 푠, 푙 , 푓, 푑

ICALP 2016, Rome Exploiting dominator tree

퐷 푠 푠

푏 푙 푎 푐 푎 푏 푘 푓 ℎ 푔 푚 푑 푒 푑 푖 푗

푓 푐 푒 푔 ℎ • All paths from 푠 to 푐 contain 푙, 푓, 푑 푘 푙 • All paths from 푠 to 푐 contain the 푖 푗 strong bridges 푠, 푙 , 푓, 푑 • A strong bridge is the only incoming edge to the vertices of its subtree 푚

ICALP 2016, Rome Exploiting dominator tree

퐷 푠 푙 푎 푏

푘 푓 ℎ 푔 푚 푑 푖 푗

푐 푒

The dominator tree of the graph provides only partial information.

ICALP 2016, Rome Exploiting dominator tree

푅 퐷 퐷 푠 푠 푙 푎 푏 푎 푏 푐 푑 푒 푓 푘 푓 ℎ 푔 푚 푔 푑 푖 푗 푘 푙 푚

푐 푒 ℎ 푖 푗

The dominator tree of the graph provides only partial information. The dominator tree of the reverse graph provides other partial information.

ICALP 2016, Rome Exploiting dominator tree

푅 퐷 퐷 푠 푠 푙 푎 푏 푎 푏 푐 푑 푒 푓 푘 푓 ℎ 푔 푚 푔 푑 푖 푗 푘 푙 푚

푐 푒 ℎ 푖 푗

Lemma [Georgiadis, Italiano, P.]: Two vertices 푢 and 푣 are 2-edge-connected iff • Their nearest bridge 푒 in 퐷 is common and they are not separated in 퐺 ∖ 푒 • Their nearest bridge 푒 in 퐷푅 is common and they are not separated in 퐺 ∖ 푒

ICALP 2016, Rome Exploiting dominator tree

푅 퐷 퐷 푠 푠 푙 푎 푏 푎 푏 푐 푑 푒 푓 푘 푓 ℎ 푔 푚 푔 푑 푖 푗 푘 푙 푚

푐 푒 ℎ 푖 푗

푐 and 푔 are not 2-edge-connected since they have distinct nearest bridges

Lemma [Georgiadis, Italiano, P.]: Two vertices 푢 and 푣 are 2-edge-connected iff • Their nearest bridge 푒 in 퐷 is common and they are not separated in 퐺 ∖ 푒 • Their nearest bridge 푒 in 퐷푅 is common and they are not separated in 퐺 ∖ 푒

ICALP 2016, Rome Exploiting dominator tree

푅 퐷 퐷 푠 푠 푙 푎 푏 푎 푏 푐 푑 푒 푓 푘 푓 ℎ 푔 푚 푔 푑 푖 푗 푘 푙 푚

푐 푒 ℎ 푖 푗

푐 and 푒 are 2-edge-connected iff they are strongly connected in 퐺 ∖ (푓, 푑)

Lemma [Georgiadis, Italiano, P.]: Two vertices 푢 and 푣 are 2-edge-connected iff • Their nearest bridge 푒 in 퐷 is common and they are not separated in 퐺 ∖ 푒 • Their nearest bridge 푒 in 퐷푅 is common and they are not separated in 퐺 ∖ 푒

ICALP 2016, Rome Exploiting dominator tree

푅 퐷 퐷 푠 푠 푙 푎 푏 푎 푏 푐 푑 푒 푓 푘 푓 ℎ 푔 푚 푔 푑 푖 푗 푘 푙 푚

푐 푒 ℎ 푖 푗

푓 and 푚 are 2-edge-connected iff they are strongly connected in 퐺 ∖ (푠, 푙) and in 퐺 ∖ (푓, 푑)

Lemma [Georgiadis, Italiano, P.]: Two vertices 푢 and 푣 are 2-edge-connected iff • Their nearest bridge 푒 in 퐷 is common and they are not separated in 퐺 ∖ 푒 • Their nearest bridge 푒 in 퐷푅 is common and they are not separated in 퐺 ∖ 푒

ICALP 2016, Rome Outline

 Definitions • 2-edge-connectivity in undirected graphs • 2-edge-connectivity in directed graphs • Problems definition • Known algorithm and our result  High-level idea  Basic ingredients • Dominators • Auxiliary components  Tools  Conclusion

ICALP 2016, Rome Auxiliary components

퐷 Bridge decomposition: The forest 푠 obtained by removing the strong bridges 푙 from the dominator tree 푎 푏 Lemma: two vertices are 2-edge- 푓 푔 푚 푘 ℎ connected only if they are in the same 푑 푖 푗 tree of the bridge decomposition

푐 푒

ICALP 2016, Rome Auxiliary components

퐷 Bridge decomposition: The forest 푠 obtained by removing the strong bridges 푙 from the dominator tree 푎 푏 Lemma: two vertices are 2-edge- 푓 푔 푚 푘 ℎ connected only if they are in the same 푑 푖 푗 tree of the bridge decomposition

푐 푒

ICALP 2016, Rome Auxiliary components

Idea: Encode all the paths that do not use the incoming strong bridge between vertices in the same tree of the 푑(푟) bridge decomposition with an auxiliary graph.

푟 Construction: • Keep the paths using only vertices of the tree • For every path using vertices outside the tree, replace the subpath outside with a shortcut edge 푥 푦

ICALP 2016, Rome Auxiliary components

Idea: Encode all the paths that do not use the incoming strong bridge between vertices in the same tree of the 푑(푟) bridge decomposition with an auxiliary graph.

푟 Construction: • Keep the paths using only vertices of the tree • For every path using vertices outside the tree, replace the subpath outside with a shortcut edge 푥 푦

ICALP 2016, Rome Auxiliary components

Idea: Encode all the paths that do not use the incoming strong bridge between vertices in the same tree of the 푑(푟) bridge decomposition with an auxiliary graph.

푟 Construction: • Keep the paths using only vertices of the tree • For every path using vertices outside the tree, replace the subpath outside with a shortcut edge 푥 푦

ICALP 2016, Rome Auxiliary components

Idea: Encode all the paths that do not use the incoming strong bridge between vertices in the same tree of the 푑(푟) bridge decomposition with an auxiliary graph.

푟 Construction: • Keep the paths using only vertices of the tree • For every path using vertices outside the tree, replace the subpath outside with a shortcut edge 푥 푦 Lemma: Two vertices in the same tree (rooted at 푟) are disconnected by 푑 푟 , 푟 iff they are not strongly connected in the auxiliary graph of their tree (in the same auxiliary component).

ICALP 2016, Rome Auxiliary components

Idea: Encode all the paths that do not use the incoming strong bridge between vertices in the same tree of the 푑(푟) bridge decomposition with an auxiliary graph.

푟 Construction: • Keep the paths using only vertices of the tree • For every path using vertices outside the tree, replace the subpath outside with a shortcut edge 푥 푦 Lemma: Two vertices in the same tree (rooted at 푟) are disconnected by 푑 푟 , 푟 iff they are not strongly connected in the auxiliary graph of their tree (in the same auxiliary component).

Algorithm: Two vertices 푢 and 푣 are 2-edge-connected iff they are in the same auxiliary component in 퐺 and 퐺푅.

ICALP 2016, Rome Auxiliary components

Idea: Encode all the paths that do not use the incoming strong bridge between vertices in the same tree of the 푑(푟) bridge decomposition with an auxiliary graph.

푟 Construction: • Keep the paths using only vertices of the tree • For every path using vertices outside the tree, replace the subpath outside with a shortcut edge 푥 푦 Lemma: Two vertices in the same tree (rooted at 푟) are disconnected by 푑 푟 , 푟 iff they are not strongly connected in the auxiliary graph of their tree (in the same auxiliary component).

GOAL: Incrementally maintain the bridge decomposition and the auxiliary components.

ICALP 2016, Rome Outline

 Definitions • 2-edge-connectivity in undirected graphs • 2-edge-connectivity in directed graphs • Problems definition • Known algorithm and our result  High-level idea  Basic ingredients • Dominators • Auxiliary components  Tools  Conclusion

ICALP 2016, Rome Tools

 Incremental dominator tree

• 2012 – Georgiadis, Italiano, Laura, Santaroni • 푂 푚 min{푛, 푘} + 푘푛

 Incremental SCCs in each auxiliary graph

• 2009 & 2016 – Bender, Fineman, Gilbert, Tarjan: • 푂 푚 min{ 푚, 푛2/3}

ICALP 2016, Rome Combining things…

• Many instances of the Incremental SCCs algorithm • Vertices can move across auxiliary graphs • Auxiliary graphs can merge • …

ICALP 2016, Rome Concluding remarks

Results: • Incremental 푂(푚푛) algorithm for maintaining the pairwise 2-edge- connectivity in directed graphs. • Answer queries in 푶(ퟏ) time, whether two vertices are 2-edge- connected. If the two vertices are not 2-edge-connected, we return an edge that separates them.

Open problems: • Can we maintain incrementally the 2-vertex-connected blocks? • Decremental? Fully dynamic?

ICALP 2016, Rome Concluding remarks

Results: • Incremental 푂(푚푛) algorithm for maintaining the pairwise 2-edge- connectivity in directed graphs. • Answer queries in 푶(ퟏ) time, whether two vertices are 2-edge- connected. If the two vertices are not 2-edge-connected, we return an edge that separates them.

Open problems: • Can we maintain incrementally the 2-vertex-connected blocks? • Decremental? Fully dynamic?

ICALP 2016, Rome Thank you!