This paper was converted on www.awesomepapers.org from LaTeX by an anonymous user.
Want to know more? Visit the Converter page.

Finding Small Complete Subgraphs Efficiently 111 A preliminary version of this paper appeared in the Proceedings of the 34th International Workshop on Combinatorial Algorithms (IWOCA 2023), LNCS 13889, Springer, Cham, Switzerland, 2023, pp. 185–196.

Adrian Dumitrescu Algoresearch L.L.C., Milwaukee, WI, USA. Email [email protected]    Andrzej Lingas Department of Computer Science, Lund University, Sweden. Email [email protected]
Abstract

(I) We revisit the algorithmic problem of finding all triangles in a graph G=(V,E)G=(V,E) with nn vertices and mm edges. According to a result of Chiba and Nishizeki (1985), this task can be achieved by a combinatorial algorithm running in O(mα)=O(m3/2)O(m\alpha)=O(m^{3/2}) time, where α=α(G)\alpha=\alpha(G) is the graph arboricity. We provide a new very simple combinatorial algorithm for finding all triangles in a graph and show that is amenable to the same running time analysis. We derive these worst-case bounds from first principles and with very simple proofs that do not rely on classic results due to Nash-Williams from the 1960s.

(II) We extend our arguments to the problem of finding all small complete subgraphs of a given fixed size. We show that the dependency on mm and α\alpha in the running time O(α2m)O(\alpha^{\ell-2}\cdot m) of the algorithm of Chiba and Nishizeki for listing all copies of KK_{\ell}, where 3\ell\geq 3, is asymptotically tight.

(III) We give improved arboricity-sensitive running times for counting and/or detection of copies of KK_{\ell}, for small 4\ell\geq 4. A key ingredient in our algorithms is, once again, the algorithm of Chiba and Nishizeki. Our new algorithms are faster than all previous algorithms in certain high-range arboricity intervals for every 7\ell\geq 7.

Keywords: triangle, subgraph detection/counting, graph arboricity, rectangular matrix multiplication.

1 Introduction

The problem of deciding whether a given graph G=(V,E)G=(V,E) contains a complete subgraph on kk vertices is among the most natural and easily stated algorithmic graph problems. If the subgraph size kk is part of the input, this is the Clique problem which is NP-complete [17]. For every fixed kk, determining whether a given graph G=(V,E)G=(V,E) contains a complete subgraph on kk vertices can be accomplished by a brute-force algorithm running in O(nk)O(n^{k}) time.

For k=3k=3, deciding whether a graph contains a triangle and finding one if it does, or counting all triangles in a graph, can be done in O(nω)O(n^{\omega}) time by the algorithm of Itai and Rodeh [16], where ω\omega is the exponent of matrix multiplication [1, 7], and ω<2.372\omega<2.372 is the best known bound [10, 36]. The algorithm compares MM and N=M2N=M^{2}, where MM is the graph adjacency matrix; if there is a pair of indexes i,ji,j such that M[i,j]=N[i,j]=1M[i,j]=N[i,j]=1, then there is a triangle based on edge ijij. An equivalent characterization is: GG contains a triangle iff M3M^{3} has a non-zero entry on its main diagonal. See [25, Ch. 10] for a short exposition of this elegant method. Alternatively, this task can be done in O(m2ω/(ω+1))=O(m1.407)O(m^{2\omega/(\omega+1)})=O(m^{1.407}) time by the algorithm of Alon, Yuster, and Zwick [3], which deals with vertices of high and low degree separately. Itai and Rodeh [16] and also Papadimitriou and Yannakakis [30] as well as Chiba and Nishizeki [6] showed that triangles in planar graphs can be found in O(n)O(n) time.

For k=4k=4, deciding whether a graph contains a K4K_{4} and finding one if it does (or counting all K4K_{4}’s in a graph) can be done in O(nω+1)=O(n3.373)O(n^{\omega+1})=O(n^{3.373}) time by the algorithm of Alon, Yuster, and Zwick [3], in O(n3.252)O(n^{3.252}) time by the algorithm of Eisenbrand and Grandoni [12], and in O(m(ω+1)/2)=O(m1.686)O(m^{(\omega+1)/2})=O(m^{1.686}) time by the algorithm of Kloks, Kratsch, and Müller [18].

In contrast to the problem of detecting the existence of subgraphs of a certain kind, the analogous problem of listing all such subgraphs has usually higher complexity, as expected. For example, finding all triangles in a given graph (each triangle appears in the output list) can be accomplished in O(m3/2)O(m^{3/2}) time and with O(n2)O(n^{2}) space by an extended version of the algorithm of Itai and Rodeh [16]. Bar-Yehuda and Even [4] improved the space complexity of the algorithm from O(n2)O(n^{2}) to O(n)O(n) by avoiding the use of the adjacency matrix. Chiba and Nishizeki [6] further refined the time complexity in terms of graph arboricity, which is the minimum number of edge-disjoint forests into which its edges can be partitioned. Their algorithm lists all triangles in a graph in O(mα)O(m\alpha) time, where α\alpha is the arboricity of the graph. They also showed that α=O(m)\alpha=O(\sqrt{m}); consequently, the running time is O(m3/2)O(m^{3/2}).

If GG is planar, α(G)3\alpha(G)\leq 3 (see [15, p. 124]), so the algorithm runs in O(m)=O(n)O(m)=O(n) (i.e., linear) time on planar graphs. Since there are graphs GG with α(G)=Θ(m1/2)\alpha(G)=\Theta(m^{1/2}), this does not improve the worst-case dependence on mm (which, in fact, cannot be improved). For every fixed 3\ell\geq 3, the same authors gave an algorithm for listing all copies of KK_{\ell} in O(α2m)=O(m/2)O(\alpha^{\ell-2}\cdot m)=O(m^{\ell/2}) time.

We distinguish several variants of the general problem of finding triangles in a given undirected graph G=(V,E)G=(V,E): (i) the triangle detection (resp., finding) problem is that of deciding if GG is triangle-free (resp., finding a triangle in GG otherwise); (ii) the triangle counting problem is that of determining the total number of triangles in GG; (iii) the triangle listing problem is that of listing (reporting) all triangles in GG, with each triangle appearing in the output list. Obviously, any algorithm for listing all triangles can be easily transformed into one for triangle detection or into one for listing a specified number of triangles, by stopping after the required number of triangles have been output.

Our results.

We obtain the following results for the problem of finding small complete subgraphs of a given size. Each of our algorithms for deciding whether a graph contains a given complete subgraph (item (iii) below) also finds a suitable witness, if it exists.

  1. (i)

    We provide a new combinatorial algorithm for finding all triangles in a graph running in O(mα)=O(m3/2)O(m\alpha)=O(m^{3/2}) time, where α=α(G)\alpha=\alpha(G) is the graph arboricity (Algorithm Hybrid in Section 2). We derive these worst-case bounds from first principles and with very simple proofs that do not rely on classic results due to Nash-Williams from the 1960s.

  2. (ii)

    For every nn, bn/2b\leq n/2 and a fixed 3\ell\geq 3, there exists a graph GG of order nn with mm edges and α(G)b\alpha(G)\leq b that has Ω(α2m)\Omega(\alpha^{\ell-2}\cdot m) copies of KK_{\ell} (Lemma 3 in Section 3). As such, the dependency on mm and α\alpha, in the running time O(α2m)O(\alpha^{\ell-2}\cdot m) for listing all copies of KK_{\ell}, is asymptotically tight.

  3. (iii)

    We give improved arboricity-sensitive running times for counting and/or detection of copies of KK_{\ell}, for small 4\ell\geq 4 (Section 4). A key ingredient in our algorithms is the algorithm of Chiba and Nishizeki. Our new algorithms beat all previous algorithms in certain high-range arboricity intervals for every 7\ell\geq 7. We also provide up-to-date running times based on rectangular matrix multiplication times.

Preliminaries and notation.

