A New Framework for Strong Connectivity and 2-Connectivity in Directed Graphs

A New Framework for Strong Connectivity and -Connectivity in Directed Graphs

Loukas Georgiadis    Giuseppe F. Italiano    Nikos Parotsidis
Abstract

In this paper, we investigate some basic problems related to the strong connectivity and to the -connectivity of a directed graph, by considering the effect of edge and vertex deletions on its strongly connected components. Let be a directed graph with edges and vertices. We present a collection of -space data structures that, after -time preprocessing can accomplish the following tasks:

  • Report in worst-case time all the strongly connected components obtained after deleting a single edge (resp., a single vertex) in .

  • Compute the total number of strongly connected components obtained after deleting a single edge (resp., vertex) in total worst-case time for all edges (resp., for all vertices).

  • Compute the size of the largest and of the smallest strongly connected components obtained after deleting a single edge (resp., vertex) in total worst-case time for all edges (resp., for all vertices).

All our bounds are tight. After the same -time preprocessing, we can also build an -space data structure that can answer in asymptotically optimal time the following basic -edge and -vertex connectivity queries on directed graphs:

  • Test whether an edge or a vertex separates two query vertices in worst-case time.

  • Report all edges or all vertices that separate two query vertices in optimal worst-case time. If there are separating edges (resp., separating vertices), then the time is in the worst case. If there are no separating edges (resp., separating vertices), then the time is in the worst case.

With the help of our data structures we can design efficient algorithms for several other strong connectivity problems on directed graphs. All our data structures are based on a uniform approach: in particular, we develop a common algorithmic framework, which hinges on new properties of the strongly connected components of a directed graph and on a novel combination of known graph theoretical concepts, such as dominance relations and loop nesting forests.

11footnotetext: Department of Computer Science & Engineering, University of Ioannina, Greece. E-mail: loukas@cs.uoi.gr.22footnotetext: Dipartimento di Ingegneria Civile e Ingegneria Informatica, Università di Roma “Tor Vergata”, Roma, Italy. E-mail: {giuseppe.italiano, nikos.parotsidis}@uniroma2.it. Partially supported by MIUR, the Italian Ministry of Education, University and Research, under Project AMANDA (Algorithmics for MAssive and Networked DAta).

1 Introduction

In this paper, we investigate some basic problems related to the strong connectivity and to the -connectivity of directed graphs, by considering the effect of edge and vertex deletions on their strongly connected components. Before defining precisely the problems considered, we give few definitions. Let be a directed graph (digraph), with edges and vertices. Digraph is strongly connected if there is a directed path from each vertex to every other vertex. The strongly connected components of are its maximal strongly connected subgraphs. Two vertices are strongly connected if they belong to the same strongly connected component of . The size of a strongly connected component is given by its number of vertices. An edge (resp., a vertex) of is a strong bridge (resp., a strong articulation point) if its removal increases the number of strongly connected components. Let be strongly connected. is -edge-connected if it has no strong bridges, and it is -vertex-connected if it has at least three vertices and no strong articulation points. The -edge- (resp., -vertex-) connected components of are its maximal -edge- (resp., -vertex-) connected subgraphs. Two vertices are said to be -edge-connected (resp., -vertex-connected), and we denote this relation by (resp., ), if there are two edge-disjoint (resp., two internally vertex-disjoint) directed paths from to and two edge-disjoint (resp., two internally vertex-disjoint) directed paths from to (note that a path from to and a path from to need not be edge- or vertex-disjoint). A -edge-connected block (resp., -vertex-connected block) of a digraph is defined as a maximal subset such that (resp., ) for all .

As shown in [7, 10, 11], in digraphs -vertex and -edge connectivity have a much richer and more complicated structure than in undirected graphs. For instance, in the case of undirected graphs the -edge- (resp., -vertex-) connected blocks are identical to the -edge- (resp., -vertex-) connected components. This is not the case for digraphs and the -edge- (resp., -vertex-) connected components of digraphs do not encompass the notion of pairwise -edge (resp., -vertex) connectivity among its vertices [10, 11]. Hence, it is not surprising that -connectivity problems on directed graphs appear to be more difficult than on undirected graphs. Indeed, for undirected graphs it has been known for over 40 years how to compute the analogous notions (bridges, articulation points, -edge- and -vertex-connected components) in linear time, by simply using depth first search [25]. In the case of digraphs, however, the same problems revealed to be much more challenging: although these problems have been investigated for quite a long time (see, e.g., [7, 22, 24]), fast algorithms for 2-edge and 2-vertex connectivity for digraphs have been achieved only in the last few years. Indeed, it has been shown only recently that all strong bridges and strong articulation points of a digraph can be computed in linear time [17]. Additionally, it was shown very recently how to compute the -edge- and -vertex-connected blocks of digraphs in linear time [10, 11], while the best current bound for computing the -edge- and the -vertex-connected components in digraphs is not even linear, but it is , and it was achieved also very recently by Henzinger et al. [16].

