1. Introduction
Strongly connected components (SCCs) refer to a subgraph structure in digraphs in which every pair of vertices can reach each other. If an SCC contains only one vertex, it is called trivial. Otherwise, it is called nontrivial, which is the main goal of SCC knowledge discovery tasks.
Some serial [
1,
2,
3,
4,
5,
6,
7,
8] algorithms have been proposed for computing SCCs. Due to the inherent efficiency disadvantages of serial algorithms compared with parallel algorithms, some parallel [
6,
9,
10,
11,
12,
13,
14,
15,
16,
17] algorithms have been proposed. Tarjan [
1] is a well-known serial algorithm for computing SCCs. The time complexity of Tarjan is
O(n+m), where
n is the number of vertices and
m is the number of edges. However, it is not computationally efficient when dealing with large amounts of data. To address this issue, a parallel SCC algorithm based on a union-find data structure (UFSCC) [
10] was proposed. It uses the union-find data structure to synchronize the vertices’ state information between different processors to avoid the current vertex’s SCC from being computed repeatedly. The time complexity of UFSCC is
O(q·(n+m)), and the space complexity of UFSCC is
O(q· n), where
q is the number of processors. The nested depth-first search (NDFS) algorithm [
13] is a linear temporal logic (LTL) model-checking algorithm. Although it is also a serial algorithm, it uses a different idea to Tarjan’s. With the process of computing SCCs in the NDFS, the state of each vertex is modified by two search processes, once in blue DFS and once in red DFS. The time complexity of NDFS is
O(n· log(n)). The multi-core nested depth-first search (MC-NDFS) algorithm [
14] is a parallel variant of the NDFS algorithm. It implements parallelization of the blue and red DFS using a shuffle (random) function. The time complexity of MC-NDFS is
. The space complexity of MC-NDFS is
, where
N is the number of threads. The forward–backward (FB) algorithm [
15] is an important parallel recursive algorithm for computing SCCs. It uses breadth-first search (BFS) to decompose the digraph into subgraph slices. The time complexity of FB is
O(n· (n+m)), and the space complexity of FB is
O(m+n·(maximum depth of recursion
)). In addition, the OWCTY-BWD-FWD (OBF) algorithm [
16] decomposes a digraph into several independent subgraph slices to compute SCCs. In detail, the OWCTY function is repeatedly invoked to eliminate the vertices that constitute trivial SCCs. Subsequently, the digraph is divided into different subgraph slices using a forward and backward reachability search. Then, the FB algorithm is used to compute the SCCs contained in each subgraph slice. The time complexity of OBF is
O(n· (n+m)), and the space complexity of OBF is
O(m+n·(maximum depth of recursion
)). Parallel identification of SCCs with the spanning trees (ISPAN) algorithm [
17] is a parallel algorithm for computing SCCs. It uses simple spanning trees to identify SCCs. The time complexity of ISPAN is
O().
Granular computing (GrC) [
18,
19,
20,
21,
22,
23] is a methodology for viewing the objective world. It abstracts and divides a complex problem into simple problems. Thus, the complexity of solving problems can be reduced, and the efficiency of solving problems can be improved by introducing the idea of GrC [
24,
25,
26,
27,
28]. GrC has been applied to uncertainty handling in decision analysis [
29,
30,
31,
32,
33] and solving graph theory [
34,
35,
36,
37,
38,
39]. For SCCs problem solving, granulation strategies based on SCC correlations have been introduced. In [
7], two nontrivial SCC correlations were found, and a granulation strategy was proposed based on them. Vertex granules corresponding to each vertex were constructed using the granulation strategy. If vertex
x has been confirmed to belong to a nontrivial SCC, then vertices in the vertex granule of
x can be regarded as redundant vertices for computing SCCs. This conclusion can narrow the solution domain without complicated computations to improve the computational efficiency of SCCs. Furthermore, two trivial SCC correlations were found by Cheng et al. [
8]. Subsequently, a granulation strategy based on four SCC correlations was proposed. This granulation strategy is unidirectional; as a result, vertices satisfying these correlations are unidirectionally added to the corresponding vertex granule. Therefore, SCC correlations between vertex granules are transitive. Based on this transitivity, a series of redundant vertices can be found by searching vertex granules with BFS. Consequently, the computational efficiency of SCCs was further enhanced. The time complexities of algorithms in [
7,
8] are both
O(c·(n+m)), where
c is the number of nontrivial SCCs.
Vertex granules were used to solve the problem of SCC discovery in a serial manner in [
7,
8]. However, they have inherent disadvantages in terms of efficiency. In view of this, this paper carries out the following work: (1) firstly, the SCC correlations between vertices are analyzed deeply. Then, four new SCC correlations are obtained, which can be divided into two classes: trivial and nontrivial SCC correlations. (2) Secondly, two new granulation strategies are designed based on the above two classes of SCC correlations. These two granulation strategies are implemented by two functions named GVT (granulate vertex by trivial correlations) and GVNT (granulate vertex by nontrivial correlations), respectively. Computations of SCCs for vertices found by GVT can be considered redundant computations; therefore, these vertices can be added to the vertex granule. The same is true for vertices found by GVNT. (3) Thirdly, computations of SCCs for vertices that do not satisfy either of these granulation strategies must be performed. Consequently, a parallel method for computing SCCs is realized based on the characteristics of vertex granules. (4) Finally, a parallel algorithm based on a granulation strategy named GPSCC is proposed to compute SCCs of simple digraphs.
The rest of this paper is arranged as follows:
Section 2 recalls related concepts concerning SCCs.
Section 3 analyzes the SCC correlations between vertices.
Section 4 puts forward a parallel algorithm named GPSCC for computing SCCs.
Section 5 displays the experimental results and related analysis.
Section 6 concludes this work.
2. Preliminaries
In this section, for the convenience of formal description, some basic concepts of SCCs are briefly introduced.
Definition 1 ([40]). A directed graph (or digraph) consists of a nonempty finite set U of elements called vertices and a finite set E of ordered pairs of distinct vertices called directed edges. The size of U is denoted by or n. The size of E is denoted by or m. There is a binary relation ‘’ on U called the reachable relation. For two distinct vertices, x and y, in U, if x is reachable to y (), then there is a sequence of vertices and edges leading from x to y. Then, x is called an of y, and y is called a descendant of x. If the sequence only contains an edge, then x is called a predecessor of y, and y is called a successor of x. is a set of vertices that is reachable from x, is a set of vertices that is reachable to x, is a set of vertices that is reachable from x by an edge, and is a set of vertices that is reachable to x by an edge. For convenience, is abbreviated to , is abbreviated to , is abbreviated to , and is abbreviated to . Notably, x is always reachable to x (); thus, it is straightforward and , which also means that the set of contains x.
The concept of loop is a directed edge which connects a vertex twice. If a digraph contains neither loop nor multiple directed edges, it is called a simple digraph. All the digraphs mentioned in this paper are simple digraphs. For a simple digraph, and can be concluded.
Definition 2 ([1]). Let be a digraph. For each pair of vertices , if x is always reachable to y () and from y (), then D is strongly connected. Proposition 1 ([6]). Let be a digraph. If there are three vertices , such that and , then . Definition 3 ([1]). Let be a digraph. We may define an equivalence relation of U as follows: for , x and y are equivalent if and . Let the distinct equivalence classes under this equivalence relation be . Let , where . If each is strongly connected, and no is a proper subgraph of a strongly connected subgraph of D, then the subgraphs are referred to as strongly connected components
(SCCs) of D. Furthermore, the is referred to as a trivial SCC if contains only one vertex; is called a nontrivial SCC if contains two distinct vertices at least. For convenience, we use the set to collect the vertex sets of trivial SCCs in D, snf the set to collect the vertex sets of nontrivial SCCs in D. Obviously, the computation of is the target, rather than .
Lemma 1. Let be a digraph. For any , .
Proof. (1) If
, then
because
x is always reachable to itself (i.e.,
); if
, then
according to the definitions of
and
; if
, then there must be
, which leads to
. Together, the following can be found:
To conclude, if , there must be .
(2) Reversely, and can deduce .
and can deduce . That is to say, there is a sequence of vertices and edges leading from x to z. If the sequence only contains an edge, then can be obtained. If the sequence contains at least two edges, then there must be so that . In other words, . Together, can infer .
Combining (1) and (2), can be obtained. □
Lemma 2. Let be a digraph. For any ,
Proof. (1) If
, then
because
x is always reachable to itself (i.e.,
); if
, then
according to the definitions of
and
; if
, then there must be
, which leads to
. Together, the following can be obtained:
To conclude, if , then there must be .
(2) Reversely, and can deduce .
and can deduce . That is to say, there is a sequence of vertices and edges leading from z to x. If the sequence only contains an edge, then can be obtained. If the sequence contains at least two edges, then there must be so that . In other words, . Together, can infer .
Combining (1) and (2), can be obtained. □
Theorem 1. Let be a digraph. For any , if , then is a set of vertices of a SCC of D.
Proof. For any pair of vertices of
, we can obtain
and
, then
According to Definition 3, it can be obatined that is a set of vertices of a SCC of D. □
Proposition 2. Let be a digraph. If , then .
Proof. According to Lemma 1, . If , then . According to Lemma 2, . Using Theorem 1, , which leads to . □
Proposition 3. Let be a digraph. If , then .
Proof. According to Lemma 2, . If , then . According to Lemma 1, . Using Theorem 1, , which leads to . □
Example 1. Let be a digraph, as shown in Figure 1a, U = {a, b, c, d, e, f, g, h, i, j}, E = {(a, b), (b, e), (b, d), (c, b), (d, f), (e, f), (e, d), (f, h), (h, d), (h, g), (i, h), (i, j), (j, i)}. The digraph of D contains seven SCCs: five trivial SCCs, , , , , and two nontrivial SCCs, and . The nontrivial SCCs in D are marked as blue regions, and the trivial SCCs in D are marked as orange regions, as shown in Figure 1b. 3. SCCs Correlations between Vertices
In this subsection, we analyze the graph concept of SCCs, and then four SCCs correlations are found, as shown in Theorems 2–5. If two distinct vertices, x and y, satisfy any above Theorem, then after computing SCCs for x, y will not deduce any new nontrivial SCCs. In other words, vertex y will lead to redundant computation. Then, Theorems 2–5 can be used to avoid such redundant computations.
Theorem 2. Let be a digraph. If satisfies , then .
Proof. According to the Theorem 1, . It is known that there must be . Let , then if is judged as empty.
Suppose that , then ⇒⇒. According to Lemma 1, , then .
(1) Now that , it is obvious that . Then, can be concluded.
(2) Suppose , then . Now that , it is obvious that . implies , then and can be obtained. Furthermore, there is because there must be , which is results from the fact that there is no loop in simple digraphs. That is to say, there are two distinct vertices, x and y, which are reachable to each other. Then, can be obtained according to Definition 3. To sum up, ) is true. However, the conclusion conflicts with the given condition of ). By the principle of contrary evidence, the hypothesis of is false. Then, can be concluded.
(3) Suppose , then . Firstly, can deduce and . Secondly, . Because , then we can obtain . means . Then, holds on the basis of and . , and show that there are two distinct vertices, x and y, which are reachable to each other. Then, it can be obtained that according to Definition 3. To sum up, ) is true. However, the conclusion conflicts with the given condition of ). By the principle of contrary evidence, the hypothesis of is false. Then, can be concluded.
Combining (1), (2), and (3), can be concluded. Thus, , i.e., . Overall, if satisfies , then . □
Theorem 3. Let be a digraph. If satisfies , then .
Proof. According to Theorem 1, . It is known that there must be . Let , then if .
Suppose that , then According to Lemma 2, .
(1) Now that , it is obvious that . Then, can be concluded.
(2) Suppose , then . Now that , it is obvious that . implies , then and can be obtained. Furthermore, there is because there must be , which results from the fact that there is no loop in simple digraphs. That is to say, there are two distinct vertices, x and y, which are reachable to each other. Then, can be obtained according to Definition 3. To sum up, ) is true. However, the conclusion conflicts with the given condition of ). By the principle of contrary evidence, the hypothesis of is false. Then, can be concluded.
(3) Suppose , then . Firstly, can deduce and . Secondly, . Because , then we can obtain . means . Then, holds on the basis of and . , , and show that there are two distinct vertices, x and y, which are reachable to each other. Then, it can be obtained that according to Definition 3. To sum up, ) is true. However, the conclusion conflicts with the given ). By the principle of contrary evidence, the hypothesis of is false. Then, can be concluded.
Combining (1), (2), and (3), can be concluded. Thus, , i.e., . Overall, if satisfies , then . □
Theorem 4. Let be a digraph. , if , then .
Proof. According to Theorem 1, . If , then . In other words, there are at least two distinct vertices, x and z, in the nontrivial SCCs corresponding to . Along with Definition 3, and can be obtained. means that . According to Lemma 1, . Then, would deduce that or .
(1) If , then . By replacing z with y, can be obtained.
(2) If , then . Firstly, can deduce (), which means . Secondly, can deduce , along with the obtained in the above part, and can be concluded according to Proposition 1. , , and show that there are two distinct vertices, x and y, which are reachable to each other. That is to say, . Overall, there must be .
Combining (1) and (2), if , then . □
Theorem 5. Let be a digraph. , if , then .
Proof. According to Theorem 1, . If , then . In other words, there are at least two distinct vertices, x and z, in the nontrivial SCCs corresponding to . Along with Definition 3, and can be obtained. means that . According to Lemma 2, . Then, would deduce that or .
(1) If , then . By replacing z with y, can be obtained.
(2) If , then . Firstly, can deduce (), which means . Secondly, can deduce , along with obtained in the above part, and can be concluded according Proposition 1. , , and show that there are two distinct vertices, x and y, which are reachable to each other. That is to say, . Overall, there must be .
Combining (1) and (2), if , then . □
5. Experiments
All experiments were performed on AMD (R52600) with 12 processors and 24 GB of memory. MATLAB@R2017a(64-bit) was the experiment platform. Tarjan [
1], FB [
15], OBF [
16], and ISPAN [
17] algorithms were used as comparison algorithms to verify the efficiency of the GPSCC algorithm. In total, 12 UFMC datasets [
41] were used in these experiments, as shown in
Table 1, where
n is the number of vertices,
m is the number of edges, and
c is the number of nontrivial SCCs in a dataset. In addition, the graph was stored in the form of a matrix. Considering the impact of cache memory on the speedup effect, the priority principle of columns was used to read and write data.
The computational efficiencies of the Tarjan, FB, OBF, ISPAN, and GPSCC algorithms are shown in
Table 2,
Table 3,
Table 4,
Table 5,
Table 6 and
Table 7. Columns 2–5 of each table represent the execution times of the four algorithms, and the optimal values are set in bold.
represents the speedup of FB, OBF, ISPAN, and GPSCC compared to Tarjan. In detail,
is computed as the ratio of the time consumed by Tarjan against FB, OBF, ISPAN, and GPSCC. In addition, the acceleration of speedup is computed as the variation of speedup divided by the variation of processors.
Table 2,
Table 3,
Table 4,
Table 5,
Table 6 and
Table 7 show that GPSCC has a higher speedup effect against Tarjan than the FB, OBF, and ISPAN algorithms. Furthermore, the speedup of GPSCC against Tarjan on the same dataset increases with the number of processors. Once the number of processors is determined, the effect of granulation strategies is highly related to the data structure of the given digraph. The changing curves of the speedup are shown in
Figure 2.
From
Figure 2, three phenomena can be observed: (1) the speedup of GPSCC against Tarjan significantly increases with the increasing number of processors, as shown in
Figure 2c–g,j–l. Correspondingly, the acceleration of GPSCC against Tarjan is greater than zero on average. (2) The speedup of GPSCC against Tarjan slowly increases with the increasing number of processors, as shown in
Figure 2h,i. Correspondingly, the acceleration of GPSCC against Tarjan tends to be zero on average. (3) The speedup of GPSCC against Tarjan decreases with the increasing number of processors, but it is still much higher than Tarjan, as shown in
Figure 2a,b. Correspondingly, the acceleration of GPSCC against Tarjan is less than zero on average.
For the first phenomenon, let the EVA dataset be used as an example to analyze the reason. The scale of the SCCs in each digraph is similar. Therefore, each time consumption of SCCs is similar, as shown in
Figure 3a. Then, the time consumption of SCCs can be approximately evenly distributed into the processor. This means that the load on the processor is balanced, as shown in
Figure 4a.
For the second phenomenon, let the FA dataset be used as an example to analyze the reason. Firstly, the number of SCCs that need to be computed is certain. Secondly, there are some larger SCCs, which consume a larger proportion of time, as shown in
Figure 3b. This means that there is processor load imbalance, as shown in
Figure 4b. Then, increasing the number of processors has less of an effect on the overall time consumption.
For the third phenomenon, let the DK01R and CollegeMsg datasets be used as examples to analyze the reason. The scales of the given digraphs and SCCs are relatively small. Therefore, the time consumption of data interaction and resource allocation may be greater than for computing SCCs, as shown in
Figure 5a,b. Then, with the increasing number of processors, the time consumption of data interaction and resource allocation also increases, which negatively impacts the overall time.
In conclusion, it can be obtained that the structure of the digraph will affect the time consumed by computing each SCC. Then, the proportion of time consumed by computing each SCC will affect whether the processor load is balanced, and whether the processor load is balanced will affect the efficiency of GPSCC for computing SCCs. Therefore, the speedup effect of GPSCC against Tarjan is greatly influenced by the digraph structure.