Let G=(V,E)G=(V,E) be an undirected graph. The neighborhood of a vertex vVv\in V is the set N(v)={w:(v,w)E}N(v)=\{w\ :\ (v,w)\in E\} of all adjacent vertices, and its cardinality deg(v)=|N(v)|\deg(v)=|N(v)| is called the degree of vv in GG. A clique in a graph G=(V,E)G=(V,E) is a subset CVC\subset V of vertices, each pair of which is connected by an edge in EE. The Clique problem is to find a clique of maximum size in GG. An independent set of a graph G=(V,E)G=(V,E) is a subset IVI\subset V of vertices such that no two of them are adjacent in GG.

Unless specified otherwise: (i) all algorithms discussed are assumed to be deterministic; (ii) all graphs mentioned are undirected; (iii) all logarithms are in base 22.

It should be noted that the asymptotically fastest algorithms for matrix multiplication have mainly a theoretical importance and are otherwise largely impractical [24, Ch. 10.2.4]. As such, any algorithm that employs fast matrix multiplication (FMM) inherits this undesirable feature. Whereas the notion of “combinatorial” algorithm does not have a formal or precise definition, such an algorithm is usually simpler to implement and practically efficient, see [35]. Combinatorial algorithms are sometimes theoretically less efficient than non-combinatorial ones but practically more efficient since they tend to be simpler to implement.

Graph parameters.

For a graph GG, its arboricity α(G)\alpha(G) is the minimum number of edge-disjoint forests into which GG can be decomposed [6]. For instance, it is known and easy to show that α(Kn)=n/2\alpha(K_{n})=\lceil n/2\rceil. A characterization of arboricity is provided by the following classic result [26, 27, 34]; see also [9, p. 60].

Theorem 1.

(Nash-Williams 1964; Tutte 1961) A multigraph G=(V,E)G=(V,E) can be partitioned into at most kk forests if and only if every set UVU\subseteq V induces at most k(|U|1)k(|U|-1) edges.

The degeneracy d(G)d(G) of an undirected graph GG is the smallest number dd for which there exists an acyclic orientation of GG in which all the out-degrees are at most dd. The degeneracy of a graph is linearly related to its arboricity, i.e., α(G)=Θ(d(G))\alpha(G)=\Theta(d(G)); more precisely α(G)d(G)2α(G)1\alpha(G)\leq d(G)\leq 2\alpha(G)-1; see [3, 13, 23, 39].

It is worth noting that high arboricity is not an indication for the graph having many (or any) triangles. Indeed, the complete bipartite graph Kn/2,n/2K_{\lfloor n/2\rfloor,\lceil n/2\rceil}, or any of its dense subgraphs has arboricity Θ(n)\Theta(n) but no triangles.

1.1 Triangle Finding Algorithms

To place our algorithm in Section 2 in a proper context, we first present a summary of previous work in the area of triangle finding and enumeration.

The algorithms of Itai and Rodeh (1978).

The authors gave three methods for finding triangles. Initially intended for triangle detection, the first algorithm [16] runs in O(m3/2)O(m^{3/2}) time. It can be extended to list all triangles within the same overall time and works as follows:

Itai-Rodeh(G)(G)
Input: an undirected graph G=(V,E)G=(V,E)
1 Find a spanning tree for each connected component of GG
2 List all triangles containing at least one tree edge
3 Delete the tree edges from GG and go to Step 1

The second is a randomized algorithm that checks whether there is an edge contained in a triangle. It runs in O(mn)O(mn) worst-case time and O(n5/3)O(n^{5/3}) expected time. The third algorithm relies on Boolean matrix multiplication and runs in O(nω)O(n^{\omega}) time. (Boolean matrix multiplication can be reduced to standard matrix multiplication; see [24, Ch. 10.2.4] for details.)

The algorithm of Chiba and Nishizeki (1985).

The algorithm uses a vertex-iterator approach for listing all triangles in GG. It relies on the observation that each triangle containing a vertex vv corresponds to an edge joining two neighbors of vv. The graph is represented with doubly-linked adjacency lists and mutual references between the two stubs of an edge ensure that each deletion takes constant time. A more compact version described by Ortmann and Brandes [29] is given below.

Chiba-Nishizeki(G)(G)
Input: an undirected graph G=(V,E)G=(V,E)
1 Sort vertices such that deg(v1)deg(v2)deg(vn)\deg(v_{1})\geq\deg(v_{2})\geq\ldots\deg(v_{n})
2 for u=v1,v2,,vn2u=v_{1},v_{2},\ldots,v_{n-2} do
3      foreach vertex vN(u)v\in N(u) do mark vv
4      foreach vertex vN(u)v\in N(u) do
5           foreach vertex wN(v)w\in N(v) do
6                if ww is marked then output triangle uvwuvw
7               
8                end foreach
9               unmark vv
10                end foreach
11               GGuG\leftarrow G-u
12                end for

The authors [6] showed that their algorithm runs in O(mα)O(m\alpha) time. As a corollary, the number of triangles is O(mα)O(m\alpha) as well. The O(m3/2)O(m^{3/2}) upper bound on the number of triangles in a graph is likely older than these references indicate. In any case, other proofs are worth mentioning [11, 19], including algebraic ones [31]. We derive yet another one in Section 2.

Corollary 1.

([16, 6]) For any graph GG of order nn with mm edges and arboricity α\alpha, GG contains O(mα)=O(m3/2)O(m\alpha)=O(m^{3/2}) triangles.

Ortmann and Brandes [29] gave a survey of other approaches, including edge-iterators. Algorithms in this category iterate over all edges and intersect the neighborhoods of the endpoints of each edge. A straightforward neighborhood merge requires O(deg(u)+deg(v))O(\deg(u)+\deg(v)) time per edge uvuv, but this is not good enough to list all triangles in O(m3/2)O(m^{3/2}) time. Two variants developed by Shanks [32] use O(m)O(m) extra space to represent neighborhoods in hash sets and obtain the intersection in O(min(deg(u),deg(v)))O(\min(\deg(u),\deg(v))) time, which suffices for listing all triangles in O(m3/2)O(m^{3/2}) time.

The algorithm of Alon, Yuster and Zwick (1997).

The authors showed that deciding whether a graph contains a triangle and finding one if it does (or counting all triangles in a graph) can be done in O(m2ω/(ω+1))=O(m1.407)O(m^{2\omega/(\omega+1)})=O(m^{1.407}) time [3]. The idea is to find separately triangles for which at least one vertex has low degree (for an appropriately set threshold) and triangles whose all three vertices have high degree. Triangles of the latter type are handled by applying matrix multiplication to a smaller subgraph.

Recent algorithms.

Björklund et al. [5] obtained output-sensitive algorithms for finding (and listing) all triangles in a graph; their algorithms are tailored for dense and sparse graphs. Several approaches [14, 20] provide asymptotic improvements by taking advantage of the bit-level parallelism offered by the word-RAM model. Although they do not appear to be very practical, these methods asymptotically improve on the O(mα+k)O(m\alpha+k) running time of the earlier algorithms (in particular that in [6]). If the number of triangles is small, Zechner and Lingas [38] showed how to list all triangles in O(nω)O(n^{\omega}) time.

2 A Simple Hybrid Algorithm for Listing All Triangles

In this section we present a new algorithm for listing all triangles. While its general idea is not new, the specific hybrid data structure therein does not appear to have been previously considered. Using both an adjacency list representation and an adjacency matrix representation of the graph yields a very time-efficient neighborhood merge (intersection) procedure. Let V={1,2,,n}V=\{1,2,\ldots,n\} and let MM be the adjacency matrix of GG. A triangle ijkijk with i<j<ki<j<k is reported when edge ijij is processed, and so each triangle is reported exactly once. For each edge ijij, the algorithm scans the adjacency list of the endpoint of lower degree (among ii and jj) and for each neighbor it checks for the needed entry in the adjacency matrix MM corresponding to the third triangle edge.