Denote by the digraph obtained after deleting edge , and by the digraph obtained after deleting vertex (together with all its incident edges). In this paper, we are interested in computing efficiently some properties of and of , for all possible edges and vertices , such as the number, or the largest or the smallest size of their strongly connected components, or in finding an edge or a vertex whose deletion minimizes / maximizes those properties. Those problems are not only theoretically interesting, but they also arise in a variety of application areas, including network analysis and computational biology. For instance, in several critical networked infrastructures, one is interested in identifying vertices and edges, whose removal results in a specific degradation of the network global pairwise connectivity [6]. In social networks, finding vertices whose deletion optimizes some connectivity properties is related to identifying key players whose removal fragments / disrupts the underlying network [3, 29]. Applications in computational biology include the computation of steady states on digraphs governed by Laplacian dynamics, which include the symbolic derivation of kinetic equations and steady state expressions for biochemical systems [14, 23]. In particular, Mihalák et al. [23] presented recently a recursive deletion-contraction algorithm for such applications, whose efficient implementation needs to find repeatedly the edge of a strongly connected digraph whose deletion minimizes quantities such as the number of resulting strongly connected components or their maximum size.

Before stating our new bounds, we review some simple-minded solutions to the problems considered in this paper. A trivial approach to find an edge whose deletion minimizes / maximizes the number, or the largest or the smallest size of the resulting strongly connected components, would be to recompute the strongly connected components of , for each edge in , which requires time in the worst case. This trivial bound can be easily improved by observing that if an edge is not a strong bridge then, by definition, remains strongly connected. Hence, we can first compute all strong bridges of in time [17] and then consider only the case where the edge to be deleted is a strong bridge, by recomputing the strongly connected components of for each strong bridge . Let the total number of strong bridges in : this yields a total time of , which is in the worst case, since there can be strong bridges in a digraph . Similar bounds apply to -vertex connectivity: we can find a vertex whose deletion minimizes / maximizes the number, or the largest or the smallest size of the resulting strongly connected components in time, where is the total number of strong articulation points in . Since , this can be in the worst case.

In this paper we present a collection of -space data structures that, after -time preprocessing can accomplish the following tasks:

  • Report in worst-case time all the strongly connected components obtained after deleting a single edge (resp., a single vertex), improving the trivial bound of . Note that those bounds are asymptotically tight, as one needs time to output the strongly connected components of a digraph.

  • Compute the total number of strongly connected components obtained after deleting a single edge (resp., a single vertex) in total worst-case time for all edges (resp., for all vertices), improving the trivial bound of . Our bounds are again asymptotically tight.

  • Compute the size of the largest and of the smallest strongly connected components obtained after deleting a single edge (resp., a single vertex) in total worst-case time for all edges (resp., for all vertices), improving the trivial bound of . Our bounds are again asymptotically tight.

With the help of our data structures we can design efficient algorithms for several other strong connectivity problems on directed graphs. For instance, after -time preprocessing, we can answer in time for each edge and for each vertex queries such as the number of strongly connected components in and in , or the maximum / minimum size of a strongly connected component in and in . We can find in linear time an edge (resp., a vertex) whose deletion minimizes / maximizes the total number of strongly connected components in the resulting digraph. We can further output all the strongly connected components in , for all edges in , in total worst-case time, and all the strongly connected components in , for all vertices in , in total worst-case time. We are also able to find an edge (resp., a vertex) whose deletion minimizes / maximizes the largest / smallest size of the resulting strongly connected components in worst-case time, improving again over the previous and bounds. All those bounds are asymptotically tight. Note that , and are all in the worst case, while and are . Thus, our data structures are able to improve one order of magnitude over previously known bounds.

