Keywords

1 Introduction

An instance of the maximum-weight triangle packing problem (MWTP for short) is an edge-weighted complete graph G on 3n vertices, where n is a positive integer. Given G, the objective of MWTP is to compute n vertex-disjoint triangles such that the total weight of edges in these n triangles is maximized.

The unweighted (or edge uniformly weighted) variant, denoted MTP for short, is to compute the maximum number of vertex-disjoint triangles in the input graph, which is edge unweighted and is not complete.

In their classic book, Garey and Johnson [8] show that MTP is NP-hard. Kann [14] and van Rooij et al. [16] show that MTP is APX-hard even restricted on graphs of maximum degree 4. Chlebik and Chlebikova [5] show that unless P \(=\) NP, no polynomial-time approximation algorithm for MTP can achieve an approximation ratio of 0.9929. Moreover, Guruswami et al. [9] show that MTP remains NP-hard even restricted on chordal, planar, line or total graphs.

MTP can be easily cast as a special case of the unweighted 3-set packing problem (U3SP for short). Recall that an instance of U3SP is a family \(\mathcal {F}\) of sets each of size 3 and the objective is to compute a sub-family \(\mathcal {F}' \subset \mathcal {F}\) of the maximum number of disjoint sets. Hurkens and Schrijver [13] (also see Halldorsson [10]) present a nontrivial polynomial-time approximation algorithm for U3SP which achieves an approximation ratio of \(\frac{2}{3} - \epsilon \) for any constant \(\epsilon > 0\). This ratio has been improved to \(\frac{3}{4} - \epsilon \) [6, 7]. Manic and Wakabayashi [15] present a polynomial-time approximation algorithm for the special case of MTP on graphs of maximum degree 4; their algorithm achieves an approximation ratio of 0.833.

Analogously, MWTP can be cast as a special case of the weighted 3-set packing problem (W3SP for short). Two different algorithms both based on local search have been designed for W3SP [1, 2] and they happen to achieve the same approximation ratio of \(\frac{1}{2} - \epsilon \) for any constant \(\epsilon > 0\). For MWTP specifically, Hassin and Rubinstein [11, 12] present a better randomized approximation algorithm with an expected approximation ratio of \(\frac{43}{83} - \epsilon \) for any constant \(\epsilon > 0\). This ratio has been improved to roughly 0.523 by Chen et al. [3, 4] and Zuylen [17].

This paper focuses on a common special case of MWTP, namely, the metric MWTP problem (MMWTP for short), where the edge weights in the input graph satisfy the triangle inequality. One can almost trivially design a polynomial-time approximation algorithm for MMWTP to achieve an approximation ratio of \(\frac{2}{3}\); but surprisingly, prior to this work, no nontrivial approximation algorithm had been designed and analyzed. In this paper, we design the first nontrivial polynomial-time approximation algorithm for MMWTP. Our algorithm is randomized and achieves an expected ratio of \(0.66745 - \epsilon \) for any constant \(\epsilon > 0\). At the high level, given an instance graph G, our algorithm starts by computing the maximum-weight cycle cover \(\mathcal {C}\) in G and then uses \(\mathcal {C}\) to construct three triangle packings \(T_1\), \(T_2\), and \(T_3\), among which the heaviest one is the output solution. The computation of \(T_1\) and \(T_2\) is deterministic but that of \(T_3\) is randomized.

The details of the algorithm are presented in the next section. We conclude the paper in the last Sect. 3, with some remarks.

2 The Randomized Approximation Algorithm

Hereafter, let G be a given instance of the problem, and we fix an optimal triangle packing B of G for the following argument. Note that there are 3n vertices in the input graph G.

The algorithm starts by computing the maximum weight cycle cover \(\mathcal {C}\) of G in polynomial time. Obviously, \(w(\mathcal {C}) \ge w(B)\), since B is also a cycle cover. Let \(\epsilon \) be any constant such that \(0< \epsilon < 1\). A cycle C in \(\mathcal {C}\) is short if its length is at most \(\lceil \frac{1}{\epsilon }\rceil \); otherwise, it is long. It is easy to transform each long cycle C in \(\mathcal {C}\) into two or more short cycles whose total weight is at least \((1-\epsilon )\cdot w(C)\). So, we hereafter assume that we have modified the long cycles in \(\mathcal {C}\) in this way. Then, \(\mathcal {C}\) is a collection of short cycles and \(w(\mathcal {C}) \ge (1-\epsilon )\cdot w(B)\).

We will compute three triangle packings \(T_1\), \(T_2\), \(T_3\) in G. The computation of \(T_1\) and \(T_2\) will be deterministic but that of \(T_3\) will be randomized. Our goal is to prove that for a constant \(\rho \) with \(0< \rho < 1\), \(\max \{w(T_1), w(T_2), \mathcal {E}[w(T_3)]\} \ge (\frac{2}{3}+\rho )\cdot w(B)\), where \(\mathcal {E}[X]\) denotes the expected value of a random variable X.

2.1 Computing \(T_1\)

We first compute the maximum weight matching \(M_1\) of size n (i.e., n edges) in G. We then construct an auxiliary complete bipartite graph \(H_1\) as follows. One part of \(V(H_1)\), denoted as \(V {\setminus } V(M_1)\), consists of the vertices of G that are not endpoints of \(M_1\); the vertices of the other part of \(V(H_1)\), denoted as \(M_1\), one-to-one correspond to the edges in \(M_1\). For each edge \(\{x, e = \{u, v\}\}\) in the bipartite graph \(H_1\), where \(x \in V {\setminus } V(M_1)\) and \(e \in M_1\), its weight is set to \(w(u,x) + w(v,x)\). Next, we compute the maximum weight matching \(M'_1\) in \(H_1\) and transform it into a triangle packing \(T_1\) with \(w(T_1) = w(M_1) + w(M'_1)\).