Hybrid(G)(G)
Input: an undirected graph G=(V,E)G=(V,E)
1 foreach edge ijEij\in E, (i<ji<jdo
2      if deg(i)deg(j)\deg(i)\leq\deg(j) then xix\leftarrow i, yjy\leftarrow j
3      else xjx\leftarrow j, yiy\leftarrow i
4      foreach kADJ(x)k\in ADJ(x) do
5           if j<kj<k and M(y,k)=1M(y,k)=1 then report triangle ijkijk
6          
7           end foreach
8          
9           end foreach

We subsequently show that the algorithm runs in time O(mα)O(m\alpha). Whereas the space used is quadratic, the hybrid algorithm appears to win by running time and simplicity. In particular, no additional data structures nor hashing are used, no sorting (by degree or otherwise) and no doubly linked lists are needed, etc. Similar algorithms that use hashing in order to run in linear space are 66 to 88 times slower than their “unoptimized” counterparts on most graphs with about 5×1065\times 10^{6} vertices in the study in [32, 33]. “The two algorithms edge-iterator-hashed and forward-hashed, which use hashed data structures for every node, perform badly” on such graphs, the authors write [33, p. 8].

2.1 The Analysis

Define the following function ff on the edges of GG. For uv=eEuv=e\in E, let

f(e)=min(deg(u),deg(v)) and F(G)=eEf(e).f(e)=\min(\deg(u),\deg(v))\text{ and }F(G)=\sum_{e\in E}f(e). (1)

There are at most f(e)f(e) triangles based on edge e=ije=ij and overall at most F(G)F(G) triangles in GG. The runtime of the algorithm is proportional to this quantity; the space used is quadratic. A short and elegant decomposition argument by Chiba and Nishizeki [6, Lemma 2] shows that

F(G)2mα,F(G)\leq 2m\alpha, (2)

thus our algorithm runs in time O(mα)O(m\alpha). The same analysis applies to the algorithm of Chiba and Nishizeki [6]. By Theorem 1, the above authors deduced that α(G)(2m+n)1/2/2\alpha(G)\leq\lceil(2m+n)^{1/2}/2\rceil, which implies that α(G)=O(m1/2)\alpha(G)=O(m^{1/2}) for a connected graph GG. As such, both algorithms run in O(m3/2)O(m^{3/2}) time on any graph.

Lemma 1 below shows how to bypass the Nash-Williams arboricity bound (Theorem 1) and deduce the O(m3/2)O(m^{3/2}) upper bound for listing all triangles in a graph from first principles.

Lemma 1.

Let GG be a graph on nn vertices with mm edges. Then

F(G)4m3/2.F(G)\leq 4m^{3/2}.
Proof.

(folklore) There are two types of edges uvuv:

  1. 1.

    min(deg(u),deg(v))2m\min(\deg(u),\deg(v))\leq 2\sqrt{m}

  2. 2.

    min(deg(u),deg(v))>2m\min(\deg(u),\deg(v))>2\sqrt{m}

There are at most mm edges of type 1 and each contributes at most 2m2\sqrt{m} to F(G)F(G), so the total contribution from edges of this type is at most 2m3/22m^{3/2}.

Each edge of type 2 connects two nodes of degree >2m>2\sqrt{m}, and there are at most 2m/(2m)=m2m/(2\sqrt{m})=\sqrt{m} such nodes. The degree of each of them thus contributes to F(G)F(G) at most m\sqrt{m} times and the sum of all degrees of such nodes is at most 2m2m. It follows that the total contribution from edges of type 2 is at most 2m3/22m^{3/2}.

Overall, we have F(G)4m3/2F(G)\leq 4m^{3/2}. ∎

Remarks.

Lemma 1 immediately gives an upper bound of 4m3/24m^{3/2} on the number of triangles in a graph. It is in fact known [31] that this number is at most (21/2/3)m3/2(2^{1/2}/3)\,m^{3/2} (and this bound is sharp). More generally, for every fixed 3\ell\geq 3, the number of copies of KK_{\ell} is O(α2m)=O(m/2)O(\alpha^{\ell-2}\cdot m)=O(m^{\ell/2}); see [6, Thm. 3].

3 Constructions

Lemma 2.

For every n3n\geq 3 and 3m(n2)3\leq m\leq{n\choose 2}, there exists a graph GG of order nn with mm edges that contains Θ(m3/2)\Theta(m^{3/2}) triangles.

Proof.

Let 3xn3\leq x\leq n be the unique integer such that (x2)m<(x+12){x\choose 2}\leq m<{x+1\choose 2}. Note that x=Θ(m)x=\Theta(\sqrt{m}). Let G=(V,E)G=(V,E) where V=V1V2V=V_{1}\cup V_{2}, |V1|=x|V_{1}|=x, and |V2|=nx|V_{2}|=n-x. Set V1V_{1} induces a complete subgraph and set V2V_{2} induces an independent set in GG. Add m(x2)m-{x\choose 2} edges to GG arbitrarily so that GG has mm edges. Let TT be the set of triangles in GG. We have

|T|(x3)=Ω(m3/2).|T|\geq{x\choose 3}=\Omega(m^{3/2}).

By Lemma 1, GG contains Θ(m3/2)\Theta(m^{3/2}) triangles, as required. ∎

Lemma 3.

Let 3\ell\geq 3 be a fixed integer. For every nn and bn/2b\leq n/2, there exists a graph GG of order nn with αb\alpha\leq b that has Ω(α2m)\Omega(\alpha^{\ell-2}\cdot m) copies of KK_{\ell}, where mm is the number of edges in GG and α\alpha is the arboricity of GG.

Proof.

We may assume that bb is even and b/2|nb/2\ |\ n. Suppose that n=(2k+1)b/2n=(2k+1)b/2. Let G=(V,E)G=(V,E), where V=V1V2V=V_{1}\cup V_{2}, and |V1|=kb|V_{1}|=kb, |V2|=b/2|V_{2}|=b/2. Set V1V_{1} consists of kk complete subgraphs of order bb whereas V2V_{2} is an independent set of size b/2b/2 in GG. All edges in V1×V2V_{1}\times V_{2} are present in GG. See Fig. 1.

Refer to caption
Figure 1: Illustration of the graph GG for k=3k=3, b=4b=4.

Let KK be the set of complete subgraphs of order \ell. We have

m\displaystyle m =|E|=k(b2)+kb22=Θ(kb2),\displaystyle=|E|=k{b\choose 2}+k\frac{b^{2}}{2}=\Theta(k\,b^{2}),
|K|\displaystyle|K| =k(b)+k(b1)b2=Ω(kb)=Ω(b2m),\displaystyle=k{b\choose\ell}+k{b\choose\ell-1}\frac{b}{2}=\Omega(k\,b^{\ell})=\Omega(b^{\ell-2}\,m),

Note that the arboricity of GG is bounded from above by bb. Indeed, αb2+b2=b\alpha\leq\frac{b}{2}+\frac{b}{2}=b, since α(Kb)=b/2\alpha(K_{b})=b/2 and the edges in V1×V2V_{1}\times V_{2} can be partitioned into b/2b/2 stars centered at the vertices in V2V_{2}. ∎

4 Finding Small Complete Subgraphs Efficiently

In this section we address the problem of detecting the presence of KK_{\ell} for a fixed 4\ell\geq 4. We combine and refine several approaches existent in the literature of the last 4040 years to obtain faster algorithms in general and for a large class of graphs with high arboricity. In particular, we will use the algorithm of Chiba and Nishizeki [6] for listing all copies of KK_{\ell} in O(α2m)O(\alpha^{\ell-2}\cdot m) time. Our algorithms are formulated for the purpose of counting but they can be easily adapted for the purpose of detection.

The basic idea is as follows: since listing is generally slower than counting or detection, one can use a hybrid—decomposition based—approach that combines listing in Part A with counting or detection in Part B.

Recall that ω<2.372\omega<2.372 is the exponent of matrix multiplication [1, 7, 36], namely the infimum of numbers τ\tau such that two n×nn\times n real matrices can be multiplied in O(nτ)O(n^{\tau}) time (operations). Similarly, let ω(p,q,r)\omega(p,q,r) stand for the infimum of numbers τ\tau such that an np×nqn^{p}\times n^{q} matrix can be multiplied by an nq×nrn^{q}\times n^{r} matrix in O(nτ)O(n^{\tau}) time (operations). For simplicity and as customary (see, e.g., [3, 28]), we write that two n×nn\times n matrices can be multiplied in O(nω)O(n^{\omega}) time, since this does not affect our results; and similarly when multiplying rectangular matrices.

The extension method.

The algorithm solves the detection (or counting) problem for a complete subgraph KK_{\ell}. Let T(n,m,)T(n,m,\ell) denote the running time of the algorithm for a graph with nn vertices and mm edges. Write =1+2\ell=\ell_{1}+\ell_{2}, for a suitable choice 1,22\ell_{1},\ell_{2}\geq 2. At the beginning, we run the algorithm of Chiba and Nishizeki to form a list of subgraphs isomorphic to K1K_{\ell_{1}}. Then, for each subgraph G1=(V1,E1)G_{1}=(V_{1},E_{1}) on the list: (i) we construct the subgraph G2G_{2} of GG induced by vertices in VV1V\setminus V_{1} that are adjacent to all vertices in V1V_{1}; and (ii) we count the subgraphs isomorphic to K2K_{\ell_{2}} in G2G_{2} (or find one such subgraph); this is a (possibly recursive) call of the same procedure on a smaller instance. In other words, we count the number of extensions of the subgraph isomorphic to K1K_{\ell_{1}} to a KK_{\ell}. Another formulation of this method can be found in [21].

There are O(α12m)O(\alpha^{\ell_{1}-2}\cdot m) copies of K1K_{\ell_{1}} and they can be found in O(α12m)O(\alpha^{\ell_{1}-2}\cdot m) time. For each fixed copy of K1K_{\ell_{1}}, the time spent in G2G_{2} is at most T(n,m,2)T(n,m,\ell_{2}), and so the overall time satisfies the recurrence

T(n,m,)=O(α12mT(n,m,2)).T(n,m,\ell)=O(\alpha^{\ell_{1}-2}\cdot m\cdot T(n,m,\ell_{2})).

Each copy of KK_{\ell} is generated exactly (1){\ell\choose\ell_{1}} times and so the total count needs to be divided by this number in the end.

The triangle method and its refinement.

The algorithm solves the detection (or counting) problem for a complete subgraph KK_{\ell}. Nešetřil and Poljak [28] showed an efficient reduction of detecting and counting copies of any complete subgraph to the aforementioned method of Itai and Rodeh [16] for triangle detection and counting. To start with, consider the detection of complete subgraphs of size =3j\ell=3j. For a given graph GG with nn vertices, construct an auxiliary graph HH with O(nj)O(n^{j}) vertices, where each vertex of HH is a complete subgraph of order jj in GG. Two vertices V1,V2V_{1},V_{2} in HH are connected by an edge if V1V2=V_{1}\cap V_{2}=\emptyset and all edges in V1×V2V_{1}\times V_{2} are present in GG; equivalently, V1V2V_{1}\cup V_{2} is a complete subgraph on |V1|+|V2||V_{1}|+|V_{2}| vertices. The detection (or counting) of triangles in HH yields an algorithm for the detection (or counting) of KK_{\ell}’s in GG, running in O(njω)O(n^{j\omega}) time. For detecting complete subgraphs of size =3j+i\ell=3j+i, where i{1,2}i\in\{1,2\}, the algorithm can be adapted so that it runs in O(njω+i)O(n^{j\omega+i}) time.

The triangle method can be extended to larger subgraphs, i.e., if =kj+i\ell=kj+i, for some k4k\geq 4, and i{0,1,,k1}i\in\{0,1,\ldots,k-1\}, the algorithm tries to detect a KkK_{k} in HH; see also [21]. We give a few applications at the end of this section.

Here we focus on k=3k=3. For convenience, define the following integer functions

β()\displaystyle\beta(\ell) =ω(/3,(1)/3,/3),\displaystyle=\omega(\lfloor\ell/3\rfloor,\lceil(\ell-1)/3\rceil,\lceil\ell/3\rceil), (3)
γ()\displaystyle\gamma(\ell) =/3ω+(mod3).\displaystyle=\lfloor\ell/3\rfloor\omega+\ell\pmod{3}. (4)

With this notation, the algorithm runs in O(nγ())O(n^{\gamma(\ell)}) time. Two decades later, Eisenbrand and Grandoni [12] refined the triangle method by using fast algorithms for rectangular matrix multiplication instead of those for square matrix multiplication. It partitions the graph intro three parts roughly of the same size: 1=/3\ell_{1}=\lfloor\ell/3\rfloor, 2=(1)/3\ell_{2}=\lceil(\ell-1)/3\rceil, 3=/3\ell_{3}=\lceil\ell/3\rceil. The refined algorithm runs in time O(nβ())O(n^{\beta(\ell)}) time. If the rectangular matrix multiplication is carried out via the straightforward partition into square blocks and fast square matrix multiplication (see, e.g., [8, Exercise 4.2-6]), one recovers the time complexity of the algorithm of Nešetřil and Poljak; that is, β()γ()\beta(\ell)\leq\gamma(\ell), see [12] for details. Eisenbrand and Grandoni [12] showed that the above inequality is strict for a certain range: if (mod3)=1\ell\pmod{3}=1 and 16\ell\leq 16, or (mod3)=2\ell\pmod{3}=2. In summary, their algorithm is faster than that of Nešetřil and Poljak in these cases. We subsequently refer to their method as the refined triangle method. Another extension of the triangle method is considered in [21].

A problem of Kloks, Kratsch, and Müller.

The authors asked [18] whether there is an O(mω/6)O(m^{\ell\omega/6}) algorithm for deciding whether a graph contains a KK_{\ell}, if \ell is a multiple of 33. Eisenbrand and Grandoni showed that this is true for every multiple of 33 at least 66. Indeed, by their Theorem 2 [12], this task can be accomplished in time O(mβ()/2)O(m^{\beta(\ell)/2}) for every 6\ell\geq 6, with β()\beta(\ell) as in (3). If =3j\ell=3j, where j2j\geq 2, then

β()=ω(/3,(1)/3,/3)=ω(j,j,j)=jω(1,1,1)=jω.\beta(\ell)=\omega(\lfloor\ell/3\rfloor,\lceil(\ell-1)/3\rceil,\lceil\ell/3\rceil)=\omega(j,j,j)=j\cdot\omega(1,1,1)=j\omega.

It follows that the running time is O(mβ()/2)=O(mjω/2)=O(mω/6)O(m^{\beta(\ell)/2})=O(m^{j\omega/2})=O(m^{\ell\omega/6}). The proof of the theorem is rather involved. Here we provide an alternative simpler argument that also yields an arboricity-sensitive bound, item (i) below.

General case derivations.

We first consider the general cases: (i) =3j\ell=3j, j3j\geq 3; (ii) =3j+1\ell=3j+1, j2j\geq 2; and (iii) =3j+2\ell=3j+2, j2j\geq 2. It will be evident that our algorithms provide improved bounds for every 7\ell\geq 7. For a given j2j\geq 2, we shall consider the interval

Ij=(ω1j(3ω)+2(ω1),12).I_{j}=\left(\frac{\omega-1}{j(3-\omega)+2(\omega-1)},\,\frac{1}{2}\right).
  1. (i)

    =3j\ell=3j, j3j\geq 3. We use the triangle method with a refined calculation. The vertices of the auxiliary graph HH are subgraphs isomorphic to KjK_{j}. By the result of Chiba and Nishizeki [6], HH has O(αj2m)O(\alpha^{j-2}\cdot m) vertices. The algorithm counts triangles in HH in time proportional to

    (αj2m)ω=α(j2)ωmω.\left(\alpha^{j-2}\cdot m\right)^{\omega}=\alpha^{(j-2)\omega}\cdot m^{\omega}.

    For =9,12,15\ell=9,12,15 (the entries in Table 1), these runtimes are O(αωmω)O(\alpha^{\omega}\cdot m^{\omega}), O(α2ωmω)O(\alpha^{2\omega}\cdot m^{\omega}), and O(α3ωmω)O(\alpha^{3\omega}\cdot m^{\omega}), respectively.

    Since α=O(m1/2)\alpha=O(m^{1/2}), the above expression is bounded from above as follows:

    α(j2)ωmω=O((m(j2)/2m)ω)=O(mjω/2)=O(mω/6).\alpha^{(j-2)\omega}\cdot m^{\omega}=O\left(\left(m^{(j-2)/2}\cdot m\right)^{\omega}\right)=O\left(m^{j\omega/2}\right)=O\left(m^{\ell\omega/6}\right).

    Next, we show that for a certain high-range of α\alpha, the new bound α(j2)ωmω\alpha^{(j-2)\omega}\cdot m^{\omega} beats all previous bounds, namely mjω/2m^{j\omega/2} and α3j2m\alpha^{3j-2}\cdot m, for j3j\geq 3 (or =9,12,15,\ell=9,12,15,\ldots). Let α=Θ(mx)\alpha=\Theta(m^{x}), where xIjx\in I_{j}. We first verify that

    α(j2)ωmωmjω/2, or ((j2)x+1)ω<jω/2,\displaystyle\alpha^{(j-2)\omega}\cdot m^{\omega}\ll m^{j\omega/2},\text{ or }((j-2)x+1)\omega<j\omega/2,

    which holds for x<1/2x<1/2. Secondly, we verify that

    α(j2)ωmω\displaystyle\alpha^{(j-2)\omega}\cdot m^{\omega} α3j2m, or ((j2)x+1)ω<(3j2)x+1, or\displaystyle\ll\alpha^{3j-2}\cdot m,\text{ or }((j-2)x+1)\omega<(3j-2)x+1,\text{ or }
    x\displaystyle x >ω1j(3ω)+2(ω1),\displaystyle>\frac{\omega-1}{j(3-\omega)+2(\omega-1)},

    which holds by the choice of the interval IjI_{j}. In particular, for =9\ell=9, this occurs for x(ω17ω,12)(0.297,0.5)x\in\left(\frac{\omega-1}{7-\omega},\frac{1}{2}\right)\supset(0.297,0.5); for =12\ell=12, this occurs for x(ω1102ω,12)(0.262,0.5)x\in\left(\frac{\omega-1}{10-2\omega},\frac{1}{2}\right)\supset(0.262,0.5); for =15\ell=15, this occurs for x(ω1133ω,12)(0.234,0.5)x\in\left(\frac{\omega-1}{13-3\omega},\frac{1}{2}\right)\supset(0.234,0.5). Moreover, if ω=2\omega=2, as conjectured, these intervals extend to (1/5,1/2)(1/5,1/2), (1/6,1/2)(1/6,1/2), and (1/7,1/2)(1/7,1/2), respectively.

  2. (ii)

    =3j+1\ell=3j+1, j2j\geq 2. The refined triangle method [12] with 1=j\ell_{1}=j, 2=j+1\ell_{2}=j+1, 3=j\ell_{3}=j, leads to rectangular matrix multiplication [O(αj2m)×O(αj1m)][O(αj1m)×O(αj2m)][O(\alpha^{j-2}m)\times O(\alpha^{j-1}m)]\cdot[O(\alpha^{j-1}m)\times O(\alpha^{j-2}m)]. Its complexity is at most O(α)O(\alpha) times that of the square matrix multiplication with dimension αj2m\alpha^{j-2}m, the latter of which is O(α(j2)ωmω)O(\alpha^{(j-2)\omega}\cdot m^{\omega}). It follows that

    T(n,m,)=O(αα(j2)ωmω)=O(α(j2)ω+1mω).T(n,m,\ell)=O(\alpha\cdot\alpha^{(j-2)\omega}\cdot m^{\omega})=O(\alpha^{(j-2)\omega+1}\cdot m^{\omega}).

    For =7,10,13,16\ell=7,10,13,16 (the entries in Table 1), these runtimes are O(αmω)O(\alpha\cdot m^{\omega}), O(αω+1mω)O(\alpha^{\omega+1}\cdot m^{\omega}), O(α2ω+1mω)O(\alpha^{2\omega+1}\cdot m^{\omega}), and O(α3ω+1mω)O(\alpha^{3\omega+1}\cdot m^{\omega}), respectively.

    As before, we show that for a certain high-range of α\alpha, the new bound α(j2)ω+1mω\alpha^{(j-2)\omega+1}\cdot m^{\omega} beats all previous bounds, namely m(jω+1)/2m^{(j\omega+1)/2} and α3j1m\alpha^{3j-1}\cdot m, for j2j\geq 2 (or =7,10,13,\ell=7,10,13,\ldots). Let α=Θ(mx)\alpha=\Theta(m^{x}), where xIjx\in I_{j}. We first verify that

    α(j2)ω+1mωm(jω+1)/2, or ((j2)x+1)ω<jω/2,\displaystyle\alpha^{(j-2)\omega+1}\cdot m^{\omega}\ll m^{(j\omega+1)/2},\text{ or }((j-2)x+1)\omega<j\omega/2,

    which holds for x<1/2x<1/2. Secondly, we verify that

    α(j2)ω+1mω\displaystyle\alpha^{(j-2)\omega+1}\cdot m^{\omega} α3j1m, or ((j2)x+1)ω+x<(3j1)x+1, or\displaystyle\ll\alpha^{3j-1}\cdot m,\text{ or }((j-2)x+1)\omega+x<(3j-1)x+1,\text{ or }
    x\displaystyle x >ω1j(3ω)+2(ω1),\displaystyle>\frac{\omega-1}{j(3-\omega)+2(\omega-1)},

    which holds by the choice of the interval IjI_{j}. In particular, for =7\ell=7, this occurs for x(ω14,12)(0.344,0.5)x\in\left(\frac{\omega-1}{4},\frac{1}{2}\right)\supset(0.344,0.5); for =10\ell=10, this occurs for x(ω17ω,12)(0.297,0.5)x\in\left(\frac{\omega-1}{7-\omega},\frac{1}{2}\right)\supset(0.297,0.5); for =13\ell=13, this occurs for x(ω1102ω,12)(0.262,0.5)x\in\left(\frac{\omega-1}{10-2\omega},\frac{1}{2}\right)\supset(0.262,0.5). Moreover, if ω=2\omega=2, as conjectured, these intervals extend to (1/4,1/2)(1/4,1/2), (1/5,1/2)(1/5,1/2), and (1/6,1/2)(1/6,1/2), respectively.

  3. (iii)

    =3j+2\ell=3j+2, j2j\geq 2. The refined triangle method [12] with 1=j+1\ell_{1}=j+1, 2=j\ell_{2}=j, 3=j+1\ell_{3}=j+1, leads to rectangular matrix multiplication [O(αj1m)×O(αj2m)][O(αj2m)×O(αj1m)][O(\alpha^{j-1}m)\times O(\alpha^{j-2}m)]\cdot[O(\alpha^{j-2}m)\times O(\alpha^{j-1}m)]. Its complexity is at most O(α2)O(\alpha^{2}) times that of the square matrix multiplication with dimension αj2m\alpha^{j-2}m, the latter of which is O(α(j2)ωmω)O(\alpha^{(j-2)\omega}\cdot m^{\omega}). It follows that

    T(n,m,)=O(α2α(j2)ωmω)=O(α(j2)ω+2mω).T(n,m,\ell)=O(\alpha^{2}\cdot\alpha^{(j-2)\omega}\cdot m^{\omega})=O(\alpha^{(j-2)\omega+2}\cdot m^{\omega}).

    For =8,11,14\ell=8,11,14 (the entries in Table 1), these runtimes are O(α2mω)O(\alpha^{2}\cdot m^{\omega}), O(αω+2mω)O(\alpha^{\omega+2}\cdot m^{\omega}), and O(α2ω+2mω)O(\alpha^{2\omega+2}\cdot m^{\omega}), respectively.

    As before, we show that for a certain high-range of α\alpha, this bound beats all previous bounds, namely m(jω+2)/2m^{(j\omega+2)/2} and α3jm\alpha^{3j}\cdot m, for j2j\geq 2 (or =8,11,14,\ell=8,11,14,\ldots). Let α=Θ(mx)\alpha=\Theta(m^{x}), where xIjx\in I_{j}. We first verify that

    α(j2)ω+2mωm(jω+2)/2, or ((j2)x+1)ω<jω/2,\displaystyle\alpha^{(j-2)\omega+2}\cdot m^{\omega}\ll m^{(j\omega+2)/2},\text{ or }((j-2)x+1)\omega<j\omega/2,

    which holds for x<1/2x<1/2. Secondly, we verify that

    α(j2)ω+2mω\displaystyle\alpha^{(j-2)\omega+2}\cdot m^{\omega} α3jm, or ((j2)x+1)ω+2x<3jx+1, or\displaystyle\ll\alpha^{3j}\cdot m,\text{ or }((j-2)x+1)\omega+2x<3jx+1,\text{ or }
    x\displaystyle x >ω1j(3ω)+2(ω1),\displaystyle>\frac{\omega-1}{j(3-\omega)+2(\omega-1)},

    which holds by the choice of the interval IjI_{j}. In particular, for =8\ell=8, this occurs for x(ω14,12)(0.344,0.5)x\in\left(\frac{\omega-1}{4},\frac{1}{2}\right)\supset(0.344,0.5); for =11\ell=11, this occurs for x(ω17ω,12)(0.297,0.5)x\in\left(\frac{\omega-1}{7-\omega},\frac{1}{2}\right)\supset(0.297,0.5); for =14\ell=14, this occurs for x(ω1102ω,12)(0.262,0.5)x\in\left(\frac{\omega-1}{10-2\omega},\frac{1}{2}\right)\supset(0.262,0.5). Moreover, if ω=2\omega=2, as conjectured, these intervals extend to (1/4,1/2)(1/4,1/2), (1/5,1/2)(1/5,1/2), and (1/6,1/2)(1/6,1/2), respectively.

    The bound for =8\ell=8, O(α2mω)O(\alpha^{2}\cdot m^{\omega}), is superseded by the bound O(αω+1mω+12)O\left(\alpha^{\omega+1}m^{\frac{\omega+1}{2}}\right), using another (so-called “the edge count”) method.

Running time derivations for small \ell.

The previous general case derivations together with the instantiations below yield the running times listed in Table 1.

\ell Previous best This paper
33 O(αm)O(\alpha\cdot m) [6], O(n2.372)O(n^{2.372}) [16], O(m1.407)O(m^{1.407}) [3]
44 O(α2m)O(\alpha^{2}\cdot m) [6], O(n3.334)O(n^{3.334}) [12], O(m1.686)O(m^{1.686}) [18] O(n3.251)O(n^{3.251})
55 O(α3m)O(\alpha^{3}\cdot m) [6], O(n4.220)O(n^{4.220}), O(m2.147)O(m^{2.147}) [12] O(n4.086)O(n^{4.086})
66 O(α4m)O(\alpha^{4}\cdot m) [6], O(n4.751)O(n^{4.751}) [12], O(m2.372)O(m^{2.372}) [12]
77 O(α5m)O(\alpha^{5}\cdot m) [6], O(n5.714)O(n^{5.714}) [12], O(m2.857)O(m^{2.857}) [12] O(m2.795)O(m^{2.795}), O(αm2.372)O(\alpha\cdot m^{2.372})
88 O(α6m)O(\alpha^{6}\cdot m) [6], O(m3.372)O(m^{3.372}) [12, 18] O(m3.251)O(m^{3.251}), O(α3.372m1.686)O(\alpha^{3.372}\cdot m^{1.686})
99 O(α7m)O(\alpha^{7}\cdot m) [6], O(m3.558)O(m^{3.558}) [12, 18] O(α2.372m2.372)O(\alpha^{2.372}\cdot m^{2.372})
1010 O(α8m)O(\alpha^{8}\cdot m) [6], O(m4.058)O(m^{4.058}) [12, 18] O(m4)O(m^{4}), O(α3.372m2.372)O(\alpha^{3.372}\cdot m^{2.372})
1111 O(α9m)O(\alpha^{9}\cdot m) [6], O(m4.558)O(m^{4.558}) [12, 18] O(m4.372)O(m^{4.372}), O(α4.372m2.372)O(\alpha^{4.372}\cdot m^{2.372})
1212 O(α10m)O(\alpha^{10}\cdot m) [6], O(m4.744)O(m^{4.744}) [12, 18] O(α4.744m2.372)O(\alpha^{4.744}\cdot m^{2.372}), O(α6.744m1.686)O(\alpha^{6.744}\cdot m^{1.686})
1313 O(α11m)O(\alpha^{11}\cdot m) [6], O(m5.160)O(m^{5.160}) [12, 18] O(α5.744m2.372)O(\alpha^{5.744}\cdot m^{2.372})
1414 O(α11m)O(\alpha^{11}\cdot m) [6], O(m5.553)O(m^{5.553}) [12, 18] O(α6.744m2.372)O(\alpha^{6.744}\cdot m^{2.372})
1515 O(α13m)O(\alpha^{13}\cdot m) [6], O(m5.930)O(m^{5.930}) [12, 18] O(α7.116m2.372)O(\alpha^{7.116}\cdot m^{2.372})
1616 O(α14m)O(\alpha^{14}\cdot m) [6], O(m6.338)O(m^{6.338}) [12, 18] O(α8.115m2.372)O(\alpha^{8.115}\cdot m^{2.372}), O(α10.115m1.686)O(\alpha^{10.115}\cdot m^{1.686})
Table 1: Running time comparison for finding/counting complete subgraphs. The column on new results includes bounds in terms of mm, based on up-to-date matrix multiplication times, and new arboricity-sensitive bounds in terms of mm and α\alpha; the entries for =4,5\ell=4,5 in terms of nn are also derived in [21].
  1. (i)

    =3\ell=3. The algorithms of Itai and Rodeh [16], and Alon, Yuster, and Zwick [3] for triangle counting/detection run in O(nω)O(n^{\omega}) and O(m2ω/(ω+1))=O(m1.407)O(m^{2\omega/(\omega+1)})=O(m^{1.407}) time, respectively.

  2. (ii)

    =4\ell=4. The refined triangle method [12] with 1=1\ell_{1}=1, 2=1\ell_{2}=1, 3=2\ell_{3}=2, leads to rectangular matrix multiplication [n×n][n×m][n\times n]\cdot[n\times m] or [n×n][n×n2][n\times n]\cdot[n\times n^{2}] in the worst case. Since ω(1,1,2)=ω(1,2,1)3.251\omega(1,1,2)=\omega(1,2,1)\leq 3.251, it follows that T(n,m,4)=O(n3.251)T(n,m,4)=O(n^{3.251}). (See also [22, Table 3]; this entry has been slightly improved in [36].) In particular, this gives a positive answer to a question of Alon, Yuster, and Zwick [3], who asked for an improvement of their O(nω+1)=O(n3.372)O(n^{\omega+1})=O(n^{3.372}) upper bound for K4K_{4} detection. In terms of mm, by [12, Table 1], T(n,m,4)=O(m1.682)T(n,m,4)=O(m^{1.682}), but this entry appears unjustified.

  3. (iii)

    =5\ell=5. The refined triangle method [12] with 1=2\ell_{1}=2, 2=1\ell_{2}=1, 3=2\ell_{3}=2, leads to rectangular matrix multiplication [m×n][n×m][m\times n]\cdot[n\times m] or [n2×n][n×n2][n^{2}\times n]\cdot[n\times n^{2}] in the worst case. According to [36, Table 1], ω(2,1,2)=2ω(1,0.5,1)22.043=4.086\omega(2,1,2)=2\omega(1,0.5,1)\leq 2\cdot 2.043=4.086, hence T(n,m,5)=O(n4.086)T(n,m,5)=O(n^{4.086}).

    On a side note, the extension method [12] with 1=3,2=2\ell_{1}=3,\ell_{2}=2, yields T(n,m,5)=O(αmm)=O(αm2)T(n,m,5)=O(\alpha m\cdot m)=O(\alpha\cdot m^{2}). Observe however, that O(α3m)=O(αm2)O(\alpha^{3}\cdot m)=O(\alpha\cdot m^{2}), so the above upper bound does not beat that of the algorithm of Chiba and Nishizeki.

  4. (iv)

    =6\ell=6. The general case derivation yields a runtime of O(mω)O(m^{\omega}).

  5. (v)

    =7\ell=7. The refined triangle method [12] with 1=2\ell_{1}=2, 2=3\ell_{2}=3, 3=2\ell_{3}=2, leads to rectangular matrix multiplication [m×αm][αm×m][m\times\alpha m]\cdot[\alpha m\times m] or [m×m3/2][m3/2×m][m\times m^{3/2}]\cdot[m^{3/2}\times m] in the worst case. Since ω(1,1.5,1)2.795\omega(1,1.5,1)\leq 2.795, it follows that T(n,m,7)=O(m2.795)T(n,m,7)=O(m^{2.795}).

  6. (vi)

    =8\ell=8. The refined triangle method [12] with 1=2=3=4=2\ell_{1}=\ell_{2}=\ell_{3}=\ell_{4}=2, leads to counting K4K_{4}’s in a graph with mm vertices. Since ω(1,1,2)3.251\omega(1,1,2)\leq 3.251, we have T(n,m,8)=O(m3.251)T(n,m,8)=O(m^{3.251}).

  7. (vii)

    =9\ell=9. The general case derivation yields a runtime of O(αωmω)O(\alpha^{\omega}\cdot m^{\omega}).

  8. (viii)

    =10\ell=10. By [12, Thm. 2], it takes O(mβ(10)/2)O(m^{\beta(10)/2}), where β(10)=ω(3,3,4)\beta(10)=\omega(3,3,4). Since according to [22, Table 3], ω(1,4/3,1)8/3\omega(1,4/3,1)\leq 8/3, we have ω(3,3,4)=3ω(1,4/3,1)3×8/3=8\omega(3,3,4)=3\omega(1,4/3,1)\leq 3\times 8/3=8, thus T(n,m,10)=O(mβ(10)/2)=O(m4)T(n,m,10)=O(m^{\beta(10)/2})=O(m^{4}). Example: for graphs with α=O(m3/8)\alpha=O(m^{3/8}), K10K_{10}’s can be counted/detected in O(m3.636)O(m^{3.636}) time, by the last entry in the right column, whereas the other entries give O(m4)O(m^{4}) time or more.

  9. (ix)

    =11\ell=11. By [12, Thm. 2], it takes O(mβ(11)/2)O(m^{\beta(11)/2}), where β(11)=ω(3,4,4)\beta(11)=\omega(3,4,4). By [36, Table 1], we have ω(1,0.75,1)2.1863\omega(1,0.75,1)\leq 2.1863, which yields ω(3,4,4)=4ω(1,0.75,1)4×2.18638.746\omega(3,4,4)=4\omega(1,0.75,1)\leq 4\times 2.1863\leq 8.746. Consequently, T(n,m,11)=O(mβ(11)/2)=O(m4.373)T(n,m,11)=O(m^{\beta(11)/2})=O(m^{4.373}).

  10. (x)

    =12\ell=12. The general case derivation yields a runtime of O(α2ωmω)O(\alpha^{2\omega}\cdot m^{\omega}). Example: for graphs with α=O(m0.4)\alpha=O(m^{0.4}), K12K_{12}’s can be counted/detected in O(α2ωmω)=O(m1.8ω)=O(m4.269)O(\alpha^{2\omega}\cdot m^{\omega})=O(m^{1.8\omega})=O(m^{4.269}) time, whereas the other entries give O(m4.744)O(m^{4.744}) time or more.

  11. (xi)

    =13\ell=13. By [12, Thm. 2], it takes O(mβ(13)/2)O(m^{\beta(13)/2}), where β(13)=ω(4,4,5)\beta(13)=\omega(4,4,5). By [22, Table 3], we have ω(1,5/4,1)2.58\omega(1,5/4,1)\leq 2.58, which yields ω(4,4,5)=4ω(1,5/4,1)4×2.58=10.32\omega(4,4,5)=4\omega(1,5/4,1)\leq 4\times 2.58=10.32. Consequently, T(n,m,13)=O(mβ(13)/2)=O(m5.16)T(n,m,13)=O(m^{\beta(13)/2})=O(m^{5.16}).

  12. (xii)

    =14\ell=14. By [12, Thm. 2], it takes O(mβ(14)/2)O(m^{\beta(14)/2}), where β(14)=ω(5,4,5)\beta(14)=\omega(5,4,5). By [36, Table 1], we have ω(1,0.8,1)2.221\omega(1,0.8,1)\leq 2.221, which implies ω(4,4,5)=5ω(1,0.8,1)5×2.221=11.105\omega(4,4,5)=5\omega(1,0.8,1)\leq 5\times 2.221=11.105, thus T(n,m,14)=O(mβ(14)/2)=O(m5.553)T(n,m,14)=O(m^{\beta(14)/2})=O(m^{5.553}).

  13. (xiii)

    =15\ell=15. The general case derivation yields a runtime of O(α3ωmω)O(\alpha^{3\omega}\cdot m^{\omega}).

  14. (xiv)

    =16\ell=16. By [12, Thm. 2], it takes O(mβ(16)/2)O(m^{\beta(16)/2}), where β(16)=ω(5,5,6)\beta(16)=\omega(5,5,6). By [36, Table 1], we have ω(1,6/5,1)2.5351\omega(1,6/5,1)\leq 2.5351, which implies ω(5,5,6)=5ω(1,6/5,1)5×2.535112.676\omega(5,5,6)=5\omega(1,6/5,1)\leq 5\times 2.5351\leq 12.676, thus T(n,m,16)=O(mβ(16)/2)=O(m6.338)T(n,m,16)=O(m^{\beta(16)/2})=O(m^{6.338}).

The edge count method.

This method combines the extended triangle method with runtime upper bounds of algorithms for the “sparse” case of the detection problem. We illustrate the method for =4j\ell=4j, with j2j\geq 2. Detecting the presence of a KK_{\ell} amounts to detecting the presence of a K4K_{4} in a graph HH with O(αj2m)O(\alpha^{j-2}m) vertices corresponding to the KjK_{j}’s GG, where two vertices in HH are adjacent if they span 2j2j vertices of GG that form a K2jK_{2j}. There are k=O(α2j2m)k=O(\alpha^{2j-2}m) K2jK_{2j}’s in GG, and so by the result of [18], a K4K_{4} in HH can be detected in O(k(ω+1)/2)=O(α(j1)(ω+1)mω+12)O(k^{(\omega+1)/2})=O\left(\alpha^{(j-1)(\omega+1)}\cdot m^{\frac{\omega+1}{2}}\right) time.

Consider three examples: j=2,3,4j=2,3,4. For j=2j=2, the new bound O(αω+1mω+12)O\left(\alpha^{\omega+1}\cdot m^{\frac{\omega+1}{2}}\right) is better than the earlier bound:. Indeed, it is easily seen that αω+1mω+12=O(α2mω)\alpha^{\omega+1}\cdot m^{\frac{\omega+1}{2}}=O(\alpha^{2}m^{\omega}) over the entire range of α\alpha. For j=3,4j=3,4, the new bounds are better than the earlier bounds for αmω14\alpha\ll m^{\frac{\omega-1}{4}}. Indeed, α2(ω+1)mω+12α2ωmω\alpha^{2(\omega+1)}\cdot m^{\frac{\omega+1}{2}}\ll\alpha^{2\omega}\cdot m^{\omega} and α3(ω+1)mω+12α3ω+1mω\alpha^{3(\omega+1)}\cdot m^{\frac{\omega+1}{2}}\ll\alpha^{3\omega+1}\cdot m^{\omega} for αmω14\alpha\ll m^{\frac{\omega-1}{4}}.

These examples are not exhaustive. For instance, one can also apply the edge count method with =3j\ell=3j and use the O(m2ω/(ω+1))=O(m1.407)O(m^{2\omega/(\omega+1)})=O(m^{1.407}) time algorithm for triangle detection [3].

5 Conclusion

We conclude by restating a few open problems in the area of finding small complete subgraphs. Recall that triangle detection can be done in O(nω)O(n^{\omega}) time by the algorithm of Itai and Rodeh.

  1. 1.

    Can K3K_{3} detection be done in O(n2)O(n^{2}) time?

  2. 2.

    Is K3K_{3} detection as difficult as Boolean matrix multiplication? Initially posed by Alon, Yuster, and Zwick [2], it also appears as in Woeginger’s survey on exact algorithms [37] (as Question 4.3 (c)). V. V. Williams and R. Williams showed that if any of the two problems admits a truly subcubic combinatorial algorithm then also the other one does [35].

  3. 3.

    Can K10K_{10} detection be accomplished in O(n7.5)O(n^{7.5}) time? (Question 4.3 (b) in Woeginger’s survey on exact algorithms [37]) We add our own version: Can K100K_{100} detection be accomplished in O(n75)O(n^{75}) time?

Acknowledgment.

The authors thank an anonymous reviewer for communicating the short folklore proof of Lemma 1.

References

  • [1] J. Alman and V. V. Williams, A refined laser method and faster matrix multiplication, Proc. 2021 ACM-SIAM Symposium on Discrete Algorithms SODA 2021, Virtual Conference, SIAM, pp. 522–539.
  • [2] N. Alon, R. Yuster, and U. Zwick, Color-coding, Journal of the ACM 42(4) (1995), 844–856.
  • [3] N. Alon, R. Yuster, and U. Zwick, Finding and counting given length cycles, Algorithmica 17(3) (1997), 209–223.
  • [4] R. Bar-Yehuda and S. Even, On approximating a vertex cover for planar graphs, Proc. 14th ACM Symposium on Theory of Computing (STOC), 1982, pp. 303–309.
  • [5] A. Björklund, R. Pagh, V. V. Williams, and U. Zwick, Listing triangles, Proc. 41st International Colloquium on Automata, Languages, and Programming (ICALP), Copenhagen, 2014, Springer, vol. 8572 of LNCS, pp. 223–234.
  • [6] N. Chiba and T. Nishizeki, Arboricity and subgraph listing algorithms, SIAM Journal on Computing 14(1) (1985), 210–223.
  • [7] D. Coppersmith and S. Winograd, Matrix multiplication via arithmetic progressions, Journal of Symbolic Computation 9(3) (1990), 251–280.
  • [8] T. H. Cormen, C. E. Leiserson, R. L. Rivest, and C. Stein, Introduction to Algorithms, 3rd edition, MIT Press, Cambridge, 2009.
  • [9] R. Diestel, Graph Theory, Springer, New York, 1997.
  • [10] R. Duan, H. Wu, and R. Zhou, Faster matrix multiplication via asymmetric hashing, Proc. 64th Annual Symposium on Foundations of Computer Science (FOCS 2023), IEEE, pp. 2129–2138.
  • [11] T. Eden, A. Levi, D. Ron, and C. Seshadhri, Approximately counting triangles in sublinear time, SIAM J. Comput. 46(5) (2017), 1603–1646.
  • [12] F. Eisenbrand and F. Grandoni, On the complexity of fixed parameter clique and dominating set, Theoretical Computer Science 326(1-3) (2004), 57–67.
  • [13] D. Eppstein, Arboricity and bipartite subgraph listing algorithms, Information Processing Letters 51(4) (1994), 207–211.
  • [14] D. Eppstein, M. T. Goodrich, M. Mitzenmacher, and M. R. Torres, 2-3 cuckoo filters for faster triangle listing and set intersection, Proc. 36th SIGMOD-SIGACT-SIGAI Sympos. on Principles of Database Systems, PODS, 2017, pp. 247–260.
  • [15] F. Harary, Graph Theory, revised, Addison–Wesley, Reading, Massachusetts, 1972.
  • [16] A. Itai and M. Rodeh, Finding a minimum circuit in a graph, SIAM Journal on Computing 7(4) (1978), 413–423.
  • [17] M. R. Garey and D. S. Johnson, Computers and Intractability: A Guide to the Theory of NP-Completeness, W.H. Freeman and Co., New York, 1979.
  • [18] T. Kloks, D. Kratsch, and H. Müller, Finding and counting small induced subgraphs efficiently, Information Processing Letters 74(3-4) (2000), 115–121.
  • [19] M. Kolountzakis, G. Miller, R. Peng, and C. Tsourakakis, Efficient triangle counting in large graphs via degree-based vertex partitioning, Internet Mathematics 8(1-2) (2012), 161–185.
  • [20] T. Kopelowitz, S. Pettie, and E. Porat, Dynamic set intersection, Proc. 14th International Symposium on Algorithms and Data Structures, WADS 2015, Victoria, BC, Canada, 2015, Springer, vol. 9214 of LNCS, pp. 470–481.
  • [21] M. Kowaluk and A. Lingas, A multi-dimensional matrix product—a natural tool for parameterized graph algorithms, Algorithms 15(12) (2022), 448.
  • [22] F. Le Gall and F. Urrutia, Improved rectangular matrix multiplication using powers of the Coppersmith-Winograd tensor, Proc. 29th Annual ACM-SIAM Sympos. on Discrete Algorithms, SODA 2018, New Orleans, SIAM, 2018, pp. 1029–1046.
  • [23] D. R. Lick and A. T. White, kk-degenerate graphs, Canadian Journal of Mathematics 22(5) (1970), 1082–1096.
  • [24] U. Manber, Introduction to Algorithms - A Creative Approach, Addison-Wesley, Reading, Massachusetts, 1989.
  • [25] J. Matoušek, Thirty-three Miniatures, American Mathematical Society, 2010.
  • [26] C. St. J. A. Nash-Williams, Edge-disjoint spanning trees of finite graphs, Journal of the London Mathematical Society 36 (1961), 445–450.
  • [27] C. St. J. A. Nash-Williams, Decomposition of finite graphs into forests, Journal of the London Mathematical Society 1(1) (1964), 12–12.
  • [28] J. Nešetřil and S. Poljak, On the complexity of the subgraph problem, Commentationes Mathematicae Universitatis Carolinae 26(2) (1985), 415–419.
  • [29] M. Ortmann and U. Brandes, Triangle listing algorithms: back from the diversion, Proc. 16th Workshop on Algorithm Engineering and Experiments, ALENEX 2014, Portland, Oregon, 2014, pp. 1–8.
  • [30] C. H. Papadimitriou and M. Yannakakis, The clique problem for planar graphs, Information Processing Letters 13(4/5) (1981), 131–133.
  • [31] I. Rivin, Counting cycles and finite dimensional Lp{}^{\mbox{\emph{p}}} norms, Advances in Applied Mathematics 29(4) (2002), 647–662.
  • [32] T. Schank, Algorithmic Aspects of Triangle-Based Networks Analysis, PhD thesis, Universität Fridericiana zu Karlsruhe (TH), 2007.
  • [33] T. Schank and D. Wagner, Finding, counting and listing all triangles in large graphs, an experimental study, 35 pages. A short version in Proc. 4th International Workshop on Experimental and Efficient Algorithms, (WEA), Santorini Island, Greece, Springer, vol. 3503 of LNCS, 2005, pp. 606–609.
  • [34] W. Tutte, On the problem of decomposing a graph into nn connected factors, Journal of the London Mathematical Society 36 (1961), 221–230.
  • [35] V. V. Williams and R. R. Williams, Subcubic equivalences between path, matrix, and triangle problems, Journal of the ACM 65(5) (2018), 1–38.
  • [36] V. V. Williams, Y. Xu, Z. Xu, and R. Zhou, New bounds for matrix multiplication: from alpha to omega, Proc. of the 2024 Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), SIAM, pp. 3792–3835. https://epubs.siam.org/doi/pdf/10.1137/1.9781611977912.134
  • [37] G. J. Woeginger, Open problems around exact algorithms, Discret. Appl. Math. 156(3) (2008), 397–405.
  • [38] N. Zechner and A. Lingas, Efficient algorithms for subgraph listing, Algorithms 7(2) (2014), 243–252.
  • [39] X. Zhou and T. Nishizeki, Edge-coloring and ff-coloring for various classes of graphs, Journal of Graph Algorithms and Applications 3(1) (1999), 1–18.