As a side result, with the help of our data structures we are also able to answer in asymptotically optimal time the following basic connectivity queries:

  • Test if an edge or a vertex separates two query vertices in worst-case time, improving the trivial bound of .

  • Report all the edges (resp., vertices) that separate two query vertices in optimal worst-case time, i.e., in time , where is the number of separating edges (resp., separating vertices). (For , the time is ). This improves the trivial bound of .

The analogs of all the above problems in undirected graphs can be easily solved in linear time by simply computing the -edge- and -vertex-connected components [25]. Unsurprisingly, the same problems become much more difficult in case of directed graphs. Finally, we mention that our approach is able to provide alternative linear-time algorithms for computing the -edge-connected and -vertex-connected blocks of a digraph, which are much simpler than the algorithms presented in [10, 11], and thus are likely to be more amenable to practical implementations.

All our data structures are based on a uniform approach. Although vertex connectivity is usually more involved than edge connectivity, and it often requires several additional nontrivial techniques and details, our approach works substantially in the same way both for -edge and for -vertex connectivity. In particular, we develop a common algorithmic framework, which hinges on new properties of the strongly connected components of directed graphs and on a novel combination of known graph theoretical concepts, such as dominance relations [1, 20] and loop nesting forests [28]. While both dominators and loop nesting forests have been central tools in program optimization and code generation [5, 19], surprisingly their impact in the design of graph algorithms has been quite limited. We believe that the framework developed and the strong connectivity properties proved in this paper may be of independent interest and may provide to be useful for other problems as well, such as for instance the dynamic maintenance of -edge and -vertex connectivity properties on directed graphs.

The remainder of the paper is organized as follows. In Section 2 we introduce some preliminary definitions and terminology. Section 3 describes our framework for performing computations on the strongly connected components that could be obtained after an edge deletion, such as reporting all strongly connected components, counting the number of strongly connected components, and computing the size of the largest and of the smallest strongly connected component. In Section 4 we describe our new and simpler linear-time algorithm for computing the -edge-connected blocks of a strongly connected digraph , while in Section 5 we deal with pairwise -edge connectivity queries. Section 6, Section 7 and Section 8 extend to vertex connectivity respectively the results of Section 3, Section 4 and Section 5. Finally, Section 9 contains some concluding remarks and lists some open problems.

2 Preliminaries

We assume that the reader is familiar with standard graph terminology. All graphs in this paper are directed, i.e., an edge in digraph is directed from , the tail of , to , the head of . We also assume that at this point the reader is familiar with the definitions of -edge and -vertex connectivity on directed graphs already given in the introduction and contained in more detail in [10, 11].

Let be a rooted tree. Throughout the paper, we assume that the edges of are directed away from the root. For each directed edge in , we say that is a parent of (and we denote it by ) and that is a child of . Every vertex except the root has a unique parent. If there is a (directed) path from vertex to vertex in , we say that is an ancestor of and that is a descendant of , and we denote this path by . If , we say that is a proper ancestor of and that is a proper descendant of , and denote by the path in to from the child of that is an ancestor of . The ancestor/descendant relationship can be naturally extended to edges. Namely, let be a vertex and be an edge of . If is an ancestor (resp., proper ancestor) of (and thus also of ), we say that is an ancestor (resp., proper ancestor) of edge and that is a descendant (resp., proper descendant) of . Similarly, if is a descendant (resp., proper descendant) of (and thus also of ), we say that is a descendant (resp., proper descendant) of edge and that is an ancestor (resp., proper ancestor) of . Let and be two edges in . If vertex is an ancestor of vertex , we say that edge is an ancestor of edge and that edge is a descendant of edge . Also, for a rooted tree , we let denote the subtree of rooted at , and we also view as the set of descendants of .

Let be a depth first search (dfs) tree of a digraph , starting from a given vertex . Edge of the digraph is a tree edge if , a forward edge if is a proper ancestor of in , a back edge if is a proper descendant of in , and a cross edge if and are unrelated in . A preorder of is a total order of the vertices of such that, for every vertex , the descendants of are ordered consecutively, with first. It can be obtained by a depth-first traversal of , by ordering the vertices in the order they are first visited by the traversal. The following lemma is an immediate consequence of depth-first search.

Lemma 2.1.

