1 Introduction

A graph H is called an induced subgraph of G if H is obtained from G by deletion of vertices. A class of graphs is called hereditary if it is closed under deletion of vertices. It is well-known that any hereditary (and only hereditary) class \({\mathcal {X}}\) can be defined by a set of its forbidden induced subgraphs \({\mathcal {Y}}\). We write \({\mathcal {X}}=Free({\mathcal {Y}})\) in this case, and graphs in \({\mathcal {X}}\) are said to be \({\mathcal {Y}}\) -free.

An independent set in a graph is a subset of its pairwise non-adjacent vertices. The size of a maximum independent set of a graph G is called the independence number of G and denoted by \(\alpha (G)\). The independent set problem is to verify, for a given graph G and a natural number k, whether \(\alpha (G)\ge k\) or not. It is a classical NP-complete problem.

A coloring of a graph G is a mapping \(c: V(G) \longrightarrow \mathbb {N}\), such that \(c(u)\ne c(v)\) for any adjacent vertices \(u,v\in V(G)\). This notion can be defined in another way via partition into independent sets. A coloring of a graph is partitioning the set of its vertices into independent sets called color classes. The minimum number of colors in colorings of G is called the chromatic number of G and denoted \(\chi (G)\). The chromatic number problem is to verify, for a given graph G and a natural number k, whether \(\chi (G)\le k\) or not. It is a classical NP-complete problem.

By \(\chi ^*(G)\) we denote the minimal number of color classes in the colorings of a graph G having at most two vertices in every color class. Clearly, for any n-vertex graph G, we have \(\chi ^*(G)=n-\pi (\overline{G})\), where \(\pi (H)\) is the matching number of a graph H, i.e. the maximum number of pairwise non-adjacent edges of H. It is well-known that the matching number of a n-vertex graph can be computed in \(O(n^4)\) time (Edmonds 1965). Hence, for any n-vertex graph G, \(\chi ^*(G)\) can be computed in the same amount of time.

The computational complexity of the coloring problem in the hereditary classes of graphs defined by forbidden induced subgraphs with at most four vertices was studied in the paper Lozin and Malyshev (2015). For all but three classes in this family, it was shown either NP-completeness or polynomial-time solvability of the problem. The three exceptional cases are the classes \(Free(\{O_4,C_4\}),Free(\{K_{1,3},O_4\}),\) \(Free(\{K_{1,3},O_4,K_2+2K_1\})\). Moreover, it was shown in Lozin and Malyshev (2015) that the coloring problem for \(Free(\{K_{1,3},O_4\})\) is polynomially equivalent to the same problem for \(Free(\{K_{1,3},O_4,K_2+2K_1\})\). In this paper, we do not find out the complexity of the problem for the two open cases. We present approximation polynomial-time algorithms for the problem with some “asymptotic” performance guarantees. More specific, for a graph G, we present a polynomial-time algorithm for computing a number p(G), such that \(\chi (G)\le p(G)\le r\cdot \chi (G)+O(1)\), where \(r=\frac{3}{2}\) if G is \(\{O_4,K_{3,3}\}\)-free and \(r=\frac{4}{3}\) if G is \(\{K_{1,3},O_4,K_2+2K_1\}\)-free. As \(Free(\{O_4,C_4\})\subseteq Free(\{K_{3,3},O_4\})\), the performance guarantee for \(\{K_{3,3},O_4\}\)-free graphs also holds for \(\{O_4,C_4\}\)-free graphs.

2 Notation

We use the standard notation \(K_n,O_n,C_n\) for a complete, an empty graph, a chordless cycle with n vertices, respectively. A graph \(K_{p,q}\) is a complete bipartite graph with p vertices in the first part and q in the second. The graph fork is obtained from a \(K_{1,3}\) by subdividing an arbitrary its edge. The graph \(K_4-e\) is obtained from a \(K_4\) by deleting an arbitrary its edge.

The formula N(x) denotes the neighborhood of a vertex x.