To compare \(w(T_1)\) against w(B), we fix a constant \(\delta \) with \(0\le \delta <1\) and classify the triangles in B into two types as follows. A triangle t in B is balanced if the minimum weight of an edge in t is at least \(1-\delta \) times the maximum weight of an edge in t; otherwise, it is unbalanced.

Lemma 1

Let \(B_{\bar{b}}\) be the set of unbalanced triangles in B, and \(\gamma = \frac{w(B_{\bar{b}})}{w(B)}\). Then, \(w(T_1) \ge \left( \frac{2}{3} + \frac{2\gamma \delta }{9-3\delta }\right) \cdot w(B)\).

Proof

For each t in B, let \(a_t\) (respectively, \(b_t\)) be the maximum (respectively, minimum) weight of an edge in t. Further let \(a = \sum _{t\in B} a_t\) and \(b = \sum _{t\in B} b_t\). If \(t \in B_{\bar{b}}\), then \(b_t < (1-\delta )a_t\) and in turn \((3-\delta )a_t > w(t)\). Thus, \(\sum _{t\in B_{\bar{b}}}a_t \ge \frac{1}{3-\delta }w(B_{\bar{b}}) \ge \frac{\gamma }{3-\delta }w(B)\). Hence, \(w(B) \le 2a + b \le 3a - \delta \sum _{t\in B_{\bar{b}}}a_t \le 3a - \frac{\delta \gamma }{3-\delta }w(B)\) and in turn \(a \ge \left( \frac{1}{3}+\frac{\delta \gamma }{9-3\delta }\right) w(B)\). Now, since \(w(T_1) \ge 2a\), we finally have \(w(T_1) \ge \left( \frac{2}{3} + \frac{2\gamma \delta }{9-3\delta }\right) \cdot w(B)\).    \(\square \)

2.2 Computing \(T_2\)

Several definitions are in order. A partial-triangle packing in a graph is a subgraph P of the graph such that each connected component of P is a vertex, edge, or triangle. A connected component C of P is a vertex-component (respectively, edge-component or triangle-component) of the graph if C is a vertex (respectively, edge or triangle). The augmented weight of P, denoted by \(\hat{w}(P)\), is \(\sum _t w(t) + 2\sum _e w(e)\), where t (respectively, e) ranges over all triangle-components (respectively, edge-components) of P. Intuitively speaking, if P has at least as many vertex-components as edge-components, then we can trivially augment P into a triangle packing \(P'\) (by adding more edges) so that \(w(P')\) is no less than the augmented weight of P.

We classify the triangles t in B into three types as follows.

  • t is completely internal if all its vertices fall on the same cycle in \(\mathcal {C}\).

  • t is partially internal if exactly two of its vertices fall on the same cycle in \(\mathcal {C}\).

  • t is external if no two of its vertices fall on the same cycle in \(\mathcal {C}\).

An edge e of B is external if the endpoints of e fall on different cycles in \(\mathcal {C}\); otherwise, e is internal. In particular, an internal edge e of B is completely (respectively, partially) internal if e appears in a completely (respectively, partially) internal triangle in B. A vertex v of G is external if it is incident to no internal edges of B. Let \(B_{\bar{e}}\) be the partial-triangle packing in G obtained from B by deleting all external edges.

Now, we are ready to explain how to construct \(T_2\) so that \(w(T_2) \ge \hat{w}(B_{\bar{e}})\). Let \(C_1\), ..., \(C_\ell \) be the cycles in \(\mathcal {C}\), and \(V_1\), ..., \(V_\ell \) be their vertex sets. For each \(i\in \{1,\ldots ,\ell \}\), let \(n_i = |V_i|\), \(p_i\) be the number of partially internal edges e in B such that both endpoints of e appear in \(C_i\), \(q_i\) be the number of external vertices in \(C_i\), and \(E_i\) be the set of edges \(\{u,v\}\) in G with \(\{u,v\} \subseteq V_i\). Obviously, \(n_i - 2p_i - q_i\) is a multiple of 3. For each \(i\in \{1,\ldots ,\ell \}\), let \(\tilde{n}_i = \sum _{h=1}^i n_h\), \(\tilde{p}_i = \sum _{h=1}^i p_h\), and \(\tilde{q}_i = \sum _{h=1}^i q_h\).

Although we do not know \(p_i\) and \(q_i\), we easily see that \(0 \le q_i \le n_i\) and \(0 \le p_i \le \lfloor \frac{n_i - q_i}{2}\rfloor \). So, for every \(j\in \{0,1,\ldots ,n_i\}\) and every \(k\in \{0,1,\ldots ,\lfloor \frac{n_i - j}{2}\rfloor \}\), we compute the maximum-weight (under \(\hat{w}\)) partial-triangle packing \(P_i(j,k)\) in the subgraph of G induced by \(V_i\) such that \(P_i(j,k)\) has exactly j vertex-components and exactly k edge-components. Since \(|V_i|\) is bounded by a constant (namely, \(\lceil \frac{1}{\epsilon }\rceil \)) from above, the computation of \(P_i(j,k)\) takes O(1) time.