(Path Lemma [25]) Let be a dfs tree of a digraph , and let denote the preorder number of vertex in . If and are vertices such that , then any path from to must contain a common ancestor of and in .

2.1 Flow graphs, dominators, and bridges

A flow graph is a directed graph with a distinguished start vertex such that every vertex is reachable from . Let be a strongly connected graph. The reverse digraph of , denoted by , is the digraph that results from by reversing the direction of all edges. Throughout the paper we let be a fixed but arbitrary start vertex of . Since is strongly connected, all vertices are reachable from and reach , so we can view both and as flow graphs with start vertex . To avoid ambiguities, throughout the paper we will denote those flow graphs respectively by and .

Let be a flow graph with start vertex . A vertex is a dominator of a vertex ( dominates ) if every path from to in contains ; is a proper dominator of if dominates and . Let dom be the set of dominators of . Clearly, dom and for any we have that dom: we say that and are the trivial dominators of in the flow graph . The dominator relation is reflexive and transitive. Its transitive reduction is a rooted tree, the dominator tree : dominates if and only if is an ancestor of in . If , the parent of in , denoted by , is the immediate dominator of : it is the unique proper dominator of that is dominated by all proper dominators of . Similarly, we can define the dominator relation in the flow graph , and let denote the dominator tree of . We also denote the immediate dominator of in by . Throughout the paper, we let (resp., ) denote the set of nontrivial dominators of (resp., ). Lengauer and Tarjan [19] presented an algorithm for computing dominators in time for a flow graph with vertices and edges, where is a functional inverse of Ackermann’s function [27]. Subsequently, several linear-time algorithms were discovered [2, 4, 8, 9].

An edge is a bridge of a flow graph if all paths from to include .111Throughout the paper, to avoid confusion we use consistently the term bridge to refer to a bridge of a flow graph and the term strong bridge to refer to a strong bridge in the original graph. The following properties were proved in  [17].

Property 2.2.

([17]) Let be an arbitrary start vertex of . An edge is strong bridge of if and only if it is a bridge of (so ) or a bridge of (so ) or both.

Property 2.3.

([17]) Let be an arbitrary start vertex of . A vertex is a strong articulation point of if and only if is a nontrivial dominator in or a nontrivial dominator in or both.

Figure 1: A flow graph and its reverse , and their dominator trees and . The corresponding digraph is strongly connected. The solid edges in and are the edges of depth first search trees with root . Strong bridges of and and bridges of and in and are shown red. The bridge decomposition of and is obtained after deleting the red edges. (Better viewed in color.)

As a consequence of Property 2.2, all the strong bridges of the digraph can be obtained from the bridges of the flow graphs and , and thus there can be at most strong bridges in a digraph . Figure 1 illustrates a strongly connected graph , its reverse graph and the dominator trees and . Let be a strong bridge of such that is a bridge of . Since there is no danger of ambiguity, with a little abuse of notation we will say that is a bridge of (although it is actually the reverse edge that is a bridge of ). We refer to the edges that are bridges in both flow graphs and as common bridges. We will use the following lemmata from [10, 11] that hold for a flow graph of a strongly connected digraph .

Lemma 2.4.

([10]) Let be a strongly connected digraph and let be a strong bridge of . Also, let and be the dominator trees of the corresponding flow graphs and , respectively, for an arbitrary start vertex .

  • Suppose . Let be any vertex that is not a descendant of in . Then there is path from to in that does not contain any proper descendant of in . Moreover, all simple paths in from to any descendant of in must contain the edge .

  • Suppose . Let be any vertex that is not a descendant of in . Then there is path from to in that does not contain any proper descendant of in . Moreover, all simple paths in from any descendant of in to must contain the edge .

Lemma 2.5.

([11]) Let be a strongly connected digraph and let be a strong articulation point of . Also, let and be the dominator trees of the corresponding flow graphs and , respectively, for an arbitrary start vertex .

  • Suppose is a nontrivial dominator of . Let be any vertex that is not a descendant of in . Then there is a path from to in that does not contain any proper descendant of in . Moreover, all simple paths in from to any descendant of in must contain .

  • Suppose is a nontrivial dominator of . Let be any vertex that is not a descendant of in . Then there is a path from to in that does not contain any proper descendant of in . Moreover, all simple paths in from any descendant of in to must contain .

