AOT: Pushing the Efficiency Boundary of Main-memory Triangle Listing
aa r X i v : . [ c s . D B ] J un AOT: Pushing the Efficiency Boundary ofMain-memory Triangle Listing
Michael Yu , Lu Qin , Ying Zhang , Wenjie Zhang , and Xuemin Lin University of New South Wales { mryu,wenjie.zhang,lxue } @cse.unsw.edu.au University of Technology Sydney { lu.qin,ying.zhang } @uts.edu.au Abstract.
Triangle listing is an important topic significant in manypractical applications. Efficient algorithms exist for the task of trianglelisting. Recent algorithms leverage an orientation framework, which canbe thought of as mapping an undirected graph to a directed acylic graph,namely oriented graph , with respect to any global vertex order. In thispaper, we propose an adaptive orientation technique that satisfies theorientation technique but refines it by traversing carefully based on theout-degree of the vertices in the oriented graph during the computation oftriangles. Based on this adaptive orientation technique, we design a newalgorithm, namely AOT, to enhance the edge-iterator listing paradigm.We also make improvements to the performance of AOT by exploitingthe local order within the adjacent list of the vertices.We show that AOT is the first work which can achieve best performancein terms of both practical performance and theoretical time complexity.Our comprehensive experiments over 16 real-life large graphs show a su-perior performance of our AOT algorithm when compared against thestate-of-the-art, especially for massive graphs with billions of edges. The-oretically, we show that our proposed algorithm has a time complexity of Θ ( P h u,v i∈ E min { deg + ( u ) , deg + ( v ) } )), where E and deg + ( x ) denote theset of directed edges in an oriented graph and the out-degree of vertex x respectively. As to our best knowledge, this is the best time complexityamong in-memory triangle listing algorithms. Keywords:
Triangle · Enumeration · Graph algorithm
Triangle-listing is one of the most fundamental problems in graphs, with nu-merous applications including structural clustering [25], web spamming discov-ery [4], community search [5,18], higher-order graph clustering [26], and rolediscovery [6]. A large number of algorithms have been proposed to efficientlyenumerate all triangles in a given graph. These include in-memory algorithms[20,19,15,27], I/O efficient algorithms [7,8,11,12], and parallel/distributed algo-rithms [21,10,16], etc. In this paper, we focus on in-memory triangle-listing al-gorithms and aim to achieve the best performance from both theoretical andpractical aspects.
State-of-the-art.
The existing state-of-the-art in-memory triangle-listing algo-rithms are based on vertex ordering and orientation techniques [15,9]. Given anndirected simple graph, these algorithms first compute a total-order η for all itsgraph vertices; one example of such ordering is the non-increasing degree order.With the total-order η , a direction can then be specified for each undirectededge ( u, v ) such that η ( u ) < η ( v ). Once complete, the graph orientation tech-nique converts the initial undirected graph G into a directed acyclic graph G .With an oriented graph, the original problem of triangle-listing on an undirectedsimple graph G is recast to a problem of finding three vertices u, v, w so thatdirected edges h u, v i , h v, w i , h u, w i exist in G . For directed triangle instances,we refer to the role of vertex u with 2 out-going edges that form a triangle as apivot. Motivation.
We give an example for finding triangles in an oriented-graph[9]. For each pivot vertex u , the method first initializes an index to the out-neighbors of u ; after that, for each out-neighbor v of u , it traverses the out-neighbor w of v and checks to see whether w is also an out-neighbor of v in theindex. The advantage of this technique is twofold: First, by simply processing allpivot vertices using the above procedure, it already guarantees that each triangleis generated only once without performing the normal pruning for duplicatetriangle solutions. Secondly, parallelization of the algorithm is easy if we processsets of pivot vertices independently. This algorithm has the time complexity of Θ ( Σ v ∈ V deg + ( v ) · deg − ( v )) and is bounded by O ( m . ) [9], where V is the setof vertices in G ; deg + ( v ) and deg − ( v ) are the numbers of out-neighbors andin-neighbors of v in G respectively; and m is the number of edges in G .A dominant cost of the above algorithm is that of look-up operations, wherethe algorithm searches the out-neighbors of each pivot. A natural question israised: Is it possible to significantly reduce the number of look-up operationsneeded by the algorithm? To answer this question, we first find the time com-plexity of the former algorithm is equivalent to that of Θ ( Σ h u,v i∈ E deg + ( v )),where E is the set of directed edges in G . In other words, for each directededge h u, v i ∈ E , the algorithm will always spend deg + ( v ) amount of look-upoperations irrespective of whether deg + ( v ) ≤ deg + ( u ) holds. We find that if weare able to spend deg + ( u ) operations in the case that deg + ( v ) > deg + ( u ) forthe edge h u, v i ∈ E , the cost of the algorithm can be further lessened, there-fore it motivates us to explore new ways to further leverage the properties fromgraph orientation at a finer level, to improve the algorithm both theoreticallyand practically. Challenges.
Faced with the above problem, we ask intuitively: Can we tacklethe asymmetry by manually reversing the direction of each edge h u, v i ∈ E if deg + ( v ) > deg + ( u ) and then reuse the same algorithm on the now modifiedoriented graph? Unfortunately, this solution is infeasible. To explain, reversingthe direction of the selected edges can result in cycles ( h u, v i , h v, w i , and h w, u i ) inthe oriented graph G , such cyclic triangles will be missed by the aforementionedalgorithm. To ensure algorithmic correctness, for each undirected edge ( u, v ),up to two orientations need to be kept simultaneously: the original orientationin G and the orientation specified by the comparison of deg + ( u ) and deg + ( v )because the two orientations can be inconsistent. Therefore, to make our ideapractically applicable, the following issues will be addressed in this paper: (1)How can we integrate the two orientations to improve the algorithm complexity able 1. The Summary of Notations
Notation Definition G = ( V, E ) an undirected graph with vertices V and edges E G a directed graph with vertices V and directed edge E u, v, w, x, y vertices in the graph( u, v ) an undirected edge between vertices u and v h u, v i a directed edge from vertex u to v ( u, v, w ) a triangle with vertices u , v and wdeg ( u ) the degree of the vertex udeg + ( u ) the out-degree of u in oriented graph and also ensure that each triangle is enumerated once and only once? and (2)Can we further improve the efficiency of the algorithm practically by exploringsome local vertex orders? Contributions.
In this paper, we answer the above questions and make thefollowing contributions.(1) We have designed a new triangle listing algorithm named
Adaptive OrientedTriangle-Listing (AOT) by developing novel adaptive orientation and local or-dering techniques, which can achieve the best time complexity among the exist-ing algorithms in the literature.(2) We conduct an extensive performance study using 16 real-world large graphsat billion scale, to demonstrate the high efficiency of our proposed solutions. Theexperimental results show that our AOT algorithm is faster than the state-of-the-art solutions by up to an order of magnitude. It is also shown that AOT canbe easily extended to parallel setting, significantly outperforming the state-of-the-art parallel solutions.
Organization.
The rest of the paper is organized as follows. Section 2 providesa problem definition and states the notations used and introduce two state-of-the-art methods. Section 3 explains some motivation and explains our proposedalgorithm. Section 4 describes the experimental studies conducted and reports onfindings from the results. Section 5 presents the related work. Section 6 concludesthe paper.
In this section, we formally introduce the problem and the state-of-the-art tech-niques. Table 1 is a summary of the mathematical notations used in this paper.
Let G = ( V, E ) be an undirected simple graph, where V and E are a set ofvertices and a set of edges, respectively. Below, we also use V(G) and E(G) todenote V and E of a graph G. The number of vertices and the number of edges isdenoted as n and m for n = | V | and m = | E | , respectively. For undirected graph G , we denote the set of neighbors of vertex u in G as N ( u ) and denote the degreeof u in G as deg ( u ) which is equal to | N ( u ) | . For a directed graph G = ( V, E ),we use E to denote the set of directed edges {h u, v i} where u and v are thestarting and ending vertex respectively. We denote the set of outgoing-neighborsof vertex u in G as N + ( u ), and the out-degree as deg + ( u ) = | N + ( u ) | . Likewise,e denote the in-neighborhood of vertex u in G as N − ( u ), and the in-degreeas deg − ( u ) = | N − ( u ) | . By ( u, v ), we denote an undirected edge between twovertices u and v . A triangle is a set of three vertices fully connected to eachother. We denote by ( u, v, w ) a triangle consisting of three vertices u , v and w . Problem statement.
Given an undirected simple graph G = ( V, E ), we aimto develop an efficient main-memory algorithm to list all triangles in the graph G one by one, with both good time complexity and practical performance. We consider the method
Compact-forward (CF) [15] as a state-of-the-art for tri-angle listing; although it was designed in 2008, its efficiency for triangle listingis still referred to frequently [9]. There are two key components in the CF algo-rithm: the “ edge-iterator ” computing paradigm and the orientation technique.
Edge-iterator . The “edge-iterator” is a recurring computing paradigm for tri-angle listing, its strategy for triangle listing is to find triangles with referenceto pairs of adjacent vertices. Given an edge ( u, v ), any triangle that includesthe edge must contain a third vertex w that has connections to both of u and v . Thus, we can obtain any triangles containing edge ( u, v ) based on the inter-section of N ( u ) and N ( v ). For each edge, the edge-iterator returns the set oftriangles associated with that edge, and when repeated on all edges, the set ofall triangle solutions is made available. Orientation technique.
An orientation technique is recently leveraged in tri-angle listing algorithms, this involves the generation of a directed (i.e., oriented)graph G from an initially undirected input graph G [15]. Each undirected edgeis mapped to a directed edge where the direction (i.e., orientation) is decidedby the rank of its endpoints in a vertex-ordering (e.g., out-degree [15]). We referto vertex u as a pivot vertex if u has two out-going edges. We can association atriangle in the undirected graph with only one pivot vertex to ensure one andonly one instance of this triangle in the output, which significantly improves theperformance. Algorithm 1 : CF( G ) Input : G : an undirected graph Output : All triangles in G G ← Orientation graph of G based on degree-order; for each vertex u ∈ G do for each out-going neighbor v do T ← N + ( u ) ∩ N + ( v ) ; for each vertex w ∈ T do Output the triangle ( u, v, w ); Compact Forward (CF) Algorithm.
The CF algorithm is designed basedon the edge-iterator and the orientation technique. We show its pseudocode inAlgorithm 1. In line 1, undirected graph G is transformed into a directed graph G via the orientation technique. (Line 2 onward follows the edge-iterator frame-work.) In Line 3, triangles are enumerated by iterating through the outgoing- lgorithm 2 : kClist( G ) Input : G : an undirected graph Output : All triangles in G G ← Orientation graph of G based on degeneracy order η ; for each vertex u ∈ G do for any two out-going neighbors { v, w } of u with η ( v ) < η ( w ) do if there is a directed edge h v, w i ∈ E then Output triangle ( u, v, w ); neighborhoods rather than the full neighborhood. In Line 4, a merge-based in-tersection identifies the common out-going neighbors of u and v , denoted by T .A set of triangles ( u, v, w ) is then output for every vertex w ∈ T . Analysis.
Since all triangles identified are unique, a naive traversal of the ori-ented graphs edges (the outgoing-neighborhoods for each vertex) yields the com-plete set of unique solutions without explicit duplicate pruning. In terms of timecomplexity, the merge-based intersection operation at Line 4 takes Θ ( deg + ( u ) + deg + ( v )), assuming that the directed adjacency lists of u and v are sorted. Intotal, the CF algorithm has a complexity of Θ ( P h u,v i∈ E deg + ( u ) + deg + ( v )). Remark 1.
There is also an alternative implementation of the CF algorithm thatadopts hash tables for the intersection operation, namely CF-Hash. Supposea hash table has been built for each vertex based on the out-going neighborsin the oriented graph. At Line 4 of Algorithm 1, we may choose the vertexwith larger number of neighbors as the hash table for intersection operationwith Θ (min { deg + ( u ) , deg + ( v ) } ) look-up cost. This can come up with a bettertime complexity of Θ ( P h u,v i∈ E min { deg + ( u ) , deg + ( v ) } )). However, as reportedin [15,21] and our experiments, the practical performance of hash-based CF al-gorithm is not competitive compared to the above merge-based CF algorithm.Thus, the merge-based CF algorithm is used as the representative of CF algo-rithm in the literature. We introduce the second state-of-the-art algorithm for in-memory triangle list-ing. The kClist algorithm [9] lists cliques for a queried size k , we restrict ourdiscussion to the relevant use-case when k = 3 for listing triangles. kClist fol-lows the node-iterator triangle listing paradigm which is described below. Node-iterator . The “node-iterator” triangle listing paradigm lists triangles byinspecting for adjacency between vertex pairs within one vertex neighborhood.For example, consider the neighboring vertices of node u , if there is an edgebetween two neighbors v and v , then the triangle solution (u, v , v ) is output. k-Clique Listing (kClist) Algorithm . The kClist algorithm begins by gen-erating an oriented graph G based on the degeneracy ordering [2]. We use η todenote the degeneracy ordering here. In lines 3 - 5 of Algorithm 2, for every twoout-going neighbor v and w where η ( v ) < η ( w ), the existence of a directed edge h v, w i is assessed; for each edge found, a triangle solution is output. (cid:13)u(cid:13) pivot edge(cid:13) w(cid:13) x(cid:13) deg(u) < deg(v) < deg(w)(cid:13)deg(cid:13) +(cid:13) (u) < deg(cid:13) +(cid:13) (v)(cid:13) pivot vertex(cid:13) a(cid:13) b(cid:13) c(cid:13) Fig. 1.
Limit of orientation technique
Analysis . The running time of kClist is Θ ( m + P u ∈ V deg + ( u ) × deg − ( u )), thiscan also be expressed as Θ ( P h u,v i∈ E deg + ( v )). It is apparent that the timecomplexity of kClist is an improvement compared to the CF algorithm whichtakes Θ ( P h u,v i∈ E ( deg + ( u ) + deg + ( v ))) time, its practical performance is alsoshown to be efficient. We introduce our adaptive orientation technique and implement it in our algo-rithm, AOT, to push the efficiency boundary for main-memory triangle listingalgorithms.
Since the proposal of the orientation technique, its nice properties and goodpractical performance have allowed it to gradually become a valuable techniqueutilized in subsequent studies of triangle listing.
Shortcoming of Orientation Technique.
We recognize the prevalent usageof this orientation technique, however, we respond by showing that althoughcurrent methods leverage the salient benefits of orientation, there are still finerbenefits that are overlooked. We argue that there are still ways to further leverageproperties that can improve the existing performances of triangle-listing. Ourgoal is therefore to maximize the benefits of the orientation technique.In the following discussion of oriented edges, relative to a vertex u , we referto edges h u, v i as positive edges if the out-degree relation of its adjacent vertex v has an out-degree value that is greater or equal to that of the pivot vertex( deg + ( u ) ≤ deg + ( v )); we also refer to edges h u, v i as negative edges if the pivotvertex has the greater out-degree value ( deg + ( u ) > deg + ( v )).We refer to the time complexity of the kClist algorithm and see that it is Θ ( P h u,v i∈ E deg + ( v )) when listing triangles. However, this is not optimal for tri-angle listing. In Figure 1, consider the point in the triangle listing computationwhere triangles of edge h u, v i are processed. With respect to pivot vertex u , deg + ( v ) is larger than that of deg + ( u ) since 4 >
3. The aforementioned com-plexity is not favorable for processing this ordinary edge. Its issue is because itscost is strictly that of deg + ( v ) (i.e., 4). Our observation is that, if we can reversethe direction of the edge h u, v i to follow the out-degree vertex-order, we canprocess h u, v i more favorably with deg + ( u ) (i.e., 3) and come up with a bettertime complexity. olutions are non-trivial. Obviously, the optimal instance for a running timeof Θ ( P h u,v i∈ E deg + ( v )) is an oriented graph G where all edges are positive.However, most graphs do not exhibit that property: in most cases, not all graphsedges {h u, v i} are necessarily positive at the same. Recall Figure 1: while edgessuch as h u, x i and h u, w i are positive, negative edges such as h u, v i are alsopossible.We remedy the existence of negative edges by making a series of modificationsto the computed orientation of negative edges after it is oriented. One naive wayof achieving this is to manually change the direction of the oriented edge. Forexample, there is a negative edge h u, v i in Figure 1, we see that it can becomea positive edge if its direction is simply changed to h v, u i . This methodology islimited because it ultimately undermines the total order used in the orientation,moreover, changing h u, v i creates a cycle subgraph ( u, x, v, u ); this is a criticalcomplication since triangle ( u, x, v ) would surely be omitted and missing fromthe result set of existing methods.Ultimately, the out-degree of a vertex is a result of the orientation of itsincident edges, and therefore depends directly on the total ordering used forthe orientation techniques, it is difficult to significantly reduce the number ofnegative edges by manually changing its orientation. The main idea.
As an alternative, we instead suggest modifying the computingorder of u and v on the fly when encountering negative edges instances {h u, v i} .We notice that the CF algorithm cannot take advantage of this because its com-plexity of Θ ( deg + ( u ) + deg + ( v )) for every edge h u, v i suggests that the designof CF is insensitive to the direction of the edge. We also notice that the kClistalgorithm cannot do this either, because the accessing order of the vertices hasto strictly follow the degeneracy order on the oriented graph to ensure the cor-rectness of the algorithm. We have showed that two state-of-the-art techniquescannot trivially take advantage of this observation. In contrast, our algorithmdoes not depend on any total order, any total order will be acceptable.Following the above analysis, we are motivated to develop a technique thattightens the boundary for efficient triangle listing, by taking advantage of theresulting out-going degree order of each incoming edge, and adaptively listingtriangle based on its property. Our key idea involves selecting the optimal pivotvertices for each triangle accordingly, such that each triangle is found only fromthe vertex with a smaller out-going degree. This way we achieve the time com-plexity Θ (min { deg + ( u ) , deg + ( v ))) for every edge h u, v i ∈ E , which is now opti-mal for a given oriented graph following the edge-iterator paradigm.When finding the intersection between the out-going neighbors of adjacentvertices u and v (i.e. N + ( u ) ∩ N + ( v ) for an oriented edge h u, v i ), there is a largerand a smaller out-degree vertex, we use the hash-join approach as the appropriatemethod to perform the set-intersection. Note that one hash-table here containthe out-going neighbors for one single vertex. Following the hash-join approach,we choose to look-up the out-going neighbors of the vertex with the lesser out-degree in the hash structure of the vertex with the greater out-degree. However,with one endpoint fixed, within its adjacent neighborhood, the endpoint with thelesser out-degree vertex varies, to accomplish the former statement efficiently ishard because it is not known in advance which endpoint has the smaller out- ositive pivot edge(cid:13) w(cid:13) u(cid:13) negative pivot edg(cid:13) e(cid:13) y(cid:13)u(cid:13) x(cid:13) pivot vertex(cid:13) (a) Positive triangle(cid:13) (b) Negative triangle(cid:13) v(cid:13) pivot vertex(cid:13) Fig. 2.
Motivation for Adaptive Orientation degree vertex. The known solution requires both hash tables for either endpointsbe available when the edge is visited. There are two methods for constructingthe two indexes in advance: (1) Building hash tables of all graph vertices priorto listing. Where this is a naive solution, it is computationally infeasible due toits high storage demand and a high look-up cost. (2) For each vertex u , buildinga hash table for all for its out-going neighbors on the fly. This is also infeasiblebecause one vertex is likely to need to rebuild its hash table multiple timesthroughout the listing stage. Categorizing Triangles.
To facilitate understanding of technique, we discusstwo categorizes for each triangle in an oriented graph G : positive triangle or negative triangle . The category of each triangle depends on its pivot edge: givenan oriented triangle, were refer to it as positive if its pivot edge h x, y i is positivei.e. η ( x ) < η ( y ) and deg + ( x ) ≥ deg + ( y ); otherwise, it is negative if η ( x ) < η ( y )and deg + ( x ) < deg + ( y ), where η is the vertex ordering used in the orientation.An example instance of positive and negative triangles is shown in Fig-ures 2(a)-(b). We consider the two triangles from a sample graph with a commonvertex u , we note that without additional structural information from the graph,the induced subgraphs u,v,w and x,u,y are isomorphic. However, with attentionto pivot edges h u, v i and h x, u i , we observe that the two triangles are differentin terms of the out-going degree order (the dotted line points to the vertex withthe higher out-degree), and there for their orientation is different.We propose seperate computations for the two types of triangles due to theirsubtle differences, by selecting different respective piviot veritices. The selectionof the pivot vertex affects the amount of computation to list the triangle. If itis a positive triangle, we remain consistent with the orientation technique anduse the vertex with two out-going edges as the pivot vertex (e.g. the vertex u inFigure 2(a)). However, if it is a negative triangle, we select a different vertex asthe pivot vertex (e.g. u in Figure 2(b)).A direct benefit from the above selection is that, every vertex u ∈ G isnow the pivot vertex for both positive and negative triangles solutions, wherethe previous technique rigidly processes all triangles as positive triangles. In thetraditional orientation technique, both triangles would be processed equally andlisted by vertices u and x respectively, this was because the pivot vertex of eachtriangle is strictly the vertex with two out-going edges and does not account forour positive or negative triangle definitions. A desirable property of our adaptiveorientation technique is that this way each vertex u only needs to build a hashtable once for its out-going neighbors.o conclude: For positive triangles with pivot vertex u , for each out-goingneighbor v of u (e.g. v in Figure 2(a)), we will look-up if each out-going neighbors w of v (e.g. w in Figure 2(a)) is also in the hash table, to see if w is also anout-going neighbor of u . For the negative triangles with pivot vertex u , for eachin-coming neighbor x of u (e.g. x in Figure 2(b)), we will look-up if each out-going neighbor y of x (e.g. y in Figure 2(b)) is also in the hash table, to see if y is also an out-going neighbor of u .As we later show in the theoretical analysis in Section 3.2, ourproposed adaptive orientation technique achieves the time complexity of Θ ( P h u,v i∈ E min { deg + ( u ) , deg + ( v ) } )) because, in terms of the hash-based in-tersection, the look-up operations will always be performed on the vertex withlarger out-degree values for each oriented edge. We introduce the algorithm with our proposed adaptive orientation technique.With reference to the pseudo-code in Algorithm 3, In line 1, the orientated graph G is generated following the degree vertex order. In lines 2-13, a vertex u actsas pivot vertex and lists its associated positive and negative triangles. For eachpivot vertex u , Line 3 generates a bitmap hash table H based on its adjacencyneighborhood.For pivot vertex u , all positive triangles are enumerated in Lines 4-8. Thatis, for each out-going neighbor v of u with deg + ( v ) < deg + ( u ) (i.e. positive pivotedge), we find its out-going neighbors which are also out-going neighbors of u by looking up the hash table H as illustrated in Figure 2(a).Similarly, all negative triangles for pivot vertex u are enumerated in Lines9-13. For each in-coming neighbor x of u with deg + ( x ) < deg + ( u ) (i.e. negativepivot edge), we find its out-going neighbors which are also out-going neighborsof u by looking up the hash table H as illustrated in Figure 2(b). Correctness.
To explain the correctness of our algorithm, we recall that eachoriented triangle in G belongs to either a positive type triangle or a negativetype triangle, we note that this is true for any vertex total-order.Given an oriented triangle ( u, v, w ): such that u is the pivot vertex, and h u, v i is its pivot edge as illustrated in Figure 1. If deg + ( v ) < deg + ( u ), then( u, v, w ) is a positive triangle with pivot vertex u ; given w is the common out-going neighbor of u and v , a triangle will be output at Line 8 of Algorithm 3.Otherwise, if the triangle is not positive i.e., if deg + ( u ) < deg + ( v ) , ( u, v, w ) isa negative triangle with pivot vertex v , this oriented triangle will be output atLine 13 of Algorithm 3 when v is the pivot vertex, because w is the common out-going neighbor of u and v . Evidently, this oriented triangle ( u, v, w ) will not beoutput under any other scenario when following the oriented triangle technique.Consequently, this showed that ( u, v, w ) will be output once and only once, thecorrectness of the Algorithm 3 follows. Time Complexity.
We use a bitmap with size | V | to implement the hash table H , where H [ v.ID ] = 1 if the vertex v is the out-going neighbor of the pivot Recall that ties are broken by vertex ID. lgorithm 3 : Our Algorithm – AOT (G)
Input : G : an undirected graph Output : All triangles in G G ← orientation graph of G based on degree-order; for u ∈ V ( G ) do Set-up the hash table H with IDs of the out-going neighbors of u ( N + ( u )) ; for every out-going neighbor v of u do if deg + ( v ) < deg + ( u ) then for every out-going neighbor w of v do if Find w in H then output triangle ( u, v, w ); for every in-coming neighbor x of u do if deg + ( x ) < deg + ( u ) then for every out-going neighbor y of x do if Find y in H then output triangle ( u, x, y ); vertex. For each pivot vertex u visited, we can use Θ ( deg + ( u )) time to initiateor clean the hash table H . Thus, the maintenance of H takes Θ (2 m ) time.Recall that for a pivot edge h u, v i , the set of triangles it outputs can bea mix of either positive or negative triangles. For every pivot edge h u, v i , thetime complexity for its positive triangles is Θ ( deg + ( v )) with deg + ( v ) < deg + ( u )since the time complexity of Line 8 is Θ (1). Similarly, the time complexity forits negative triangles is Θ ( deg + ( u )) with deg + ( u ) < deg + ( v ) since the timecomplexity of Line 13 is Θ (1). It follows that the total time complexity of ourAlgorithm 3 is Θ ( P h u,v i∈ E min { deg + ( u ) , deg + ( v ) } )) Example 1.
In Figure 3, the oriented graph has 14 vertices and 21 edges.Out of the 21 edges, 9 for which have a deg + ( v ) value of greater than 0. For P h u,v i∈ E deg + ( v )): Edges h v , v i , h v , v i and h v , v i each incur a cost of 3.Edges h v , v i , h v , v i , h v , v i each incur a cost of 2. Edges h v , v i , h v , v i and h v , v i each also incur a cost of 2. The remaining edges incur no cost.In total, P h u,v i∈ E deg + ( v )) = 3 + 3 + 3 + 2 + 2 + 2 + 2 + 2 + 2 = 21. For P h u,v i∈ E min { deg + ( u ) , deg + ( v ) } ): Edges h v , v i , h v , v i and h v , v i each in-cur a cost of 1. Edges h v , v i , h v , v i , h v , v i each also incur a cost of 1. Edges h v , v i , h v , v i and h v , v i each incur a cost of 2. The remaining edges incur nocost. In total, P h u,v i∈ E min { deg + ( u ) , deg + ( v ) } ) = 1+1+1+1+1+1+2+2+2 =12. The former is a calculation of the computation required by the state-of-the-art, the latter is the computations required by our algorithm. In comparison,Example 1 illustrates that our algorithm incurs significantly fewer computationto list triangles. Where the costs for some edges is the same between two algo-rithms, our algorithm uses less computation for edges h v , v i , h v , v i , h v , v i , h v , v i , h v , v i and h v , v i . (cid:13) v(cid:13) v(cid:13) v(cid:13) v(cid:13) v(cid:13) v(cid:13) v(cid:13) v(cid:13) v(cid:13) v(cid:13) v(cid:13) v(cid:13) v(cid:13) Fig. 3.
Example Graph
Remark 2.
Note that the bitmap hash table cannot be deployed by CF-Hashtechnique. Clearly, on large graphs we cannot afford to construct | V | bitmaphash tables each of which has size | V | . On the other hand, it is time consuming tobuild H on the fly because, unlike we build the hash table H only once for eachvertex in AOT algorithm, H might be built multiple times for a vertex becauseit’s hash table will be chosen (i.e., build on the fly) by CF-Hash algorithm onceits hash table size is smaller than that of pivot vertex. Space Complexity.
We only need to keep the graph G , the oriented graph G and the globalhash table H , as a result, Algorithm 3 is space efficient, with space complexity O ( m + n ) where m is the number of edges and n is the number of vertices in G . Exploiting Local Order.
In addition to the global vertex order, we also con-sider a local vertex ordering used to store vertices within the scope for eachvertex neighborhood list (i.e. local order ). In Algorithm 3, the dominant cost isthe hash table look-ups happen at Lines 7 and 12. There is a good chance that avertex w will be repeatedly checked because of the overlap of the neighborhood.Ideally, the ID of w should be kept in the CPU cache such that the followinglook-up of w can be processed efficiently. We may design sophisticate local or-dering strategy with some assumptions on the workload such that the neighborsof a (pivot) vertex is well organized by their neighborhood similarity. However,we cannot afford such cost for the preprocessing. In this paper, we order thevertices in the adjacent list of a vertex by the decreasing order of their degree;that is, we visit the vertices at Lines 4 and 9 in Algorithm 3 following the degreeorder. This is because we believe the vertex with a high degree is more likelyto have common neighbors with other vertices. For each vertex, we can keep itsneighbors with this local order in the adjacent list. Our empirical study confirmsthe efficiency of this local order strategy. Algorithms.
To show the efficiency of our proposed technique, we compareour proposed algorithm with the following state-of-the-art methods. In total, wemake comparisons between the four algorithms listed below. – CF [15,21]. The CF algorithm, presented in Section 2.2. – CF-Hash [15,21]. A variant of CF, where the intersection of two adjacencylists are implemented by hashing. When it is chosen as the pivot vertexraph
Table 2.
Statistics of 16 Datasets. – kClist [9]. The kClist algorithm for triangle listing, presented in Section 2.3. – AOT . Our proposed algorithm with adaptive orientation and local ordering,presented in Section 3.2.The source-code for the assessment of CF , kClist , and CF - Hash are ac-quired from their respective authors. We note that for CF and CF - Hash , weuse the implementation from [21] named
T C - M erge and
T C - Hash respectively,due to their more efficient implementations.
Datasets.
The datasets used in the experiments are listed in Table 2. We used16 large real-world graphs with up to a billion edges. Networks are treated asundirected simple graphs, and are processed appropriately.
Settings.
The tests are run on a 64 bit Linux machine with a Intel(R) Xeon(R)CPU E5-2650 v3 @ 2.30GHz processor, the L1, L2 and L3 cache of 32K, 256K,and 25600K respectively, with 591 GB of available RAM. w eb - ba i du - ba i k eu k - - t pda c t o r f li ck e r u k - - ho s t sx - s t a ck o v e r f l o w lj ou r na l - s o c - o r k u t i ndo c h i na - ll y w ood - s o c - s i na w e i bo w i k i ped i a - li n k - ena r ab i c - k - i t - t w i tt e r- P r o c e ss i ng T i m e AOT KClist CF TC-Hash
Fig. 4.
Performance Analysis .1 Results against the State-of-the-art
Figure 4 reports the relative running times of the algorithms tested. The mea-sured time captures the elapsed time between the point when the graph is loadeduntil the point of successful program termination. For the state-of-the-art meth-ods, the kClist algorithm requires fewer running time than the CF algorithm. Fordatasets containing up to 100 million edges, kClist is observed to significantlyoutperform CF; this gap in running time is less significant for graphs where theedge count is greater than 100 million. There are also instances where CF ismore efficient than kClist, as observed in the social-network soc-sinaweibo .In comparison, our algorithm AOT consistently outperforms thetwo state-of-the-art, which supports the tightened running bound of P { u,w }∈ E min ( deg + ( u ) , deg + ( v )) from its theoretical analysis. We notice thaton a large graph twitter-2010 that has 41 .
65 million vertices, 1 . ,
381 seconds and 4 ,
230 seconds respectively. In contrast, our algorithm listedall triangles in twitter-2010 in 433 seconds and achieved a speedup of 10-times. Itis noticed that hash-based CF (CF-Hash) is consistently outperformed by AOTwith big margins, though two algorithms have the same asymptotic behavior.This is because the high efficiency of look-up operation of the bitmap hash tableas well as the local ordering technique in AOT algorithm. Recall that, with-out the adaptive orientation technique proposed in this paper, hash-based CFcannot take this advantage. This reflects the non-trivial nature of our adaptiveorientation technique. w eb - ba i du - ba i k eu k - - t pda c t o r f li ck e r u k - - ho s t sx - s t a ck o v e r f l o w lj ou r na l - s o c - o r k u t i ndo c h i na - ll y w ood - s o c - s i na w e i bo w i k i ped i a - li n k - ena r ab i c - k - i t - t w i tt e r- P r o c e ss i ng T i m e AOT AOT-randomOrder CF
Fig. 5.
Incremental Improvements
To show the efficiency of our algorithm, we evaluate the benefits for having adap-tive orientation and local ordering in our technique. For this setting, a baselinemethod is one that has neither adaptive orientation or local ordering. We con-sider CF algorithm as a proper baseline since it uses the existing orientationtechnique, but uses neither of the aforementioned techniques. In addition to con-sidering the AOT algorithm with both adaptive orientation and local ordering.We also require an algorithm that uses adaptive orientation without utilizing aocal ordering technique, for this, we consider our AOT algorithm with a randomlocal ordering, denoted later as
AOT - randomOrder .As we can see in Figure 5, the processing time decreases after introducingadaptive orientation and the local ordering strategy. In comparison to the base-line processing time, the adaptive orientation contributes a greater drop in pro-cessing time compared to that from the later adoption of the local-order strategyWhere the difference between AOT - randomOrder and CF is greater than thatbetween AOT and
AOT - randomOrder . This highlights that our adaptive ori-entation technique performs better than the orientation technique in its currentstate. Furthermore, the results also show that using a local order reduces therunning time needed on most graphs; this can be explained by an improvementin the algorithms cache performance. Our algorithm
AOT can be easily made parallel. This is achieved by processingvertices in parallel. As a result, we analyze the parallelism of our algorithmand compare it against the state-of-the-art methods.
T C - M erge (i.e., parallelimplementation of CF proposed in [15]), T C - Hash and kClist all providedparallel implementations of their algorithms. For this parallel experiment, weconsider the two largest datasets It -2004 and T witter -2010. P r o c e ss i ng T i m e Number of ThreadsTC-HashTC-MergekClistAOT (a) It-2004 P r o c e ss i ng T i m e Number of ThreadsTC-HashTC-MergekClistAOT (b) Twitter-2010
Fig. 6.
Evaluating Parallel Performance
As seen in Figure 6, increasing the number of threads decreases the amountof processing time needed to list all triangles, this is expected and true for allfour algorithms tested. In the case of kClist , the drop is less pronounced forboth networks after 4 threads. In the case of
T C - M erge and
T C - Hash , thedrop in processing time is not visible when handling It -2004 past 8 threads. Incontrast, this decrease is visible for our method AOT across both datasets. Allin all,
AOT is consistently the fastest method in this parallel experiments.
Triangle Listing
In-memory algorithms for listing triangles have been exten-sively studied in the literature. The edge-iterator [1] and node-iterator [13] aretwo popular triangle listing computing paradigms, which share the same asymp-totic behavior [20]. A lot of subsequent algorithms are mostly improvementsased on the original two paradigms. While Ortmann was the first to formalizea generalized framework based on undirected graph orientation, past literatureForward and Compact Forward(CF) had previously considered triangle-listingon induced directed graphs with respect to a vertex ordering [20]. In literature,the orientation technique is observed beyond triangle-listing; it is also appliedfor higher-order structure enumeration [9]. In more recent years, the topicsof interest have shifted to parallel/distributed processing (e.g.,[21,16]), efficientI/O external memory methods (e.g.,[7,12], and the asymptotic cost analysis oftriangle listing in random graphs [24].
Triangle Counting
The triangle counting is a related problem to the trianglelisting problem, solving the listing problem solves the counting problem. Thetriangle counting problem is the task to find the total number of triangles ina graph G. Compared to listing algorithms, counting algorithms find ways tocompute the number without relying on the exploration of triangle instances.Many algorithms have been designed to count triangles (e.g., [3,17,14]). Approx-imate methods are useful for settings that handle large-scale graphs, or settingswhere a given approximation is as useful as knowing the exact triangle count(e.g.,[22,23]).
The triangle listing is a fundamental problem in graph analysis with a widerange of applications. This problem has been extensively studied in the litera-ture. Although many efficient main memory algorithms based on the efficientorientation technique have been proposed, in this paper, we pushed the effi-ciency boundary of the triangle listing and developed a new algorithm withbest theoretical time complexity and practical performance. On the theoret-ical side, we showed that our proposed algorithm has the time complexity Θ ( P h u,v i∈ E min { deg + ( u ) , deg + ( v ) } )) where E is the directed edges in the ori-ented graph, which is the best known theoretical time complexity for the prob-lem of in-memory triangle listing so far. On the practical side, our comprehensiveexperiments over 16 real-life large graphs show the superior performance of ourAOT algorithm compared with two state-of-the-art techniques, especially onlarge-scale graphs with billions of edges. Acknowledgement
Lu Qin is is supported by ARC DP160101513. Ying Zhang is supportedby FT170100128 and ARC DP180103096, Wenjie Zhang is supported byARC DP180103096 and ARC DP200101116. Xuemin Lin is supported by2018YFB1003504, ARC DP200101338, NSFC61232006, ARC DP180103096 andDP170101628.
References
1. Batagelj, V., Mrvar, A.: A subquadratic triad census algorithm for large sparsenetworks with small maximum degree. Social Networks (3) (2001)2. Batagelj, V., Zaverˇsnik, M.: Generalized cores. arXiv preprint cs/0202039 (2002). Becchetti, L., Boldi, P., Castillo, C., Gionis, A.: Efficient semi-streaming algorithmsfor local triangle counting in massive graphs. In: Proc. of SIGKDD’08 (2008)4. Becchetti, L., Boldi, P., Castillo, C., Gionis, A.: Efficient algorithms for large-scalelocal triangle counting. TKDD (3) (2010)5. Berry, J.W., Hendrickson, B., LaViolette, R.A., Phillips, C.A.: Tolerating the com-munity detection resolution limit with edge weighting. Physical Review E (5)(2011)6. Chou, B.H., Suzuki, E.: Discovering community-oriented roles of nodes in a socialnetwork. In: Proc. of DaWaK’10 (2010)7. Chu, S., Cheng, J.: Triangle listing in massive networks and its applications. In:Proc. of KDD’11 (2011)8. Chu, S., Cheng, J.: Triangle listing in massive networks. TKDD (4) (2012)9. Danisch, M., Balalau, O., Sozio, M.: Listing k-cliques in sparse real-world graphs.In: Proc. of WWW’18 (2018)10. Giechaskiel, I., Panagopoulos, G., Yoneki, E.: Pdtl: Parallel and distributed trianglelisting for massive graphs. In: Proc. of ICPP’15 (2015)11. Hu, X., Tao, Y., Chung, C.W.: Massive graph triangulation. In: Proc. of SIG-MOD’13 (2013)12. Hu, X., Tao, Y., Chung, C.: I/o-efficient algorithms on triangle listing and counting.ACM Trans. Database Syst. (4) (2014)13. Itai, A., Rodeh, M.: Finding a minimum circuit in a graph. SIAM Journal onComputing (4) (1978)14. Kolda, T.G., Pinar, A., Plantenga, T.D., Seshadhri, C., Task, C.: Counting tri-angles in massive graphs with mapreduce. SIAM J. Scientific Computing (5)(2014)15. Latapy, M.: Main-memory triangle computations for very large (sparse (power-law)) graphs. Theor. Comput. Sci. (1-3) (2008)16. Park, H.M., Myaeng, S.H., Kang, U.: Pte: Enumerating trillion triangles on dis-tributed systems. In: Proc. of SIGKDD’16 (2016)17. Pavan, A., Tangwongsan, K., Tirthapura, S., Wu, K.: Counting and sampling tri-angles from a graph stream. PVLDB (14) (2013)18. Radicchi, F., Castellano, C., Cecconi, F., Loreto, V., Parisi, D.: Defining and iden-tifying communities in networks. PNAS101