The sum \(G_1+G_2\) is the disjoint union of graphs \(G_1\) and \(G_2\) with non-intersected sets of vertices. A graph \(\overline{G}\) is the complement of a graph G. A graph kG is the disjoint union of k copies of G. For a graph G and a subset \(V'\subseteq V(G)\), \(G\setminus V'\) denotes the subgraph of G obtained by deleting all elements of \(V'\).

3 Approximation algorithms

3.1 The case of \(\{O_4,K_{3,3}\}\)-free graphs

For a \(\{O_4,K_{3,3}\}\)-free graph G, \(\chi ^*(G)\) computed in polynomial time gives an approximation for \(\chi (G)\) with the performance guarantee almost \(\frac{3}{2}\), as the following theorem shows.

Theorem 1

For any \(\{O_4,K_{3,3}\}\)-free graph G, we have \(\chi (G)\le \chi ^*(G)\le \frac{3}{2}\cdot \chi (G)+1\).

Proof

Let us consider an optimal coloring of G. Let \(k_1\) be the number of its three-vertex color classes, \(k_2\) be the number of its color classes with at most two vertices. Since G is \(O_4\)-free, \(\chi (G)=k_1+k_2\). As G is \(K_{3,3}\)-free, any two of the \(k_1\) color classes have two non-adjacent vertices in distinct classes. Hence, the union of the \(k_1\) color classes can be partitioned into \(\lceil \frac{3k_1}{2}\rceil \) subsets, each of which induces a \(O_1\) or a \(O_2\). Therefore, G has a coloring with \(\lceil \frac{3k_1}{2}\rceil +k_2\) color classes, each of which has at most two elements. Hence, \(\chi ^*(G)\le \lceil \frac{3k_1}{2}\rceil +k_2\le \frac{3k_1}{2}+k_2+1\le \frac{3}{2}\cdot (k_1+k_2)+1=\frac{3}{2}\cdot \chi (G)+1\). Clearly, \(\chi ^*(G)\ge \chi (G)\). \(\square \)

3.2 The case of \(\{O_4,K_{1,3},K_2+2K_1\}\)-free graphs

Let G be a graph. By T(G) we denote the graph, whose vertices are the triangles of G and two its vertices are adjacent if and only if the corresponding triangles intersect. Given G, T(G) can be constructed in polynomial time on |V(G)|. Let \(\alpha ^*(G)\triangleq \alpha (T(G))\).

Lemma 1

If G is \(\{K_4,K_4-e,K_3+K_1\}\)-free, then the independence number of T(G) can be computed in polynomial time on |V(G)|.

Proof

Firstly, we will show that T(G) is \(fork+56K_1\)-free. Any triangle (xyz) of G defines a “3-coloring” of \(G\setminus V'\) as follows, where \(V'=\{x,y,z\}\). We use the term “3-coloring” in a non-classical sense assuming that some adjacent vertices can have the same color. As G is \(\{K_4,K_4-e,K_3+K_1\}\)-free, each of the elements of \(V(G)\setminus V'\) is adjacent to exactly one element of \(V'\). All neighbors of an element \(a\in V'\) in \(V(G)\setminus V'\) have the same color.

Assume that T(G) contains an induced fork. Hence, G contains five pairwise distinct triangles \((x_1,x_2,x_3),(y_1,y_2,y_3),(z_1,z_2,z_3),(x_1,y_1,u_1),(u_1,u_2,u_3)\), where \(z_1=u_3\) (see the figure below). Additionally, assume that there is a triangle \((a_1,a_2,a_3)\) of G non-intersecting with each of the five triangles. Let \(c:~V(G)\setminus \{a_1,a_2,a_3\}\longrightarrow \{1,2,3\}\) be the “3-coloring” defined above, where \(c(w)=i\) for every \(w\in V(G)\setminus \{a_1,a_2,a_3\}\) adjacent to \(a_i\). Since G is \(\{K_4,K_4-e\}\)-free, vertices of each of the five triangles have pairwise distinct colors. Hence, there is an element of \(\{x_2,x_3\}\), an element of \(\{y_2,y_3\}\), an element of \(\{z_2,z_3\}\) having the same color as the color of \(u_1\). Without loss of generality, \(c(x_3)=c(y_3)=c(z_3)=c(u_1)=3, c(x_1)=c(u_2)=c(y_2)=c(z_2)=1, c(y_1)=c(x_2)=c(u_3)=2\) (Fig. 1).

We will show that there is an edge \((v',v'')\in E(G)\), such that \(v'\) and \(v''\) belong to some two of the five triangles and \(c(v')=c(v'')\). Assume that there is no such an edge. As G is \(\{K_4,K_4-e,K_3+K_1\}\)-free, \((x_1,z_3)\in E(G)\) and \((z_3,y_2)\in E(G)\). Similarly, \((y_2,z_1)\in E(G)\). We have a contradiction, as \(y_2\) is adjacent to two vertices of the triangle \((z_1,z_2,z_3)\). So, for any triangle of G non-intersecting with each of the five triangles, there is a triangle of G intersecting with T, whose two vertices belong to \(\bigcup \limits _{i=1}^{3}\{x_i,y_i,z_i,u_i\}\). The subgraph of G induced by \(\bigcup \limits _{i=1}^{3}\{x_i,y_i,z_i,u_i\}\) has at most \(\frac{11\cdot (11-1)}{2}=55\) edges. Hence, by the pigeonhole principle, T(G) must be \(fork+56K_1\)-free, otherwise it contains an induced \(K_4\) or \(K_4-e\).

Clearly, the equality \(\alpha (H)=\max (\alpha (H\setminus \{v\}),\alpha (H\setminus N(v)))\) holds for any graph H and its vertex v. Hence, the independent set problem for \(fork+56K_1\)-free graphs can be polynomially reduced to the same problem for fork-free graphs. The independent set problem for fork-free graphs can be solved in polynomial time (Alekseev 2004). Hence, the lemma holds. \(\square \)

Fig. 1
figure 1

The configuration of the triangles

Lemma 2

For every n-vertex \(\{K_{1,3},O_4,K_2+2K_1\}\)-free graph G, the inequalities \(0<\chi ^*(G)-\frac{\alpha ^*(\overline{G})+1}{2}\le \chi (G)\le \min (\chi ^*(G),n-2\alpha ^*(\overline{G}))\) hold.

Proof

The inequality \(\chi (G)\le \chi ^*(G)\) is obvious. Consider a set of \(\alpha ^*(\overline{G})\) vertex-disjoint triangles of \(\overline{G}\). There are \(n-3\alpha ^*(\overline{G})\) vertices of \(\overline{G}\) not belonging to the triangles in the set. Hence, there is a coloring of G with \(n-2\alpha ^*(\overline{G})\) color classes, \(\alpha ^*(\overline{G})\) of them have three vertices and \(n-3\alpha ^*(\overline{G})\) of them have one element. Hence, \(\chi (G)\le n-2\alpha ^*(\overline{G})\). Consider an arbitrary optimal coloring of G. Every its color class contains at most three vertices, as G is \(O_4\)-free. Let k be the number of the color classes in the coloring having exactly three vertices. As G is \(K_{1,3}\)-free, any two of the color classes with three vertices have two non-adjacent vertices in distinct classes. Hence, the union of all k color classes with three vertices can be partitioned into \(\lceil \frac{3k}{2}\rceil \) subsets, each of them induces a \(O_2\) or a \(O_1\). Therefore, there is a coloring of G in at most \(\chi (G)+\lceil \frac{3k}{2}\rceil -k\) colors, such that every color class has at most two vertices. Clearly, \(\chi (G)+\lceil \frac{3k}{2}\rceil -k\ge \chi ^*(G)\), i.e. \(\chi (G)\ge \chi ^*(G)+k-\lceil \frac{3k}{2}\rceil \). As \(k-\lceil \frac{3k}{2}\rceil \ge -\frac{k+1}{2}\) and \(\alpha ^*(\overline{G})\ge k\), \(\chi (G)\ge \chi ^*(G)-\frac{\alpha ^*(\overline{G})+1}{2}\). The inequality \(\chi ^*(G)-\frac{\alpha ^*(\overline{G})+1}{2}>0\) is trivial whenever G is the single-vertex graph. As \(\chi ^*(G)\ge \frac{n}{2}\) and \(\alpha ^*(\overline{G})\le \frac{n}{3}\), \(\chi ^*(G)-\frac{\alpha ^*(\overline{G})+1}{2}\ge \frac{\frac{2n}{3}-1}{2}>0\) whenever \(n\ge 2\). \(\square \)

Theorem 2

There is an approximation polynomial-time algorithm for the coloring problem for \(\{K_{1,3},O_4,K_2+2K_1\}\)-free graphs having the performance guarantee almost \(\frac{4}{3}\).

Proof

Let G be a n-vertex \(\{K_{1,3},O_4,K_2+2K_1\}\)-free graph. The complement of any \(\{K_{1,3},O_4,K_2+2K_1\}\)-free graph is \(\{K_4,K_4-e,K_3+K_1\}\)-free. By Edmonds (1965) and Lemma 1, \(\chi ^*(G)\) and \(\alpha ^*(\overline{G})\) can be computed in polynomial time on n. Assume that \(\alpha ^*(\overline{G})\le \frac{n}{4}\). Hence, \(\chi ^*(G)-\frac{\alpha ^*(\overline{G})+1}{2}\ge \chi ^*(G)-\frac{\alpha ^*(\overline{G})}{2}-\frac{1}{2}\ge \frac{3}{4}\chi ^*(G)-\frac{1}{2}\), as \(\chi ^*(G)\ge \frac{n}{2}\) and \(\alpha ^*(\overline{G})\le \frac{n}{4}\). Therefore, \(\chi ^*(G)\) approximates \(\chi (G)\) with an factor which is asymptotically at most \(\frac{4}{3}\), since \(\frac{\chi ^*(G)}{\chi (G)}\le \frac{\chi ^*(G)}{\chi ^*(G)-\frac{\alpha ^*(\overline{G})+1}{2}}\) (by Lemma 2) and \(\chi ^*(G)\ge \chi (G)\). Assume that \(\alpha ^*(\overline{G})>\frac{n}{4}\). Hence, \(\chi ^*(G)\ge \frac{n}{2}>n-2\alpha ^*(\overline{G})\). By Lemma 2, \(1\le \frac{n - 2\alpha ^{*}(\overline{G})}{\chi (G)} \le \frac{n - 2\alpha ^{*}(\overline{G})}{\chi ^{*}(G) - \frac{\alpha ^{*}(\overline{G})+1}{2}}\). Clearly, \(\frac{n-2\alpha ^*(\overline{G})}{\chi ^*(G)-\frac{\alpha ^*(\overline{G})}{2}}\le 2\frac{n-2\alpha ^*(\overline{G})}{n-\alpha ^*(\overline{G})}\), as \(\chi ^*(G)\ge \frac{n}{2}\). Moreover, \(2\frac{n-2\alpha ^*(\overline{G})}{n-\alpha ^*(\overline{G})}\) is equal to the value of the function \(f(x)=2\frac{1-2x}{1-x}\) at the point \(x=\frac{\alpha ^*(\overline{G})}{n}\). As \(f'(x)=-\frac{2}{(1-x)^2}\), the function f(x) is monotonically decreasing over the segment \([\frac{1}{4},\frac{1}{3}]\). Hence, its maximum value over the segment is equal to \(f(\frac{1}{4})=\frac{4}{3}\). Therefore, \(n-2\alpha ^*(\overline{G})\) approximates \(\chi (G)\) with an approximation ratio, which is asymptotically at most \(\frac{4}{3}\). \(\square \)

4 Concluding remarks

Recall that there are three hereditary classes defined by forbidden induced subgraphs with at most four vertices for which the computational complexity of the coloring problem is open. The cases are \(Free(\{O_4,C_4\}),Free(\{K_{1,3},O_4\}), Free(\{K_{1,3},O_4,K_2+2K_1\})\). The problem seems to be NP-complete for \(Free(\{K_{1,3},O_4\}),Free(\{K_{1,3},O_4,K_2+2K_1\})\) and polynomial-time solvable for \(Free(\{O_4,C_4\})\). Clarifying its complexity status in the classes is an interesting problem for future research. For all of the three classes, we presented polynomial-time approximation algorithms with specified performance guarantees. Designing efficient approximation algorithms with better performance guarantees for them is also an interesting problem for future research.