After deleting from the dominator trees and respectively the bridges of and , we obtain the bridge decomposition of and into forests and (see Figure 1). Throughout the paper, we denote by (resp., ) the tree in (resp., ) containing vertex , and by (resp., ) the root of (resp., ).

2.2 Loop nesting forests

Let be a directed graph. A loop nesting forest represents a hierarchy of strongly connected subgraphs of  [28], and is defined with respect to a dfs tree of as follows. For any vertex , the loop of , denoted by , is the set of all descendants of in such that there is a path from to in containing only descendants of in . Vertex is the head of . Any two vertices in reach each other. Therefore, induces a strongly connected subgraph of ; it is the unique maximal set of descendants of in that does so. The sets form a laminar family of subsets of : for any two vertices and , and are either disjoint or nested (i.e., one contains the other). The above property allows us to define the loop nesting forest of , with respect to , as the forest in which the parent of any vertex , denoted by , is the nearest proper ancestor of in such that if there is such a vertex , and null otherwise. Then is the set of all descendants of vertex in , which we will also denote as (the subtree of rooted at vertex ). Since is a dfs tree, every cycle contains a back edge [25]. More generally, every cycle contains a vertex that is a common ancestor of all other vertices of in the cycle [25], which means that any is in . Hence, every cycle of is contained in a loop. A loop nesting forest can be computed in linear time [4, 28]. Since here we deal with strongly connected digraphs, each vertex is contained in a loop, so is a tree. Therefore, we will refer to as the loop nesting tree of . Figure 2 shows the loop nesting trees of the flow graphs and given in Figure 1.

Figure 2: The loop nesting trees and of the flow graphs and of Figure 1 respectively, with respect to the dfs trees shown in Figure 1.

The following lemma will be useful throughout the paper.

Lemma 2.6.

Let be any vertex in . Let be the parent of in the loop nesting tree and be the root of the tree in the bridge decomposition . Then is an ancestor of in .

Proof.

Assume by contradiction that is not an ancestor of in . Let be the dfs tree based on which the loop nesting tree was built. By the definition of dominators, all paths from to contain , and therefore is an ancestor of in . By Lemma 2.4(a) all paths from to in contain the strong bridge . But this is a contradiction to the fact that there is a path from to containing only descendants of in , since is an ancestor of in . ∎

3 Strongly connected components after an edge deletion

In this section, we consider the effect of an edge deletion on the strong connectivity properties of a digraph . In particular, let be an edge to be deleted from . We will show how to solve efficiently the following problems:

  • Compute all the strongly connected components of ;

  • Count the number of strongly connected components of ;

  • Find the smallest or the largest strongly connected components of .

Throughout this section, we assume without loss of generality that the input digraph is strongly connected (otherwise, we apply our algorithms to the strongly connected components of ). If is strongly connected, then , where and are respectively the number of edges and vertices in , which will simplify some of the bounds. All our algorithms are based on dominator trees and loop nesting forests, so we fix arbitrarily a start vertex in . We also restrict our attention to the strong bridges of , since only the deletion of a strong bridge of can affect its strongly connected components.

Let be a strongly connected digraph, be an arbitrary start vertex in , and let be a strong bridge of . We will first prove some general properties of the strongly connected components of . We will then exploit those properties in Sections 3.1, 3.2 and 3.3 to design efficient solutions for our problems. Consider the dominator relations in the flow graphs and . By Property 2.2, one of the following cases must hold:

  • is a bridge in but not in , so and .

  • is a bridge in but not in , so and .

  • is a common bridge, i.e., a bridge both in and in , so and .

We will show how to compute the strongly connected components of in each of these cases. Consider , i.e., when either (a) or (c) holds. Case (b) is symmetric to (a). By Lemma 2.4, the deletion of the edge separates the descendants of in , denoted by , from . Therefore, we can compute separately the strongly connected components of the subgraphs of induced by the vertices in and by the vertices in . We begin with some lemmata that allow us to compute the strongly connected components in the subgraph of that is induced by the vertices in . We recall here that, given the loop nesting tree of and a vertex in , we denote by the parent of in and by the set of descendants of in .

Lemma 3.1.

Let be a strong bridge of that is also a bridge in the flow graph (i.e., ). For any vertex the vertices in are contained in a strongly connected component of such that .

