1 Introduction

In his weblog of February 2009 [17], Richard J. Lipton quotes Alan J. Perlis, the first Turing Award winner:

For every polynomial-time algorithm you have, there is an exponential algorithm that I would rather run.”

Richard J. Lipton illustrates this quote beautifully: “His point is simple: if your algorithm runs in n 4 time, then an algorithm that runs in n2n/10 time (alternatively denoted as n1.07178n time) is faster if for example n=100.” Note that this observation even holds for all n≤236.

Woeginger made the same observation for \(\mathcal{NP}\)-hard problems instead of polynomial time solvable problems in his well-known survey on exact exponential-time algorithms [24]. Woeginger considers the fact that algorithms for \(\mathcal{NP}\)-hard problems with exponential running times may actually lead to practical algorithms: he compares the running times of \(\mathcal{O}(n^{4})\) with \(\mathcal{O}(1.01^{n})\).

Even so, we are not aware of any results on natural \(\mathcal{NP}\)-hard problems with exponential-time algorithms with running times anywhere near \(\mathcal{O} (1.01^{n})\) without involving huge polynomial factors (either visible, or hidden in the notation, or hidden in the decimal rounding of the exponent in the big-\(\mathcal{O}\)). ‘Very fast’ exponential-time algorithms exist for problems such as Independent Set restricted to graphs in which 99 % of the vertices have degree at most two. However, we do not consider this to be a natural problem because one can reduce an instance of this artificial problem in polynomial time to an equivalent instance of Independent Set in which only 1 % of the vertices remain (this can be done by vertex folding, e.g., see [1, 5]). Then, the trivial brute-force \(\mathcal{O}(n2^{n})\) algorithm for Independent Set gives an algorithm for this artificial problem running in \(\mathcal{O}(n2^{n/100}) = \mathcal{O}(1.0070^{n})\) time. We note that for the problem studied in this paper, no polynomial-time transformation from the problem on graphs of maximum degree four to the problem on general graphs that greatly reduces the instance size is known (and most likely no such transformation is possible).

This paper, we will present such a very fast exponential-time algorithm for the Partition Into Triangles problem restricted to graphs of maximum degree four. In the main body of the paper, we will given an algorithm running in \(\mathcal{O}(1.02445^{n})\) or \(\mathcal{O}(2^{n/28.69})\) time. This result is further improved to \(\mathcal{O}(1.02220^{n})\) or \(\mathcal{O} (2^{n/31.58})\) time by a further case analysis in the Appendix. These algorithms could solve reasonable size instance as their running times do not include any large factors hidden in the \(\mathcal{O}\)-notation. Both algorithms use an interesting and powerful relation between Partition Into Triangles on graphs of maximum degree four and the Exact 3-Satisfiability problem. We will use this relation not only to give fast exponential-time algorithms, but also to prove that, assuming the Exponential-Time Hypothesis [11, 12], no subexponential-time algorithms for this problem exist. We note that we find it interesting that the same reduction is used for both the hardness result and the faster algorithms.

This paper is organised as follows. We first introduce the Partition Into Triangles and Exact 3-Satisfiability problems and survey known results in Sect. 2. Then, we give a linear-time algorithm for Partition Into Triangles on graphs of maximum degree three in Sect. 3. Thereafter, we focus on the relation between Partition Into Triangles on graphs of maximum degree four to and Exact 3-Satisfiability in Sect. 4. We use this relation to prove our hardness results in Sect. 5 and to give a simple \(\mathcal{O}(1.02445^{n})\)-time algorithm for Partition Into Triangles in Sect. 6. In the Appendix, one can find the slightly faster \(\mathcal{O} (1.02220^{n})\)-time algorithm.

2 Definitions and Notation