Although we do not know \(\tilde{p}_i\) and \(\tilde{q}_i\), we easily see that \(0 \le \tilde{q}_i \le \tilde{n}_i\) and \(0 \le \tilde{p}_i \le \lfloor \frac{\tilde{n}_i - \tilde{q}_i}{2}\rfloor \). For every \(j\in \{0,1,\ldots ,\tilde{n}_i\}\) and every \(k\in \{0,1,\ldots ,\lfloor \frac{\tilde{n}_i - j}{2}\rfloor \}\), we want to compute the maximum-weight (under \(\hat{w}\)) partial-triangle packing \(\tilde{P}_i(j,k)\) in the graph \((\bigcup _{h=1}^i V_h, \bigcup _{h=1}^i E_h)\) such that \(\tilde{P}_i(j,k)\) has exactly j vertex-components and exactly k edge-components. This can be done by dynamic programming in \(O(n^3)\) time as follows. Clearly, \(\tilde{P}_1(j,k) = P_1(j,k)\) for every \(j\in \{0,1,\ldots ,\tilde{n}_1\}\) and every \(k\in \{0,1,\ldots ,\lfloor \frac{\tilde{n}_1 - j}{2}\rfloor \}\). Suppose that \(1\le i< \ell \) and we have computed \(\tilde{P}_{i}(j,k)\) for every \(j\in \{0,1,\ldots ,\tilde{n}_{i}\}\) and every \(k\in \{0,1,\ldots ,\lfloor \frac{\tilde{n}_{i} - j}{2}\rfloor \}\). For every \(j\in \{0,1,\ldots ,\tilde{n}_{i+1}\}\) and every \(k \in \{0, 1, \ldots \), \(\lfloor \frac{\tilde{n}_{i+1} - j}{2}\rfloor \}\), we can compute \(\tilde{P}_{i+1}(j,k)\) by finding a pair \((j',k')\) such that \(j'\in \{0,1,\ldots ,n_{i+1}\}\), \(k' \in \{0, 1, \ldots \), \(\lfloor \frac{n_{i+1} - j'}{2}\rfloor \}\), and \(\hat{w}(P_{i+1}(j',k')) + \hat{w}(\tilde{P}_i(j-j',k-k'))\) is maximized. Obviously, \(\tilde{P}_{i+1}(j,k) = P_{i+1}(j',k') \cup \tilde{P}_i(j-j',k-k')\).

Finally, we have \(\tilde{P}_\ell (j,k)\) for every \(j\in \{0,1,\ldots ,3n\}\) and every \(k\in \{0, 1, \ldots \), \(\lfloor \frac{3n - j}{2}\rfloor \}\). We now find a pair \((j',k')\) such that \(j'\in \{0,1,\ldots ,3n\}\), \(k'\in \{0, 1, \ldots \), \(\lfloor \frac{3n - j'}{2}\rfloor \}\), \(k' \le j'\), and \(\hat{w}(\tilde{P}_\ell (j',k'))\) is maximized. Obviously, \(\hat{w}(\tilde{P}_\ell (j',k')) \ge \hat{w}(B_{\bar{e}})\). Moreover, we can easily transform \(\tilde{P}_\ell (j',k')\) into a triangle packing \(T_2\) of G with \(w(T_2) \ge \hat{w}(\tilde{P}_\ell (j',k'))\) as follows.

  1. 1.

    Arbitrarily select \(k'\) vertex-components of \(\tilde{P}_\ell (j',k')\) and connect them to the edge-components of \(\tilde{P}_\ell (j',k')\) so that \(k'\) vertex-disjoint triangles are formed.

  2. 2.

    Arbitrarily connect the remaining \((j'-k')\) vertex-components of \(\tilde{P}_\ell (j',k')\) into \(\frac{j'-k'}{3}\) vertex-disjoint triangles.

In summary, we have shown the following lemma:

Lemma 2

We can construct a triangle packing \(T_2\) of G with \(w(T_2) \ge \hat{w}(B_{\bar{e}})\) in \(O(n^3)\) time.

2.3 Computing a Random Matching in \(\mathcal {C}\)

We compute a random matching M in \(\mathcal {C}\) as follows.

  1. 1.

    Initialize two sets \(L = \emptyset \) and \(M = \emptyset \).

  2. 2.

    For each even cycle \(C_i\) in \(\mathcal {C}\), perform the following three steps:

    1. (a)

      Partition \(E(C_i)\) into two matchings \(M_{i,1}\) and \(M_{i,2}\).

    2. (b)

      Select a \(j_i \in \{1,2\}\) uniformly at random.

    3. (c)

      Add the edges in \(M_{i,j_i}\) to L.

  3. 3.

    For each odd cycle \(C_i\) in \(\mathcal {C}\), perform the following five steps:

    1. (a)

      Select an edge \(e_i \in E(C_i)\) uniformly at random.

    2. (b)

      Partition \(E(C_i){\setminus }\{e_i\}\) into two matchings \(M_{i,1}\) and \(M_{i,2}\).

    3. (c)

      Select a \(j_i \in \{1,2\}\) uniformly at random.

    4. (d)

      Select an edge \(e'_i\in M_{i,j_i}\) uniformly at random and add \(e'_i\) to M.

    5. (e)

      Add the edges in \(M_{i,j_i} {\setminus } \{e'_i\}\) to L.

  4. 4.

    Select two thirds of edges from L uniformly at random and add them to M.

Lemma 3

Let \(c_o\) be the number of odd cycles in \(\mathcal {C}\). Then, immediately before Step 4, \(|L| = \frac{3}{2}\cdot (n-c_o)\).

Proof

Immediately before Step 4, \(2|L| = 3n-3c_o\) and hence \(|L| = \frac{3}{2}\cdot (n-c_o)\).

   \(\square \)

Lemma 4

\(|M| = n\).

Proof

Immediately before Step 4, \(|M| = c_o\). So, by Lemma 3, \(|M|=c_o+(n-c_o) = n\) after Step 4.    \(\square \)

Lemma 5

For every vertex v of G, \(\mathrm{Pr}[v\not \in V(M)] = \frac{1}{3}\).

Proof

First consider the case where v appears in an even cycle in \(\mathcal {C}\). In this case, \(v \in V(M)\) immediately before Step 4. So, after Step 4, \(\mathrm{Pr}[v\not \in V(M)] = \frac{1}{3}\).

Next consider the case where v appears in an odd cycle \(C_i\) in \(\mathcal {C}\). There are two subcases, depending on whether or not v is an endpoint of the edge \(e_i\) selected in Step 3a. If v is incident to \(e_i\), then \(\mathrm{Pr}[v \not \in V(M_{i,j_i})] = \frac{1}{2}\) and \(\mathrm{Pr}[v \in V(M_{i,j_i}) \wedge v \not \in V(e'_i)] = \frac{1}{2}\cdot \left( 1 - \frac{2}{n_i-1}\right) \). Hence, \(\mathrm{Pr}[v\not \in V(M)~|~v\in V(e_i)] = \frac{1}{2}+ \frac{1}{2}\cdot \left( 1 - \frac{2}{n_i-1}\right) \cdot \frac{1}{3} =\frac{2n_i-3}{3(n_i-1)}\). On the other hand, if v is not an endpoint of \(e_i\), then \(\mathrm{Pr}[v \in V(M_{i,j_i})] = 1\) and \(\mathrm{Pr}[v \in V(M_{i,j_i}) \wedge v \not \in V(e'_i)] = 1\cdot \left( 1 - \frac{2}{n_i-1}\right) = \frac{n_i-3}{n_i-1}\). Thus, \(\mathrm{Pr}[v\not \in V(M)~|~v\not \in V(e_i)] = \frac{n_i-3}{n_i-1}\cdot \frac{1}{3} = \frac{n_i-3}{3(n_i-1)}\). Therefore, \(\mathrm{Pr}[v \not \in V(M)] = \frac{2}{n_i}\cdot \frac{2n_i-3}{3(n_i-1)} + \left( 1 - \frac{2}{n_i}\right) \cdot \frac{n_i-3}{3(n_i-1)} = \frac{1}{3}\).    \(\square \)

Lemma 6

For every edge e of \(\mathcal {C}\), \(\mathrm{Pr}[e \in M] = \frac{1}{3}\).

Proof

First consider the case where e appears in an even cycle in \(\mathcal {C}\). In this case, \(\mathrm{Pr}[e \in M] = \frac{1}{2} \cdot \frac{2}{3} = \frac{1}{3}\).

Next consider the case where e appears in an odd cycle \(C_i\) in \(\mathcal {C}\). There are two subcases, depending on whether or not e is the edge \(e_i\) selected in Step 3a. If \(e = e_i\), then \(\mathrm{Pr}[e \not \in M] = 1\). Hence, \(\mathrm{Pr}[e\not \in M~|~e = e_i] = 1\). On the other hand, if \(e \ne e_i\), then \(\mathrm{Pr}[e \not \in M_{i,j_i}] = \frac{1}{2}\) and \(\mathrm{Pr}[e \ne e'_i~|~e \in M_{i,j_i}] = 1 - \frac{2}{n_i-1} = \frac{n_i-3}{n_i-1}\). Thus, \(\mathrm{Pr}[e \not \in M~|~e \ne e_i] = \frac{1}{2}\cdot 1 + \frac{1}{2}\cdot \frac{n_i-3}{n_i-1}\cdot \frac{1}{3} = \frac{2n_i-3}{3(n_i-1)}\). Therefore, \(\mathrm{Pr}[e \not \in M] = \frac{1}{n_i} \cdot 1 + \left( 1-\frac{1}{n_i}\right) \cdot \frac{2n_i-3}{3(n_i-1)} = \frac{2}{3}\).    \(\square \)

Lemma 7

For every vertex v of G and every edge e of \(\mathcal {C}\) such that v and e appear in different cycles in \(\mathcal {C}\), \(\mathrm{Pr}[e \in M \wedge v\not \in V(M)] \ge \frac{1}{9}\).

Proof

Suppose that v and e appear in \(C_{i'}\) and \(C_{i''}\), respectively. We distinguish four cases as follows.

Case 1: Both \(n_{i'}\) and \(n_{i''}\) are even. In this case, \(\mathrm{Pr}[v \in V(M_{i',j_{i'}})] = 1\) and \(\mathrm{Pr}[e \in M_{i'',j_{i''}}] = \frac{1}{2}\). So, \(\mathrm{Pr}[v \in V(M_{i',j_{i'}}) \wedge e \in M_{i'',j_{i''}}] = \frac{1}{2}\). Moreover, by Lemma 3, \(\mathrm{Pr}[e \in M \wedge v\not \in V(M)~|~v \in V(M_{i',j_{i'}}) \wedge e \in M_{i'',j_{i''}}] = \frac{{{|L|-2} \atopwithdelims (){\frac{2}{3}|L|-1}}}{{|L| \atopwithdelims ()\frac{2}{3}|L|}} = \frac{(n-c_o)\cdot \frac{1}{2}(n-c_o)}{\frac{3}{2}(n-c_o)\cdot \left( \frac{3}{2}(n-c_o)-1\right) } \ge \frac{2}{9}\). Thus, \(\mathrm{Pr}[e \in M \wedge v\not \in V(M)] \ge \frac{2}{9} \cdot \frac{1}{2} = \frac{1}{9}\).

Case 2: \(n_{i'}\) is even but \(n_{i''}\) is odd. In this case, \(\mathrm{Pr}[v \in V(M_{i',j_{i'}})] = 1\) and \(\mathrm{Pr}[e \in M_{i'',j_{i''}}] = \frac{1}{2}\cdot \frac{n_{i''}-1}{n_{i''}}= \frac{n_{i''}-1}{2n_{i''}}\). Moreover, \(\mathrm{Pr}[e = e'_{i''}~|~e \in M_{i'',j_{i''}}] = \frac{2}{n_{i''}-1}\), \(\mathrm{Pr}[e = e'_{i''}] = \frac{1}{n_{i''}}\), and \(\mathrm{Pr}[e \in M_{i'',j_{i''}}{\setminus } \{e'_{i''}\}] = \frac{n_{i''}-1}{2n_{i''}}\cdot \left( 1-\frac{2}{n_{i''}-1}\right) = \frac{n_{i''}-3}{2n_{i''}}\). Furthermore, \(\mathrm{Pr}[v\not \in V(M)~|~e = e'_{i''}] = \frac{1}{3}\) by Lemma 5, and \(\mathrm{Pr}[v\not \in V(M)\wedge e\in M~|~e \in M_{i'',j_{i''}}{\setminus } \{e'_{i''}\}] = \frac{{{|L|-2} \atopwithdelims (){\frac{2}{3}|L|-1}}}{{|L| \atopwithdelims ()\frac{2}{3}|L|}} = \frac{(n-c_o)\cdot \frac{1}{2}(n-c_o)}{\frac{3}{2}(n-c_o)\cdot \left( \frac{3}{2}(n-c_o)-1\right) } \ge \frac{2}{9}\). Thus, \(\mathrm{Pr}[e \in M \wedge v\not \in V(M)] \ge \frac{1}{3}\cdot \frac{1}{n_{i''}} + \frac{2}{9}\cdot \frac{n_{i''}-3}{2n_{i''}} = \frac{1}{9}\).

Case 3: \(n_{i'}\) is odd but \(n_{i''}\) is even. In this case, \(\mathrm{Pr}[v \in V(M_{i',j_{i'}})] = \frac{2}{n_{i'}}\cdot \frac{1}{2} + \left( 1-\frac{2}{n_{i'}}\right) \cdot 1 = \frac{n_{i'}-1}{n_{i'}}\) and \(\mathrm{Pr}[e \in M_{i'',j_{i''}}] = \frac{1}{2}\). So, \(\mathrm{Pr}[v \in V(M_{i',j_{i'}})\wedge e \in M_{i'',j_{i''}}] = \frac{n_{i'}-1}{2n_{i'}}\) and \(\mathrm{Pr}[v \not \in V(M_{i',j_{i'}})\wedge e \in M_{i'',j_{i''}}] = \frac{1}{2n_{i'}}\). Moreover, by Lemma 3, \(\mathrm{Pr}[e \in M \wedge v\not \in V(M)~|~v \in V(M_{i',j_{i'}}) \wedge e \in M_{i'',j_{i''}}] = \frac{{{|L|-2} \atopwithdelims (){\frac{2}{3}|L|-1}}}{{|L| \atopwithdelims ()\frac{2}{3}|L|}} = \frac{(n-c_o)\cdot \frac{1}{2}(n-c_o)}{\frac{3}{2}(n-c_o)\cdot \left( \frac{3}{2}(n-c_o)-1\right) } \ge \frac{2}{9}\) and \(\mathrm{Pr}[e \in M \wedge v\not \in V(M)~|~v \not \in V(M_{i',j_{i'}}) \wedge e \in M_{i'',j_{i''}}] = \frac{2}{3}\). Thus, \(\mathrm{Pr}[e \in M \wedge v\not \in V(M)] \ge \frac{n_{i'}-1}{2n_{i'}}\cdot \frac{2}{9} + \frac{1}{2n_{i'}} \cdot \frac{2}{3} \ge \frac{1}{9}\).

Case 4: Both \(n_{i'}\) and \(n_{i''}\) are odd. In this case, \(\mathrm{Pr}[v \in V(M_{i',j_{i'}})] = \frac{n_{i'}-1}{n_{i'}}\) and \(\mathrm{Pr}[e \in M_{i'',j_{i''}}] = \frac{1}{2}\cdot \frac{n_{i''}-1}{n_{i''}}= \frac{n_{i''}-1}{2n_{i''}}\). Moreover, \(\mathrm{Pr}[e = e'_{i''}~|~e \in M_{i'',j_{i''}}] = \frac{2}{n_{i''}-1}\), \(\mathrm{Pr}[e = e'_{i''}] = \frac{1}{n_{i''}}\), and \(\mathrm{Pr}[e \in M_{i'',j_{i''}}{\setminus } \{e'_{i''}\}] = \frac{n_{i''}-1}{2n_{i''}}\cdot \left( 1-\frac{2}{n_{i''}-1}\right) = \frac{n_{i''}-3}{2n_{i''}}\). So, \(\mathrm{Pr}[v\not \in V(M_{i',j_{i'}})\wedge e = e'_{i'}] = \frac{1}{n_{i'}n_{i''}}\), \(\mathrm{Pr}[v\not \in V(M_{i',j_{i'}})\wedge e \in M_{i'',j_{i''}}{\setminus } \{e'_{i''}\}] = \frac{n_{i''}-3}{2n_{i'}n_{i''}}\), \(\mathrm{Pr}[v\in V(M_{i',j_{i'}})\wedge e = e'_{i'}] = \frac{n_{i'}-1}{n_{i'}n_{i''}}\), \( \mathrm{Pr}[v\in V(M_{i',j_{i'}})\wedge e \in M_{i'',j_{i''}}{\setminus } \{e'_{i''}\}] = \frac{(n_{i'}-1)(n_{i''}-3)}{2n_{i'}n_{i''}}\). Obviously, \(\mathrm{Pr}[e \in M \wedge v\not \in V(M)~|~v \in V(M_{i',j_{i'}}) \wedge e =e'_{i''}]=\frac{1}{3}\), \(\mathrm{Pr}[e \in M \wedge v\not \in V(M)~|~v \not \in V(M_{i',j_{i'}}) \wedge e =e'_{i''}]=1\), and \(\mathrm{Pr}[e \in M \,\wedge \, v\not \in V(M)~|~v \not \in V(M_{i',j_{i'}}) \,\wedge \, e \in M_{i'',j_{i''}}{\setminus } \{e'_{i''}\}]=\frac{2}{3}\). Furthermore, by Lemma 3, \(\mathrm{Pr}[e \in M \wedge v\not \in V(M)~|~v \in V(M_{i',j_{i'}}) \wedge e \in M_{i'',j_{i''}}{\setminus } \{e'_{i''}\}] = \frac{{{|L|-2} \atopwithdelims (){\frac{2}{3}|L|-1}}}{{|L| \atopwithdelims ()\frac{2}{3}|L|}} = \frac{(n-c_o)\cdot \frac{1}{2}(n-c_o)}{\frac{3}{2}(n-c_o)\cdot \left( \frac{3}{2}(n-c_o)-1\right) } \ge \frac{2}{9}\). Thus, \(\mathrm{Pr}[e \in M \wedge v\not \in V(M)] \ge \frac{1}{3}\cdot \frac{n_{i'}-1}{n_{i'}n_{i''}} + 1\cdot \frac{1}{n_{i'}n_{i''}} + \frac{2}{3}\cdot \frac{n_{i''}-3}{2n_{i'}n_{i''}} + \frac{2}{9}\cdot \frac{(n_{i'}-1)(n_{i''}-3)}{2n_{i'}n_{i''}} \ge \frac{1}{9}\).    \(\square \)

2.4 Computing \(T_3\)

Fix a constant \(\tau \) with \(0< \tau < 1\). A good triplet is a triplet (xyz), where \(\{x,y\}\) is an edge of some cycle \(C_i\) in \(\mathcal {C}\) and z is a vertex of some other cycle \(C_j\) in \(\mathcal {C}\) with \(i\ne j\) such that \(w(x,y) \le (1-\tau )\cdot \left( w(x,z) + w(y,z)\right) \).

To compute \(T_3\), we initialize \(T_3 = \emptyset \) and proceed as follows.

  1. 1.

    Construct an auxiliary edge-weighted and edge-labeled multi-digraph \(H_3\) as follows. The vertex set of \(H_3\) is V(G). For each good triplet (xyz), \(H_3\) contains the two arcs (zx) and (zy), each of the two arcs has a weight of \(w(x,z) + w(y,z)\) in \(H_3\), the label of (zx) is y, and the label of (zy) is x.

  2. 2.

    Compute the maximum-weight matching \(M_3\) in \(H_3\) (by ignoring the direction of each arc).

  3. 3.

    Compute a random matching M in \(\mathcal {C}\) as in Sect. 2.3.

  4. 4.

    Let \(N_3\) be the set of all arcs \((z,x) \in M_3\) such that \(z \not \in V(M)\) and \(\{x,y\} \in M\), where y is the label of (zx). (Comment: Since both M and \(N_3\) are matchings, no two arcs in \(N_3\) can share a label. Moreover, the endpoints of each edge in M can be the heads of at most two arcs in \(N_3\).)

  5. 5.

    Initialize \(N'_3 = N_3\). For every two arcs (zx) and \((z',y)\) in \(N'_3\) such that \(\{x,y\} \in M\), select one of (zx) and \((z',y)\) uniformly at random and delete it from \(N'_3\).

  6. 6.

    For each \((z,x) \in N'_3\), let \(T_3\) include the triangle t with \(V(t)=\{x,y,z\}\), where y is the label of (zx). (Comment: By Step 5 and the comment on Step 4, the triangles included in \(T_3\) in this step are vertex-disjoint.)

  7. 7.

    Let \(M'\) be the set of edges (xy) in M such that neither x nor y is the head or the label of an arc in \(N'_3\). Further let Z be the set of vertices z in G such that \(z \not \in V(M)\) and z is not the tail of an edge in \(N'_3\). (Comment: Since \(|M| = n\) by Lemma 4, the comment on Step 6 implies \(|Z| = |M'|\).)

  8. 8.

    Select an arbitrary one-to-one correspondence between the edges in \(M'\) and the vertices in Z. For each \(z \in Z\) and its corresponding edge (xy) in \(M'\), let \(T_3\) include the triangle t with \(V(t)=\{x,y,z\}\).

We classify external balanced triangles in B into two types as follows. An external balanced triangle t in B is of Type 1 if for each vertex v of t, the weight of each edge incident to v in \(\mathcal {C}\) is at least \(\frac{1}{2}(1-\frac{1}{2}\delta )(1-\tau )w(t)\); otherwise, t is of Type 2.

Similarly, we classify partially internal balanced triangles in B into two types as follows. A partially internal balanced triangle t in B is of Type 1 if the weight of each edge incident to the external vertex of t in \(\mathcal {C}\) is at least \(\frac{1}{2}(1-\frac{1}{2}\delta )(1-\tau ) w(t)\); otherwise, t is of Type 2.

Lemma 8

Let \(B^e_1\) be the set of Type-1 external balanced triangles in B. Further let \(B^p_1\) be the set of Type-1 partially internal balanced triangles in B. Then, \(w(T_1) \ge \frac{2}{3}w(B) + \frac{2-3\delta -6\tau +3\delta \tau }{54}w(B^e_1) + \frac{2-3\delta -6\tau +3\delta \tau }{162}w(B^p_1)\).

Proof

For the analysis, we use the triangles in \(B^e_1 \cup B^p_1\) to construct a random matching N in \(\mathcal {C}\) as follows.

  1. 1.

    Initialize \(N' = \emptyset \). For each triangle t in B, select one edge \(e_t\) of t uniformly at random and add it to \(N'\).

  2. 2.

    For each triangle t in \(B^e_1\), choose one neighbor \(v'_t\) of \(v_t\) in \(\mathcal {C}\) uniformly at random, where \(v_t\) is the vertex of t not incident to \(e_t\).

  3. 3.

    For each triangle t in \(B^p_1\) such that \(e_t\) is internal, choose one neighbor \(v'_t\) of \(v_t\) in \(\mathcal {C}\) uniformly at random, where \(v_t\) is the external vertex of t.

  4. 4.

    Initialize \(X = \emptyset \). For each \(t\in B^e_1 \cup B^p_1\), if \(v'_t \not \in V(N')\), then add \((v_t,v'_t)\) to X.

  5. 5.

    Let D be the digraph with vertex set \(V(G){\setminus } V(N')\) and arc set X. Partition X into three matchings \(X_1\), \(X_2\), \(X_3\) in D. (Comment: Each connected component of the underlying undirected graph of D is either a cycle of \(\mathcal {C}\) or a graph of maximum degree at most 3 whose simplified version is a path. Therefore, the partition in this step can be done.)

  6. 6.

    Select a set Y among \(X_1\), \(X_2\), \(X_3\) uniformly at random.

  7. 7.

    Initialize \(N = \{e_t~|~t \in B {\setminus } (B^e_1\cup B^p_1)\}\). For each \(t \in B^e_1\), if \((v_t,v'_t) \not \in Y\), then add \(e_t\) to N; otherwise add \(\{v_t,v'_t\}\) to N. Similarly, for each \(t \in B^p_1\), if \(e_t\) is external or \((v_t,v'_t) \not \in Y\), then add \(e_t\) to N; otherwise add \(\{v_t,v'_t\}\) to N.

For each triangle \(t \in B^e_1\), let \(E_t\) be the set of edges e in \(\mathcal {C}\) such that e is incident to a vertex of t. Similarly, for each triangle \(t \in B^p_1\), let \(E_t\) be the set of edges e in \(\mathcal {C}\) such that e is incident to the external vertex of t. Consider a \(t \in B^e_1\) and an \(e=\{x,y\} \in E_t\) with \(x\in V(t)\). Obviously, \(\mathrm{Pr}[x = v_t] = \frac{1}{3}\) and \(\mathrm{Pr}[y = v'_t~|~x = v_t] = \frac{1}{2}\); hence \(\mathrm{Pr}[\{v_t,v'_t\}=e] = \frac{1}{6}\). Moreover, \(\mathrm{Pr}[v'_t \not \in V(N')] = \frac{1}{3}\) and in turn \(\mathrm{Pr}[\{v_t,v'_t\} = e\wedge v'_t \not \in V(N')] = \frac{1}{18}\). Furthermore, \(\mathrm{Pr}[e \in N~|~\{v_t,v'_t\} = e\wedge v'_t \not \in V(N')] = \frac{1}{3}\). So, \(\mathrm{Pr}[e \in N] = \frac{1}{3}\cdot \frac{1}{18} = \frac{1}{54}\). Now, if \(t \in B^e_1\), then \(|E_t| = 6\) and in turn \(\mathrm{Pr}[e_t \not \in N] = 6\cdot \frac{1}{54} = \frac{1}{9}\). On the other hand, if \(t \in B^p_1\), then \(|E_t| = 2\) and in turn \(\mathrm{Pr}[e_t \not \in N] = 2\cdot \frac{1}{54} = \frac{1}{27}\).

By the discussions in the last paragraph, \(\mathcal {E}[w(N)] \ge \frac{1}{3}\sum _{t\in B{\setminus } (B^e_1\cup B^p_1)} w(t) + \frac{8}{9}\cdot \frac{1}{3}\sum _{t\in B^e_1}w(t) + \frac{1}{9}\cdot \frac{1}{2}(1-\frac{1}{2}\delta )(1-\tau )\sum _{t\in B^e_1}w(t) + \frac{26}{27}\cdot \frac{1}{3}\sum _{t\in B^p_1}w(t) + \frac{1}{27}\cdot \frac{1}{2}(1-\frac{1}{2}\delta )(1-\tau )\sum _{t\in B^p_1}w(t) = \frac{1}{3}w(B) + \frac{2-3\delta -6\tau +3\delta \tau }{108}w(B^e_1) + \frac{2-3\delta -6\tau +3\delta \tau }{324}w(B^p_1)\). So, \(w(T_1) \ge 2\cdot \mathcal {E}[w(N)] \ge \frac{2}{3}w(B) + \frac{2-3\delta -6\tau +3\delta \tau }{54}w(B^e_1) + \frac{2-3\delta -6\tau +3\delta \tau }{162}w(B^p_1)\).    \(\square \)

Lemma 9

Let \(B^e_2\) be the set of Type-2 external balanced triangles in B to w(B). Further let \(B^p_2\) be the set of Type-2 partially internal balanced triangles in B. Then, \(\mathcal {E}[w(T_3)] \ge \frac{2(1-\epsilon )}{3}w(B) + \frac{(1-\delta )\tau }{54-18\delta } \cdot w(B^e_2) + \frac{(1-\delta )\tau }{54-18\delta } \cdot w(B^p_2)\).

Proof

For a set F of edges in \(H_3\), let \(\tilde{w}(F)\) denote the total weight of edges of F in \(H_3\). Further let \(W_2\) be the total weight of triangles in \(B^e_2 \cup B^p_2\).

Consider an arbitrary \(t \in B^e_2 \cup B^p_2\). Since t is of Type 2, t has a vertex \(v_t\) such that some neighbor \(v'_t\) of \(v_t\) in \(\mathcal {C}\) satisfies \(w(v_t,v'_t) < \frac{1}{2}(1-\frac{1}{2}\delta )(1-\tau )w(t)\). Let \(z_t\) and \(z'_t\) be the vertices in \(V(t){\setminus }\{v_t\}\). By the triangle inequality, \(w(z_t,v'_t)\ge \frac{1}{2}w(z_t,z'_t)\) or \(w(z'_t,v'_t)\ge \frac{1}{2}w(z_t,z'_t)\). Without loss of generality, we may assume that \(w(z_t,v'_t)\ge \frac{1}{2}w(z_t,z'_t)\). We claim that \((v_t,v'_t;z_t)\) is a good triplet. To see this, first recall that \((1-\delta )w(z'_t,v_t) \le w(z_t,v_t)\) because t is balanced. So, \((1-\frac{1}{2}\delta )w(z'_t,v_t) \le (1+\frac{1}{2}\delta )w(z_t,v_t) + \frac{1}{2}\delta w(z_t,z'_t)\) by the triangle inequality. Thus, \((1-\frac{1}{2}\delta )\left( w(z_t,v_t) + w(z_t,z'_t) + w(z'_t,v_t)\right) \le 2w(z_t,v_t) + w(z_t,z'_t) \le 2w(z_t,v_t) + 2w(z_t,v'_t)\). Hence, \(\frac{1}{2}(1-\frac{1}{2}\delta ) w(t) \le w(z_t,v_t) + w(z_t,v'_t)\). Therefore, \(w(v_t,v'_t) < \frac{1}{2}(1-\frac{1}{2}\delta )(1-\tau )w(t) \le (1-\tau ) \left( w(z_t,v_t) + w(z_t,v'_t)\right) \). Consequently, the claim holds.

By the claim in the last paragraph, the set X of all \(\{z_t,v_t\}\) with \(t\in B^e_2 \cup B^p_2\) is a matching in \(H_3\). Moreover, \(\tilde{w}(M_3) \ge \tilde{w}(X) = \sum _{t\in B^e_2 \cup B^p_2} w(z_t,v_t) \ge \frac{1-\delta }{3-\delta } \sum _{t\in B^e_2 \cup B^p_2} w(t) = \frac{1-\delta }{3-\delta }W_2\), where the second inequality holds because t is balanced and in turn \(w(z_t,v_t) \ge \frac{1-\delta }{3-\delta }w(t)\). Now, by Lemma 7, \(\mathcal {E}[\tilde{w}(N_3)] \ge \frac{1}{9}\tilde{w}(M_3) \ge \frac{1-\delta }{27-9\delta }W_2\) and in turn \(\mathcal {E}[\tilde{w}(N'_3)] \ge \frac{1-\delta }{54-18\delta }W_2\). Obviously, \(w(T_3) \ge 2w(M) + \tau \cdot \tilde{w}(N'_3)\) by the triangle inequality. Therefore, by Lemma 6, \(\mathcal {E}[w(T_3)] \ge \frac{2}{3}\cdot w(\mathcal {C}) + \frac{(1-\delta )\tau }{54-18\delta }W_2 \ge \frac{2(1-\epsilon )}{3}\cdot w(B) + \frac{(1-\delta )\tau }{54-18\delta }W_2\).    \(\square \)

2.5 Analyzing the Approximation Ratio

Let \(B^i\) be the set of completely internal balanced triangles in B. For convenience, let \(\alpha _1 = \frac{w(B^i)}{w(B)}\), \(\alpha _2 = \frac{w(B^e_1)}{w(B)}\), \(\alpha _3 = \frac{w(B^e_2)}{w(B)}\), \(\alpha _4 = \frac{w(B^p_1)}{w(B)}\), and \(\alpha _5 = \frac{w(B^p_2)}{w(B)}\). Then, \(\gamma + \alpha _1 + \alpha _2 + \alpha _3 + \alpha _4 + \alpha _5 = 1\).

We choose \(\delta = 0.08\) and \(\tau = 0.22\). Then, by Lemmas 1, 2, 8, and 9, we have the following inequalities:

$$\begin{aligned} \frac{w(T_1)}{w(B)}\ge & {} \frac{2}{3} + \frac{4}{219}\gamma \end{aligned}$$
(1)
$$\begin{aligned} \frac{w(T_2)}{w(B)}\ge & {} \alpha _1 + \frac{2}{3} \alpha _4 + \frac{2}{3}\alpha _5 \end{aligned}$$
(2)
$$\begin{aligned} \frac{w(T_1)}{w(B)}\ge & {} \frac{2}{3} + \frac{0.2464}{27}\alpha _2 + \frac{0.2464}{81}\alpha _4 \end{aligned}$$
(3)
$$\begin{aligned} \frac{\mathcal {E}[w(T_3)]}{w(B)}\ge & {} \frac{2(1-\epsilon )}{3} + \frac{2.53}{657}\alpha _3 + \frac{2.53}{657}\alpha _5. \end{aligned}$$
(4)

Suppose that we multiply both sides of Inequalities (1), (2), (3), and (4) by 0.1288, 0.00235, 0.2578, and 0.611, respectively. Then, one can easily verify that the summation of the left-hand sides of the resulting inequalities is

$$ 0.1288 \cdot \frac{w(T_1)}{w(B)} + 0.00235 \cdot \frac{w(T_2)}{w(B)} + 0.2578 \cdot \frac{w(T_1)}{w(B)} + 0.611 \cdot \frac{\mathcal {E}[w(T_3)]}{w(B)}, $$

while the summation of the right-hand sides is at least

$$ \frac{1.9952}{3}-\frac{1.222}{3}\epsilon + 0.00235(\gamma + \alpha _1 + \alpha _2 + \alpha _3 + \alpha _4 + \alpha _5). $$

Now, using \(\gamma + \alpha _1 + \alpha _2 + \alpha _3 + \alpha _4 + \alpha _5 = 1\), we finally have

$$ (0.3866 + 0.00235 + 0.611) \cdot \max \left\{ \frac{w(T_1)}{w(B)}, \frac{w(T_2)}{w(B)}, \frac{\mathcal {E}[w(T_3)]}{w(B)}\right\} \ge \frac{2.00225}{3} - \frac{1.222}{3}\epsilon . $$

That is,

$$ \max \left\{ w(T_1), w(T_2), \mathcal {E}[w(T_3)]\right\} \ge (0.66745-0.41\epsilon ) \cdot w(B). $$

In summary, we have proven the following theorem, stating that the MMWTP problem admits a better approximation algorithm than the trivial \(\frac{2}{3}\)-approximation.

Theorem 1

For any constant \(0< \epsilon < 0.00078\), the expected approximation ratio achieved by our randomized approximation algorithm is at least \(0.66745 - \epsilon \).

3 Conclusions

We studied the maximum-weight triangle packing problem on an edge-weighted complete graph G, in which the edge weights satisfy the triangle inequality. Although the non-metric variant has been extensively studied in the literature, it is surprising that prior to our work, no nontrivial approximation algorithm had been designed and analyzed for this common metric case. We designed the first nontrivial polynomial-time approximation algorithm for MMWTP, which is randomized and achieves an expected approximation ratio of \(0.66745 - \epsilon \) for any positive constant \(\epsilon < 0.00078\). This improves the almost trivial deterministic \(\frac{2}{3}\)-approximation.

Perhaps more dexterous tuning of the parameters inside our algorithm could lead to certain better worst-case performance ratio, but we doubt it will be significantly better. New ideas are needed for the next major improvement.