Proof.

Let be a vertex such that . We claim that and are strongly connected in . Let be the dfs tree that generated . Note that, since and , the path from to in the dfs tree avoids the edge . To show that and are strongly connected in , we exhibit a path from to that avoids the edge . Indeed, by the definition of the loop nesting forest, there is a path from to that contains only descendants of in . Note that cannot contain the edge since is a proper ancestor of in and all descendants of in are descendants of in , since all paths from to contain . Assume by contradiction that either or contains a vertex . But then, Lemma 2.4 implies that the either the subpath of from to or the subpath of from to contains , a contradiction. This implies that every pair of vertices in are strongly connected in . Let be the strongly connected component of that contains . The same argument implies that all vertices in are descendants of in . ∎

Lemma 3.2.

Let be a strong bridge of that is also a bridge in the flow graph (i.e., ). For every strongly connected component in such that there is a vertex that is a common ancestor in of all vertices in .

Proof.

Let be a strongly connected component of that contains only descendants of in . Let be the dfs tree that generated and let be the corresponding preorder numbering of the vertices. Define to be the vertex in with minimum preorder number with respect to . Consider any vertex . Since is a strongly connected component, there is a path from to that contains only vertices in . By the choice of , , so Lemma 2.1 implies that contains a common ancestor of and in . Also , since contains only vertices in . But then , since otherwise which contradicts the choice of . Hence is also an ancestor of in . ∎

Lemma 3.3.

Let be a strong bridge of that is also a bridge in the flow graph (i.e., ). Let be a vertex such that and . Then, the subgraph induced by is a strongly connected component of .

Proof.

From Lemma 3.1 we have that is contained in a strongly connected component of . Let be the vertex that is a common ancestor in of all vertices in , as stated by Lemma 3.2. The fact that implies , so is a maximal subset of vertices that are strongly connected in . Thus induces a strongly connected component of . ∎

Next we consider the strongly connected components of the subgraph of induced by .

Lemma 3.4.

Let be a strong bridge of that is a bridge in but not in (i.e., such that and ). Let . Then, the subgraph induced by is a strongly connected component of .

Proof.

By Lemma 2.4(a), a vertex in cannot be strongly connected in to a vertex in . Thus, it remains to show that the vertices in are strongly connected in . Note that by the definition of we have that . Now it suffices to show that for any vertex , digraph has a path from to and a path from to containing only vertices in . Assume by contradiction that all paths in from to contain a vertex in . Then, Lemma 2.4 implies that all paths from to contain , which contradicts the fact that . We use a similar argument for the paths from to . If all such paths contain a vertex in , then by Lemma 2.4 we have that all paths from to contain . Hence, also all paths from to must contain , which contradicts the fact that . ∎

Figure 3: An illustration of the sets , , , and that correspond to a common strong bridge , as they appear with respect to the dominator trees and . The vertices in are shown red, the vertices in are shown green, and the vertices in are shown blue. (Better viewed in color.) The remaining vertices are in .

Finally we deal with the more complicated case (c). We refer the reader to Figure 3 for an illustration of the sets involved in the lemma.

Lemma 3.5.

Let be a strong bridge of that is a common bridge of and (i.e., such that and ). Let . Then, the subgraph induced by is a strongly connected component of .

Proof.

The fact that is a strong bridge and Lemma 2.4 imply that the following properties hold in :

  • There is a path from to any vertex in that does not contain .

  • There is a path from any vertex in to that does not contain .

  • There is no edge such that and . In particular, since , there is no edge such that and .

  • Symmetrically, there is no edge such that and . In particular, since , there is no edge such that and .

Let be a strongly connected component of such that . By properties (3) and (4) we have that contains no vertex in . Thus . Let be the subgraph of induced by the vertices in . We will show that for any vertex digraph contains a path from to and a path from to . This implies that all vertices in are strongly connected in , and hence also in . Moreover, since is a strongly connected component of , we have that and that it induces a strongly connected component in .

First we argue about the existence of a path from to in . Let be a path in from to that does not contain . Property (1) guarantees that such a path exists. Also, Lemma 2.4 implies that does not contain a vertex in , since otherwise would include . It remains to show that also avoids . Assume by contradiction that contains a vertex in . Choose to be the last such vertex in . Since we have that . Let be the successor of in . From the fact that does not contain vertices in and by the choice of it follows that . But then, edge violates property (4), which is a contradiction. We conclude that path also exists in as claimed.