Let G=(V,E) be a simple n-vertex graph. The degree of a vertex vV is its number of neighbours in G: d(v)=|{uV|(u,v)∈E}|. A r-regular graph is a graph in which all vertices have degree r; a cubic graph is a 3-regular graph. The (closed) neighbourhood of a vertex N[v] is the set of vertices at distance at most one from v: N[v]={v}∪{uV|(u,v)∈E}. In this paper, we will use the term local neighbourhood of a vertex v referring to the graph induced by N[v], i.e., the graph H=(N[v],E∩(N[vN[v])) where N[v] is taken in G.

A triangle in a graph is a set of three vertices that are pairwise joined by an edge. The Partition Into Triangles problem is a classical \(\mathcal{NP}\)-complete problem [10] that is defined as follows.

Partition Into Triangles

Input:

A graph G=(V,E).

Question:

Can V be partitioned into 3-element sets S 1,S 2,…,S |V|/3 such that each S i forms a triangle in G?

A partitioning of the vertices of G into 3-element vertex set S 1,S 2,…,S |V|/3 that each form a triangle is also called a triangle partition of G.

On general graphs, Partition Into Triangles can be solved using inclusion/exclusion [4] in \(\mathcal{O}(2^{n} n^{\mathcal{O}(1)})\) time and polynomial space. If we allow the use of exponential space, then this can be improved using a recent result by Koivisto [14] who has given a general covering algorithm that can solve the problem in \(\mathcal{O} (1.7693^{n})\) time and space. Also, Björklund [2] has given a general randomised partitioning algorithm that can be used to solve the problem in \(\mathcal{O} (1.496^{n})\) time and polynomial space while having a probability of failure that is exponentially small in n. On bounded-degree graphs, we do not know of any results besides the hardness result of Kann: he proved that the optimisation variant (find a packing consisting of a maximum number of triangles in G) is Max-\(\mathcal{SNP}\)-complete on graphs of maximum degree at least six [13].

The second problem that we consider in this paper is Exact 3-Satisfiability. A literal is a variable x or its negation ¬x; a clause is a multiset of literals. Let f(x) denotes the number of occurrences (frequency) of the variable x, and let f +(x) and f (x) denote the number of positive or negative occurrences of x, respectively (f(x)=f +(x)+f (x)).

Exact 3-Satisfiability is a variant of 3-Satisfiability where a clause is satisfied if and only if exactly one literal in the clause is set to True.

Exact 3-Satisfiability

Input:

A set of clauses C with each clause of size at most three using a set of variables X.

Question:

Does there exist a truth assignment of the variables X such that each clause in C contains exactly one true literal?

The problem Exact Satisfiability is defined similarly by omitting the requirement on the input that clauses must have size at most three.

For both the Exact Satisfiability and the Exact 3-Satisfiability problem there exists a long series of papers giving fast exponential-time algorithms. The first non-trivial algorithm for Exact Satisfiability is due to Schroeppel and Shamir and runs in \(\mathcal{O}(2^{n/2} n^{\mathcal{O}(1)})\) time and \(\mathcal{O}(2^{n/4} n^{\mathcal{O}(1)})\) space [22]. This was already improved in 1981 by Monien et al. to \(\mathcal{O} (1.1844^{n})\) [19]. However, many authors seem to have missed this paper as they published algorithms with slightly worse upper bounds on the running time [7, 8]. The currently fastest algorithm for this problem is due to Byskov et al. and runs in \(\mathcal{O}(1.1749^{n})\) time. When the number of clauses m is used as the complexity parameter, there exists an unpublished algorithm by Skjernaa using \(\mathcal{O}(2^{m} \, m^{\mathcal{O}(1)})\) time and space, and an \(\mathcal{O}(m! m^{\mathcal{O}(1)})\)-time and polynomial-space algorithm by Madsen [18]. These results were improved by Björklund and Husfeldt who gave an \(\mathcal{O}(2^{m} m^{\mathcal{O}(1)})\)-time and polynomial-space algorithm [3].

The first improvement for Exact 3-Satisfiability is an \(\mathcal{O} (1.1545^{n})\)-time algorithm due to Drori and Peleg [8]. This was later improved by Porschen et al. [20], by Kulikov [15], and Byskov et al. [6]. The currently fastest algorithm is due to Wahlström and runs in \(\mathcal{O} (1.0984^{n})\) time and polynomial space [23].

3 A Linear-Time Algorithm on Graphs of Maximum Degree Three

We begin by considering Partition Into Triangles on graphs of maximum degree three. We will prove that this problem is polynomial time solvable on this class of graphs by giving a linear-time algorithm: Algorithm 1.

Lemma 1

Let G=(V,E) be an instance of Partition Into Triangles restricted to graphs of maximum degree d containing a vertex v of degree at most two. In constant time, we can either decide that G is a No-instance, or transform G into an equivalent smaller instance.

Proof

If v has degree at most one, then this vertex cannot be in any triangle and the instance is a No-instance. Otherwise, let u, w be the neighbours of v. As G is of constant maximum degree, we can test in constant time whether (u,w)∈E. If (u,w)∈E, then {u,v,w} is the unique triangle containing v, and we remove this triangle from G to obtain a smaller equivalent instance. If \((u,w) \not\in E\), then v is not part of any triangle, and we again have a No-instance. □

Theorem 2

Algorithm  1 solves Partition Into Triangles on graphs of maximum degree three in linear time.

Proof

For correctness, we note that the number of vertices must be a multiple of three in order to partition G into triangles. Consider the tree cases in the if-statement in the main loop of the algorithm. Correctness of the first case follows from Lemma 1. For the other two cases, we observe that G is now a cubic graph and thus any local neighbourhood of v must equal one of the four cases in Fig. 1. In Case 1, no triangle containing v exists, and, in Cases 3 and 4, the fact that G is cubic would mean that removing any triangle leads to vertices of degree at most 1 which can no longer be in a triangle. Hence, these are all No-instances. In Case 2, v can only be part of one triangle, which Algorithm 1 determines.

Fig. 1
figure 1

Possible edges within the neighbourhood of a vertex in a cubic graph

Algorithm 1
figure 2

A linear-time algorithm for graphs of maximum degree three

Each iteration of the main loop requires constant time, since inspecting a neighbourhood in a graph of maximum degree three can be done in constant time. In each iteration, Algorithm 1 either terminates, or removes three vertices from G. Hence, there are at most a linear number of iterations and Algorithm 1 runs in linear time. □

4 The Relation Between Partition Into Triangles on Graphs of Maximum Degree Four and Exact 3-Satisfiability

When we restrict the Partition Into Triangles problem to graphs of maximum degree four, an interesting relation with Exact 3-Satisfiability can be observed. This relation will be the topic of this section.

We will first give three lemmas used to either decide that an instance of Partition Into Triangles on graphs of maximum degree four is a No-instance, or that it can be reduced to an equivalent smaller instance. These lemmas will apply to any instance unless all vertices in the instance have a local neighbourhood that is identical to one of two possible options. If we cannot reduce an instance in this way, pairs of vertices with one of these local neighbourhoods can be interpreted as a clause of size three in which exactly one variable must be set to True. The variables are then represented by connected series of vertices that each have the other remaining local neighbourhood. These variable can be set to True or False depending on in which of the two possible ways the corresponding connected series of vertices will be partitioned into triangles. In this way, remaining instances can be interpreted as an Exact 3-Satisfiability instance.

Lemma 3

Let G be an instance of Partition Into Triangles of maximum degree four with a given vertex v of degree at most three. In constant time, we can either decide that G is a No-instance, or obtain an equivalent smaller instance that is 4-regular.

Proof

We can assume that v has degree three: otherwise we apply Lemma 1.

Similar to in the proof of Theorem 2, the local neighbourhood of v corresponds to one of the four cases in Fig. 1. If this neighbourhood corresponds to Case 1, then all edges incident to v are not part of any triangle. If this neighbourhood corresponds to Case 2, then the edge between v and the bottom vertex is not part of any triangle. In these two cases, we remove these edges and apply Lemma 1 to v, which now has degree at most two. If this neighbourhood corresponds to Case 4, then, since G is of maximum degree four, selecting any triangle in the solution results in the creation of a vertex of degree at most one: we can conclude that we have a No-instance. The same holds for Case 3 unless the vertices a and b (see Fig. 2) are of degree four.

Fig. 2
figure 3

Reducing an instance with a degree three vertex by merging its neighbours

In this last case, we reduce the graph as in Fig. 2. Either vertex a or vertex b must be in a triangle with u and v. If we take the triangle {a,u,v} in a solution, then b must be in a triangle with its other two neighbours; the same goes if we switch the roles of a and b. We distinguish three subcases depending on the number of common neighbours of a and b.

Case 1. Let a and b have no other common neighbours than u and v. The reader can work out that an edge between a neighbour of a and a neighbour of b outside the shown part of the graph cannot be in a triangle in any solution: we remove such edges if any exist. Next, we merge the vertices a and b to a single vertex and remove both u and v. Now, the new vertex is part of only two different triangles, and both possibilities corresponds to taking one of the two possible triangles containing v in the original graph. Also, no extra triangles are introduced as we have removed the edge between the neighbours of the merged vertices. We conclude that the new smaller instance is equivalent.

Case 2. Let a and b have exactly three common neighbours, and let w be the third common neighbour (the common neighbour of a and b that is not u or v). We must pick a triangle with u, v and either a or b. Consequently, the two edges incident to a and not incident to u or v can be removed if they are not on a common triangle together. If we do so, we obtain a vertex of degree two and can apply Lemma 1. The same holds for the two edges incident to b and not incident to u or v. Hence, we can assume that both a and b lie on a triangle with their third common neighbour w. Moreover, depending on which vertex from a and b we pick in a triangle with u and v, the other must be in a triangle with w. Now, we remove u and v and merge a and b to a single vertex and remove double edges. In the new instance, the edge between the merged vertex and w can be in two triangles and the choice corresponds directly to either taking the triangle u, v, a and the triangle with b and w, or taking the triangle u, v, b and the triangle with a and w.

Case 3. Let a and b have four common neighbours, called u, v, w and x. Again, the two pairs of edges incident to a and b not incident to u and v must be pairwise in triangles or we can remove them and apply Lemma 1. In the remaining case, each of these pairs of edges forms a triangle with the edge between w and x. Now, we must either pick the triangles u, v, a and b, w, x or we must pick u, v, b, and a, w, x. Both options involve the same vertices, hence we can remove these to obtain an equivalent smaller instance. □

As a result, we can reduce any instance of maximum degree four that is not 4-regular. In a 4-regular graph, a vertex v can have one of eleven possible local neighbourhoods, all shown in Fig. 3. We will now show that we can reduce any instance having a vertex whose local neighbourhood does not correspond to one of two specific local neighbourhoods: Cases 2b and 3a from Fig. 3.

Fig. 3
figure 4

Possible edges within the local neighbourhood of a degree four vertex. The numbering corresponds to the number of edges between the neighbours of v

Lemma 4

Let G be a 4-regular instance of Partition Into Triangles containing a given vertex v whose local neighbourhood is different from Cases 2b, 3a and 3b in Fig3. In constant time, we can either decide that G is a No-instance, or we can transform G into an equivalent smaller instance.

Proof

Consider the possible local neighbourhoods of v shown in Fig. 3.

If the local neighbourhood of v equals Case 0, then we clearly have a No-instance. If the local neighbourhood of v equals Case 1, 2a, or 3c, then v is incident to an edge that is not part of any triangle in G because there exists an edge incident to v from which both endpoints do not have a common neighbour. For these cases, we remove the edge and apply Lemma 3 to v. If this local neighbourhood equals Case 5 or 6, then we have a No -instances since picking any triangle containing v results in a vertex of degree at most one.

Next, we consider the remaining two Cases: 4a, and 4b.

Case 4a: Consider the edge from the top left vertex to the bottom right vertex. This edge is part of two triangles, one with the centre vertex v and one with the top right vertex. If we would take any of these two triangles in the solution, a vertex of degree at most one remains. Hence, this edge cannot be part of a triangle in the solution. We remove it and then apply Lemma 3.

Case 4b: Consider one of the four edges in N[v] not incident to v, say the edge between the top two vertices. This edge is part of one or two triangles, one with v, and one with a possible third vertex outside of N[v]. Assume that we take the triangle with this edge and v in a solution, then the remaining two vertices will get degree two and thus they can be only in a triangle together and with a common neighbour. Hence, for each of the four edges in N[v], we remove it if the endpoints of both the edge and the opposite edge (edge between the other two vertices in N[v]∖{v}) have no common neighbour except for v.

Note that there is no instance in which all four edges remain since each of the four corner vertices has only one neighbour outside of N[v]. Hence there can be at most two such common neighbours, and if there are two then they must involve the endpoints of opposite edges. We can now apply Lemma 3. □

Having reduced the number of possible local neighbourhoods of a vertex in an instance to three, we now remove one more such possibility.

Lemma 5

Let G be a 4-regular instance of Partition Into Triangles in which the local neighbourhood of each vertex equals Case 2b, 3a or 3b in Fig3. Then, vertices whose local neighbourhood equal Case 3b form separate connected components in G. In linear time, we can either decide that G is a No-instance, or remove these components to obtain an equivalent smaller instance.

Proof

Let v be a vertex whose local neighbourhood corresponds to Case 3b of Fig. 3. Let u be the top left vertex in this picture and consider the local neighbourhood of u. This neighbourhood cannot equal Case 2b of Fig. 3 as it contains one vertex adjacent to two other vertices in the neighbourhood. The neighbourhood can also not equal Case 3a, since v is of degree four and thus cannot have an extra edge to the neighbour of u outside N[v]. We conclude that the local neighbourhood of u must equal that of Case 3b in Fig. 3. Thus, the top two vertices have a common neighbour outside N[v].

We can repeat this argument and apply it to u to conclude that the top right vertex in the picture w also has the same local neighbourhood. This shows that w and the new vertex created in the previous step must have another common neighbour. In this way, we conclude that every vertex in the connected component containing v has this local neighbourhood. An example of such a connected component can be found in Fig. 4.

Fig. 4
figure 5

A connected component with all local neighbourhoods equal to case 3b of Fig. 3

It is not hard to see that such a connected component can be partitioned into triangles if and only if its number of vertices is a multiple of three. Therefore, we can decide that we have a No-instance if this is not the case, and otherwise we can remove it in linear time to obtain an equivalent smaller instance. □

Let a reduced instance of Partition Into Triangles on maximum degree four graphs be an instance to which Lemmas 3, 4 and 5 do not apply, i.e., an instance in which each local neighbourhood corresponds to Case 2b or 3a in Fig. 3.

Let v be a vertex in a reduced instance whose neighbourhood equals Case 3a. Note that v has one neighbour with the same neighbourhood and it has three neighbours whose neighbourhoods are equal to Case 2b. We refer to a pair of two vertices which have the neighbourhood of Case 3a as a fan. And, we refer to adjacent series of vertices with local neighbourhood equals Case 2b as a cloud of triangles. See Fig. 5.

Fig. 5
figure 6

A fan and a cloud, with the two ways in which the cloud can be partitioned into triangles

Observe how these reduced instances can be partitioned into triangles. In a fan, we must select a triangle containing the middle two vertices and exactly one of the three vertices on the boundary. In a cloud, each triangle is either selected or all its neighbouring (cloud or fan) triangles are selected. Hence, adjacent triangles will alternate between being selected and not being selected in a triangle partition of a cloud; see Fig. 5. If such a series of adjacent triangles forms a cycle consisting of an odd number of these triangles, then the instance is a No-instance since an odd length series cannot alternate between being selected and not being selected. If a cloud does not have such an odd cycle of adjacent triangles, then it has two groups of boundary vertices connecting it to fans: in any solution all fan triangles connected to one group will be selected and all fan triangles connected to the other group will not be selected (see also Fig. 5). The only exception to this is the single vertex cloud that directly connects two fans; here the single vertex is in both groups of endpoints.

Now, the relation between Partition Into Triangles on graphs of maximum degree four and Exact 3-Satisfiability emerges. Namely, we can interpret a reduced instance of Partition Into Triangles on graphs of maximum degree four as an Exact 3-Satisfiability instance in the following way. We interpret a fan as a clause containing three literals whose corresponding variables are represented by the clouds adjacent to this fan. Exactly one fan triangle must be selected and this choice determines exactly which triangles in the adjacent clouds will be selected. In this way, we interpret a cloud as a variable that can be set to True or False. Both truth assignments correspond to one of the two possible ways to partition the cloud into triangles. If we fix one of the two possible ways to partition a cloud into triangles and let the corresponding truth value of the corresponding variable by the value True, then we can define the positive and negative literals of this variable. Namely, if this partitioning of the cloud into triangles forces that a triangle from a fan is selected, then the literal corresponding to this occurrence of the variable in the clause is a positive literal. Otherwise, this occurrence of the variable in the clause is a negative literal.

Notice that if we had fixed the other possible ways to partition a cloud into triangles, then this would result in the same instance of Exact 3-Satisfiability that we would get from the above procedure only with the sign of all literals of this variable flipped. It is not hard to see that this Exact 3-Satisfiability interpretation of a reduced instance is satisfiable if and only if the partition into triangles instance has a solution.

An Exact 3-Satisfiability instance obtained in this way can have multiple identical clauses. We will now prove that if we count copies of identical clauses separately, then an instance that is obtained in this way satisfies Property 6, which we define below.

Recall that f(x) denotes the number of occurrences (frequency) of the variable x, and that f +(x) and f (x) denote the number of positive or negative occurrences of x, respectively.

Property 6

For any variable x in the formula, the number of positive f +(x) and negative f (x) literals differ by a multiple of three.

Proposition 7

An Exact 3-Satisfiability instance obtained in the above way from an instance of Partition Into Triangles satisfies Property 6.

Proof

Let x be any variable in the Exact 3-Satisfiability instance. Consider the cloud that represents x, and let t + and t be the number of triangles selected in this cloud when x is set to True or False, respectively. A cloud has a fixed number of vertices and for each corresponding truth assignment each vertex is either selected in a triangle or part of a corresponding literal, thus: 3t ++f +(x)=3t +f (x). Hence, f +(x)≡f (x)(mod3). □

The following lemma shows how we can model Exact 3-Satisfiability instances by reduced instances of Partition Into Triangles on graphs of maximum degree four.

Lemma 8

Any variable x in a formula satisfying Property 6 can be represented by a cloud. Such a cloud consists of 2f(x)−3 vertices.

Proof

Without loss of generality, let f +(x)>0, and define F(x)=(f +(x),f (x)). Notice that the single vertex cloud corresponds to F(x)=(1,1), a single triangle corresponds to F(x)=(3,0), two adjacent triangles corresponds to F(x)=(2,2), and a chain of four triangles corresponds to F(x)=(3,3).

These small clouds can be extended to larger clouds that correspond to any combination F(x)=(f +(x),f (x)) with f +(x)≡f (x)(mod3) by repeatedly increasing f +(x) or f (x) by three in the following way. Take three triangles that are adjacent in the sense that two triangles are connected to the third triangle through having one common vertex. Now, identify the third vertex of the middle triangle with a vertex v that could be connected to a fan in the cloud that we are enlarging. This vertex can now no longer be connected to a fan, but four new such vertices that can be connected to fans are added. Furthermore, these vertices will be in a triangle with the adjacent fan if and only if the vertex v would be in such a triangle before we enlarged the cloud. Therefore, this construction increases the number of positive or negative literals of the variable represented by the cloud by three.

One easily checks that the statement on the number of vertices holds for the initial cases and is maintained every time three triangles are added. □

We conclude by formally expressing the relation between Partition Into Triangles on graphs of maximum degree four and Exact 3-Satisfiability. The proof of the resulting theorem directly follows from the above results.

Theorem 9

There exist linear-time transformations between Partition Into Triangles on graphs of maximum degree four and Exact 3-Satisfiability restricted to instances that satisfy Property 6 such that the following holds:

  1. 1.

    Any given instance is equivalent to its transformed instance.

  2. 2.

    An Exact 3-Satisfiability instance with variable set X and clause set  \(\mathcal{C}\) obtained from an n-vertex Partition Into Triangles instance of maximum degree four satisfies: \(2|\mathcal{C}| + \sum_{x \in X} (2f(x)-3 ) \leq n\).

  3. 3.

    A Partition Into Triangles instance on n vertices obtained from an Exact 3-Satisfiability instance satisfying Property 6 with variable set X and clause set \(\mathcal{C}\) satisfies: \(2|\mathcal{C}| + \sum_{x \in X} (2f(x)-3 ) = n\).

5 Hardness Results for Graphs of Maximum Degree Four

Having formalised the relation between Partition Into Triangles on graphs of maximum degree four and Exact 3-Satisfiability, we are now ready to prove some hardness results. In this section, we will show that Partition Into Triangles on graphs of maximum degree four is \(\mathcal{NP}\)-complete, and that no subexponential-time algorithm for this problem exists unless the Exponential-Time Hypothesis [11, 12] fails.

Theorem 10

Partition Into Triangles on graphs of maximum degree four is \(\mathcal{NP}\)-complete.

Proof

Clearly, the problem is in \(\mathcal{NP}\). For hardness, we reduce from the \(\mathcal{NP}\)-complete problem Exact 3-Satisfiability [10]. Given an Exact 3-Satisfiability instance, we enforce Property 6 by making three copies of each clause. Then, the result follows from Theorem 9. □

Next, we show that no subexponential-time algorithm for our problem exists under the following complexity-theoretic hypothesis that is known as the Exponential-Time Hypothesis. Note that for 3-Satisfiability instances n denotes the number of variables and m denotes the number of clauses.

Complexity-Theoretic Hypothesis 11

(Exponential-Time Hypothesis [11, 12])

There exists a constant c>1 such that there exists no algorithm for 3-Satisfiability that uses only \(\mathcal{O}(c^{n})\) time.

Proposition 12

Assuming the Exponential-Time hypothesis, there exists a constant c>1 such that there exists no algorithm for 3-Satisfiability that uses only \(\mathcal{O}(c^{m})\) time.

Proof

Direct consequence of the Sparsification Lemma of Impagliazzo et al.; see [12]. □

Now, we are ready to prove the following result.

Theorem 13

Assuming the Exponential-Time Hypothesis, there exists no algorithm for Partition Into Triangles on graphs of maximum degree four with a worst-case running time that is subexponential in n.

Proof

Consider an arbitrary 3-Satisfiability instance with m clauses. We create an equivalent Exact 3-Satisfiability instance with 4m clauses by using the equivalence from [21] shown below. To avoid confusion, we now denote a 3-Satisfiability clause with literals x, y, and z by SAT(x,y,z) and a similar Exact 3-Satisfiability clause with literals x, y, and z by XSAT(x,y,z).

We then transform this Exact 3-Satisfiability instance into an equivalent instance of Partition Into Triangles of maximum degree four using the construction in the proof of Theorem 10. This construction triples the number of clauses to 12m, and thus the total sum of the number of literal occurrences is at most 36m. By Lemma 8, variables x can be represented by clouds using less than 2f(x) vertices each. This gives at most 96m vertices: 72m for the variables and another 24m for the two vertices of a fan for each clause.

Suppose there exists a subexponential-time algorithm for Partition Into Triangles on graphs of maximum degree four, i.e, an \(\mathcal{O} (2^{\delta n})\)-time algorithm for all δ>0. Then, this algorithm solves 3-Satisfiability in \(\mathcal{O}(2^{\epsilon m})\) for all ϵ>0 using the above construction and δ=ϵ/96. However, no such algorithm can exist if we assume the Exponential-Time Hypothesis by Proposition 12. □

Note that although we have proven that, under the Exponential-Time Hypothesis, no algorithm subexponential in n exists, this also implies that no algorithm subexponential in m exists as \(m = \mathcal{O} (n)\) on bounded-degree graphs.

6 A Very Fast Exponential-Time Algorithm

In the previous section, we have given two hardness results for Partition Into Triangles on graphs of maximum degree four. Despite these results, this problems seems to admit very fast, though exponential-time, algorithms.

In this section, we give a simple \(\mathcal{O}(1.02445^{n})\)-time algorithm for this problem based on the algorithm for Exact Satisfiability by Byskov et al. [6] and the algorithm for Exact 3-Satisfiability by Wahlström [23]. In the Appendix, we also give a faster \(\mathcal{O} (1.02220^{n})\)-time algorithm. This algorithm is based on the same principles as the one in Theorem 14 but uses an extensive case analysis.

Theorem 14

There exists an \(\mathcal{O}(1.02445^{n})\)-time algorithm for Partition Into Triangles on graphs of maximum degree four.

Proof

Use Theorem 9 to obtain an instance of Exact 3-Satisfiability with variable set X and clause set \(\mathcal{C}\) satisfying \(n \geq2|\mathcal{C}| + \sum_{x \in X} (2f(x)-3 )\). Let γ 1 be the number of variables x with f +(x)=f (x)=1 and let γ 3 be the number of variables x with f(x)≥3; by Property 6 the total number of variables γ equals γ 1+γ 3. Since clauses have size three, we find that \(n \geq2(2\gamma_{1}+3\gamma_{3})/3 + \gamma_{1} + 3\gamma_{3} = 2\frac{1}{3}\gamma_{1} + 5\gamma_{3}\) and \(\gamma_{3} \leq n - 2\frac{1}{3}\gamma_{1}\).

If γ 1≤0.10746n, then apply Wahlström’s \(\mathcal{O} (1.0984^{\gamma})\)-time algorithm for Exact 3-Satisfiability [23]. Now, \(\gamma= \gamma_{1} + \gamma_{3} \leq0.10746n + (n - 2\frac{1}{3} \times0.10746n)/5 < 0.25732n\) by basic calculus. Therefore, the problem is solved by this algorithm in \(\mathcal{O} (1.0984^{0.25732n}) = \mathcal{O}(1.02445^{n})\) time.

Otherwise γ 1>0.10746n. In this case, we first reduce the instance in polynomial time removing all variables x with f +(x)=f (x)=1 by using the following equivalence where C and C′ are arbitrary sets of literals and Φ denotes any Exact Satisfiability formula:

$$(x,C) \wedge\bigl(\neg x,C'\bigr) \wedge\varPhi \Longleftrightarrow \bigl(C,C'\bigr) \wedge\varPhi $$

This results in an instance where γ 1=0 while the clauses have been increased in size. Now, we can apply the \(\mathcal{O}(2^{0.2325\gamma})\) Exact Satisfiability algorithm from Byskov et al. [6]. This algorithm now solves our instance in \(\mathcal{O}(1.1749^{\gamma_{3}}) = \mathcal{O}(1.02445^{n})\) time as \(\gamma_{3} \leq(n - 2\frac{1}{3} \times 0.10746n)/5 < 0.14986n\) by basic calculus. □

Theorem 15

There exists an \(\mathcal{O}(1.02220^{n})\)-time algorithm for Partition Into Triangles on graphs of maximum degree four.

Proof

See Appendix. □

7 Concluding Remarks

We have shown that the Partition Into Triangles problem is linear-time solvable on graphs of maximum degree three, that it is \(\mathcal{NP}\)-complete on graphs of maximum degree at least four, and that no subexponential-time algorithm for the problem on graphs of maximum degree four exists unless the Exponential-Time Hypothesis fails. For this seemingly hard problem on graphs of maximum degree four, we have given an efficient \(\mathcal{O}(1.0222^{n})\)-time algorithm using only linear space, and without any large, hidden polynomial-factors in the running time. When concerned with problems with reasonable input sizes, this would mean that our algorithm will probably be faster than polynomial-time algorithms for the same problem on, for example, graphs whose treewidth is bounded by 10. We would be interested to find more problems on which such fast, yet exponential-time, algorithms exists.

We have used an interesting relation between Partition Into Triangles on graphs of maximum degree four and Exact 3-Satisfiability to obtain these results. This relationship emerges by reducing Partition Into Triangles instances of maximum degree four until each vertex can have only two different possible local neighbourhoods. Connected series of vertices with one of these local neighbourhoods then form the variables of an Exact 3-Satisfiability instance, and pairs vertices with the other local neighbourhood form the clauses of this Exact 3-Satisfiability instance. Since such a structure seems to disappear on graphs with a higher degree bound, we wonder whether similar ideas could be used for triangle packing or triangle covering.