The argument for the existence of a path from to in is symmetric. Let be a path in from to that does not contain . From property (2) and Lemma 2.4 we have that such a path exists and does not contain a vertex in . Now we show that also avoids . Assume by contradiction that contains a vertex in . Choose to be the first such vertex in . Since we have that . Let be the predecessor of in . From the fact that does not contain vertices in and by the choice of it follows that . So, edge violates property (3). Hence path also exists in . ∎

Lemma 3.6.

Let be a strong bridge of that is a common bridge of and (i.e., such that and ). Let be a strongly connected component of that contains a vertex in . Then, .

Proof.

Consider any two vertices and such that and . We claim that and are not strongly connected in , which implies the lemma. To prove the claim, note that by Lemma 3.5, is not strongly connected in with any vertex in . Hence, we can assume that or . In either case, and are not strongly connected in by Lemma 2.4. ∎

The following theorem summarizes the results of Lemmata 3.3, 3.4, 3.5, and 3.6.

Theorem 3.7.

Let be a strongly connected digraph, be an arbitrary start vertex in , and let be a strong bridge of . Let be a strongly connected component of . Then one of the following cases holds:

  • If is a bridge in but not in then either or .

  • If is a bridge in but not in then either or .

  • If is a common bridge of and then either , or , or , or .

Moreover, if (resp., ) then (resp., ) where is a vertex in (resp., ) such that (resp., ).

3.1 Finding all strongly connected components after an edge deletion

In this section we show how to exploit Theorem 3.7 in order to find efficiently the strongly connected components of , for each edge in . In particular, we present an -space data structure that, after -time preprocessing, given a strong bridge of can report in time all the strongly connected components of . This is a sharp improvement over the naive solution, which computes from scratch the strongly connected components of in time. Furthermore, our bound is asymptotically tight, as one needs time to output the strongly connected components of a digraph. With our data structure we can output in a total of worst-case time the strongly connected components of , for each edge in , where is the total number of strong bridges in .

We next describe our data structure. First, we process the dominator trees and in time, so that we can test the ancestor/descendant relation in each tree in constant time [26]. To answer the query about a strong bridge , we execute a preorder traversal of the loop nesting trees and . During those traversals, we will assign a label to each vertex that specifies the strongly connected component of : that is, at the end of the preorder traversals of and , each strongly connected component will consist of vertices with the same label. More precisely, if is a bridge of but not of , then the preorder traversal of will identify the strongly connected components of all vertices. Similarly, if is a bridge of but not of , then we only execute a preorder traversal of . Finally, if is a common bridge, then the preorder traversal of will identify the strongly connected components of all vertices except for those in (i.e., the green vertices in Figure 3). The strongly connected components of these vertices will be discovered during the subsequent preorder traversal of .

We do this as follows. We initialize for all vertices . During our preorder traversals of and we will update for all vertices . Throughout, we will always have . Suppose is a bridge only in . We do a preorder traversal of , and when we visit a vertex we test if the condition holds. If it does, then the label of remains , otherwise the label of is updated as . We handle the case where is a bridge only in symmetrically. Suppose now that is a common bridge. During the preorder traversal of , when we visit a vertex , , we test if the condition holds. As before, if this condition holds then the label of remains , otherwise we set . Note that this process assigns to all vertices . Also, all vertices , where and are assigned . Finally, we need to assign appropriate labels to the vertices in . We do that by executing a similar procedure on . This time, when we visit a vertex , , we test if the condition holds. If it does, then the label of remains , otherwise we set . At the end of this process we have that all vertices , such that and , are assigned .

In every case, Theorem 3.7 implies that the above procedure assigns correct labels to all vertices. We remark that, during the execution of a query, each condition can be tested in constant time, since it involves computing the parent of a vertex in a loop nesting tree or checking the ancestor/descendant relationship in a dominator tree. This yields the following theorem.

Theorem 3.8.

Let be a strongly connected digraph with vertices and edges. We can preprocess in time and construct an -space data structure, so that given an edge of we can report in time all the strongly connected components of .

Corollary 3.9.

Let be a strongly connected digraph with vertices, edges and strong bridges. We can output the strongly connected components of , for all strong bridges in , in a total of worst-case time.

Figure 4: The dominator trees and and the loop nesting trees and of the flow graphs and of Figure 1 respectively. The edge in red is a common bridge. The vertices in are shown red. The vertices in are shown green, and the vertices in are shown blue. (Better viewed in color.) The remaining vertices are in .

Figure 5: The strongly connected components of where is the graph of Figure 1.

Figure 4 highlights the vertices of different sets (with respect to the strong bridge ) in the dominator trees and and the loop nesting trees and of the flow graph and given in Figure 1. Figure 5 shows the result of a reporting query for the digraph of Figure 1 and for the edge .

3.2 Counting the number of strongly connected components after an edge deletion

In this section we consider the problem of computing the total number of strongly connected components obtained after the deletion of a single edge in a strongly connected digraph . In particular, we describe a data structure which, after -time preprocessing, is able to answer the following aggregate query in worst-case time : “Find the total number of strongly connected components in , for all edges .” This provides a linear-time algorithm for computing the total number of strongly connected components obtained after the deletion of a single edge, for all edges in . Note that we need to answer this query only for edges that are strong bridges in ; indeed if is not a strong bridge, then has exactly the same strongly connected components as . Our bound is tight, and it improves sharply over the naive solution, which computes from scratch the strongly connected components of for each strong bridge of .

Let be a subset of vertices of . We denote by the number of the strongly connected components in the subgraph of induced by the vertices in . Also, for an edge of , we denote by the number of the strongly connected components in . Our goal is to compute for every strong bridge in . Theorem 3.7 yields immediately the following corollary.

Corollary 3.10.

Let be a strong bridge of . Then one the following cases holds:

  • If is a bridge in but not in then .

  • If is a bridge in but not in then .

  • If is a common bridge of and then .

Moreover, let be a strongly connected component of . If (resp., ) then (resp., ) where is a vertex in (resp., ) such that (resp., ).

Corollary 3.10 shows that in order to compute the number of strongly connected components in it is enough to compute , and . We will first show how to compute and . Next, we will present an algorithm for computing .

Computing and .

As suggested by Corollary 3.10, we can compute (resp., ) by counting the number of distinct vertices in (resp., in ) for which (resp., ). We do this with the help of the bridge decomposition (resp., ) of (resp., ) defined in Section 2.1. We recall that we denote by (resp., ) the tree in (resp., ) containing vertex , and by (resp., ) the root of the tree (resp., ).

To compute , we maintain a counter for each bridge in . counts the number of strongly connected components in that are subsets of encountered so far. Rather than processing the bridges of one at the time, we update simultaneously all counters for all bridges while visiting the bridge decomposition of the dominator tree in a bottom-up fashion. To update the counters , we exploit the loop nesting tree : we increment the counter of a bridge in whenever we find a vertex in such that , since is a strongly connected component of by Corollary 3.10. After the bridge decomposition of has been processed, for each strong bridge in we have that , i.e., the counter stores exactly the number of strongly connected components of containing only vertices in . In particular, by Corollary 3.10(a) we can compute for each strong bridge which is a bridge in but not in .

We can compute in a similar fashion. We maintain a counter for each bridge in . counts the number of strongly connected components in that are subsets of encountered so far. We visit in a bottom-up fashion the bridge decomposition of with the help of the loop nesting tree : we increment the counter of a bridge in whenever we find a vertex in such that , since is a strongly connected component of by Corollary 3.10. At the end of this visit, for each strong bridge in we have that . By Corollary 3.10(b) we can now compute for each strong bridge which is a bridge in but not in .

Note that if is a common bridge of and , then by Corollary 3.10(c) we have that . Thus, to complete the description of our algorithm we have still to show how to compute , i.e., the number of strongly connected components in the subgraph induced by the vertices in . We will deal with this issue later.

As previously mentioned, a crucial task for updating the counter (resp., ) for each strong bridge is to check for a vertex in (resp., in ) such that (resp., ). An efficient method to perform this test hinges on the following lemma.

Lemma 3.11.

For each vertex in , the following holds:

  • (resp., ) induces a strongly connected component of , for any bridge of (resp., ) in the path (resp., ) from to in (resp., from to in ).

  • (resp., ) does not induce a strongly connected component of , for any bridge of (resp., ) in the path (resp.,