1 Introduction

Many standard computational problems, including maximum clique, maximum independent set, or minimum coloring, which are \(\mathsf {NP}\)-hard in general, have polynomial-time exact or approximation algorithms in restricted classes of graphs. Due to the practical and theoretical applications, some of such graph classes are particularly intensively studied. Among them are:

  • interval graphs: intersection graphs of intervals on a real line,

  • proper interval graphs: intersection graphs of intervals none of which is contained in another,

  • chordal graphs: intersection graphs of subtrees of a tree,

  • function and permutation graphs: intersection graphs of continuous and linear functions, respectively, defined on the interval [0, 1],

  • comparability graphs: graphs whose edges correspond to the pairs of vertices comparable in some fixed partial order \({<}\) on the vertex set (such an order is called a transitive orientation of the graph),

  • co-comparability graphs: the complements of comparability graphs.

It is well known that the class of function graphs corresponds to the class of co-comparability graphs [13], and the class of permutation graphs corresponds to the intersection of comparability and co-comparability graphs [24] (see Fig. 1 for the hierarchy of inclusions). All these classes of graphs are hereditary, which means that they are closed under vertex deletion.

Fig. 1
figure 1

Hierarchy of inclusions between graph classes considered in the introduction. An arrow from graph class \({\mathcal {A}}\) to graph class \({\mathcal {B}}\) indicates that \({\mathcal {A}} \subset {\mathcal {B}}\)

Being hereditary is a very useful property in algorithmic design as every hereditary class of graphs can also be uniquely characterized in terms of minimal forbidden induced subgraphs: a graph belongs to a class \({\mathcal {G}}\) if and only if it does not contain any graph from some family \({\mathcal {F}}\) as an induced subgraph. For every graph class introduced above, a characterization by forbidden subgraphs is known, see [8] for perfect graphs, [19] for interval graphs, [12] for comparability and permutation graphs. However, for all of them, the family of forbidden subgraphs is infinite and it may also be quite complex. Moreover, every graph G from any class introduced above is perfect. Grötschel, Lovász, and Schrijver [14] showed that in the class of perfect graphs the maximum clique, the maximum independent set, and the minimum coloring problems can be solved in polynomial time.

Polynomial-time algorithms devised for the above-mentioned graph classes can sometimes be adjusted to also work on graphs that are “close” to graphs from these classes. Usually, the “closeness” of a graph G to a graph class \({\mathcal {G}}\) is measured by the number of operations required to transform G into a graph from the class \({\mathcal {G}}\), where a single operation consists either on removing a vertex from G or on adding or removing an edge from G. Such an approach leads us to the following generic problem.

Problem:

Graph modification problem into a class of graphs \({\mathcal {G}}\)

Input:

A graph G (typically not from \({\mathcal {G}}\)) and a number k

Question:

Can G be transformed into a graph of the class \({\mathcal {G}}\)

by performing \(\leqslant k\) modifications of an appropriate kind?

Depending on the kind of modifications allowed, we obtain four variants of this problem: vertex deletion problem, edge deletion problem, edge completion problem, and edge edition problem (the latter allowing both deletions and additions of edges). For the class of graphs defined above, all four variants of the modification problem are \(\mathsf {NP}\)-hard—see [22] for references to \(\mathsf {NP}\)-hardness proofs. In particular, Lewis and Yannakakis [20] showed that the vertex deletion problem into any non-trivial hereditary class of graphs is \(\mathsf {NP}\)-hard. This is not surprising, as many classical hard problems can be formulated as vertex deletion problems into particular classes of graphs, for example, Vertex Cover as vertex deletion to edgeless graphs, Feedback Vertex Set as vertex deletion to forests, and Odd Cycle Transversal as vertex deletion to bipartite graphs.

Graph modification problems are a popular research direction in the study of the parameterized complexity of \(\mathsf {NP}\)-complete problems. In general, for a problem \(\varPi \), an input of a parameterized problem consists of an instance I of \(\varPi \) and a parameter \(k \in {\mathbb {N}}\). Then we say that \(\varPi \) is fixed parameter tractable (\(\mathsf {FPT}\)) if there exists an algorithm deciding whether I is a yes-instance of \(\varPi \) in time \(f(k)\cdot |I|^{{\mathcal {O}}(1)}\), where f is some computable function. For a graph modification problem, we often choose the parameter k as a number of allowed modifications, so the instance of such a problem is still a pair (Gk).

It turns out that characterizations by forbidden structures are sometimes useful to design \(\mathsf {FPT}\) algorithms for graph modification problems. For example, Cai [4] proposed an \(\mathsf {FPT}\) algorithm for modification problems into classes of graphs characterized by a finite family of forbidden induced subgraphs \({\mathcal {F}}\). His algorithm identifies a forbidden structure in the input graph (which can be done in polynomial time when \({\mathcal {F}}\) is finite) and branches over all possible ways of modifying that structure. Since the families of forbidden structures are infinite for graph classes introduced above, modification algorithms for these classes have to be much more sophisticated. For several of them modification problems have satisfactory solutions:

  • chordal graphs: all four versions of the modification problem are \(\mathsf {FPT}\) [7, 23];

  • interval graphs: edge completion and edge deletion are \(\mathsf {FPT}\) [5, 28], vertex deletion is \(\mathsf {FPT}\) [7], edge edition remains open;

  • proper interval graphs: all four versions of the modification problem are \(\mathsf {FPT}\) [6].

On the other hand, it is known that the vertex deletion to perfect graphs is \(\mathsf {W[2]}\)-hard [15]. It is worth mentioning that for a long time, it was unknown whether there are classes of graphs recognizable in polynomial time for which modification problems are hard. The first such example was given by Lokshtanov [21], who proved that the vertex deletion is \(\mathsf {W[2]}\)-hard for graphs avoiding all wheels (i.e., cycles with an additional vertex adjacent to all other vertices). It is unknown whether comparability graphs, co-comparability graphs, and permutation graphs have \(\mathsf {FPT}\) modification algorithms. The class of co-comparability graphs, which constitutes the superclass of interval graphs and an important subclass of perfect graphs, seems to be particularly interesting from the parameterized point of view.

Our focus.Like the class of interval graphs, the class of permutation graphs admits polynomial-time algorithms for rich family problems which are \(\mathsf {NP}\)-complete in general. Apart from the already mentioned classical hard problems which are polynomial-time solvable for perfect graphs, there also exist polynomial algorithms solving e.g., Hamiltonian Cycle, Feedback Vertex Set or Dominating Set in the class of permutation graphs [3, 9].

In light of the above considerations, since all the modification problems into the class of permutation graphs—and the related classes of comparability and co-comparability graphs—remain open, restricting our attention to the class of bipartite permutation graphs appears to be a natural research direction. Bipartite permutation graphs form an interesting graph class themselves, first investigated by Spinrad, Brandstädt, and Stewart [25], who characterized them by means of appropriately chosen linear orderings of its bipartition classes. One of the most interesting results concerning the bipartite permutation graphs is by Heggernes et al. [16], who showed that the \(\mathsf {NP}\)-complete problem of computing the cutwidth of a graph (i.e., finding a linear order of the vertices of a graph that minimizes the maximum number of edges intersected by any line inserted between two consecutive vertices) is polynomial for bipartite permutation graphs.

Our algorithm exploits the absence of some forbidden structures in bipartite permutation graphs. Since these structures cannot, in particular, occur in permutation graphs, we believe that besides being a complete result itself, our research is a step towards understanding the parameterized complexity of modification problems into permutation graphs.

Our results. We focus mainly on the modification by vertex deletion.

Theorem 1

There is an \({\mathcal {O}}(9^k \cdot |V(G)|^9)\)-time algorithm for instances (Gk) of the vertex deletion into bipartite permutation graphs problem.

We prove Theorem 1 in Sect. 4. Our algorithm is based on the characterization of bipartite permutation graphs by forbidden subgraphs. Using the characterization, at first, we get rid of constant-size forbidden subgraphs by branching, which is a standard technique in modification problems on hereditary graph classes [27, 28]. We call graphs without these forbidden subgraphs almost bipartite permutation graphs.

Our main contribution is in the structural analysis of almost bipartite permutation graphs which may contain holes (on more than ten vertices) in contrast to bipartite permutation graphs. This approach is partially inspired by the ideas of van ’t Hof and Villanger [27] who used similar tools in their work on proper interval vertex deletion problem. We use the result of Spinrad, Brandstädt, and Stewart [25], who showed that the vertices of every connected bipartite permutation graph \(G=(U,W,E)\) can be embedded into a strip in such a way that the vertices from U are on the bottom edge of the strip, the vertices from W are on the top edge of the strip, the neighbors N(u) of u occur consecutively on the top edge of the strip for every \(u \in U\) (adjacency property), the vertices from \(N(u)-N(u')\) occur consecutively on the top edge of the strip for every \(u,u' \in U\) (enclosure property), and the analogous properties are satisfied by the vertices in W (see Fig. 2).

Fig. 2
figure 2

Embedding of a bipartite permutation graph (UWE) into a strip satysfying the adjacency and the enclosure properties

Our structural result (see the discussion after Lemma 1) asserts that, depending on the parity of the length of the shortest hole, a connected almost bipartite permutation graph may be naturally embedded in either a cylinder, or a Möbius strip, locally satisfying adjacency and enclosure properties (see Fig. 3).

Fig. 3
figure 3

An embedding of a connected almost bipartite permutation graph in a cylinder or a Möbius strip that locally satisfies the adjacency and enclosure properties

Once we obtain such structure, we show that every minimal vertex cut that destroys all holes lies nearby a few consecutive vertices from the shortest hole. This allows us to check all the possibilities where we can find a minimum cut. Finally, we use a polynomial algorithm for finding maximum flow (and thus a minimum cut).

The approach used to prove Theorem 1 can be slightly modified to obtain a 9-approximation algorithm for the bipartite permutation vertex deletion problem. We show the following.

Theorem 2

There exists a polynomial-time 9-approximation algorithm for vertex deletion into bipartite permutation graphs problem.

2 Preliminaries

Unless stated otherwise, all graphs considered in this work are simple, i.e., undirected, with no loops and parallel edges. Let \(G=(V,E)\) be a graph. For a subset \(S \subseteq V\), the subgraph of G induced by S is the graph \(G[S] = (S, \{uv \mid uv \in E, u,v\in S\})\). The neighborhood of a vertex \(u \in V\) is the set \(N(u) = \{v \in V \mid uv \in E\}\). Similarly, we write \(N(U)=\bigcup _{u\in U} N(u)\setminus U\) for a set \(U\subseteq V\). Let \(u,v\in V\). We say that u and v are at distance k (in G) if k is the length of a shortest path between u and v in G. We denote a complete graph and a cycle on n vertices by \(K_n\) and \(C_n\), respectively. By hole we mean an induced cycle on at least five vertices. We say that a hole is even (or odd) if it contains even (odd) number of vertices, respectively.

For a graph \(G=(V,E)\), a pair \((V,{<})\) is a transitive orientation of G if \({<}\) is a transitive and irreflexive relation on V that satisfies either \(u < v\) or \(v < u\) iff \(uv \in E\) for every \(u,v \in V\).

A partially ordered set (shortly partial order or poset) is a pair \(P = (X,{\leqslant _P})\) that consists of a set X and a reflexive, transitive, and antisymmetric relation \({\leqslant _P}\) on X. For a poset \((X,{\leqslant _P})\), let the strict partial order \(<_P\) be a binary relation defined on X such that \(x <_P y\) if and only if \(x \leqslant _P y\) and \(x \ne y\). Equivalently, \((X,{<_P})\) is a strict partial order if \(<_P\) is irreflexive and transitive. Two elements \(x,y \in X\) are comparable in P if \(x \leqslant _P y\) or \(y \leqslant _P x\); otherwise, xy are incomparable in P. A linear order \(L=(X,{\leqslant _L})\) is a partial order in which every two vertices \(x,y \in X\) are comparable. A strict linear order \((X,<_L)\) is a binary relation defined in a way that \(x <_L y\) if and only if \(x \leqslant _L y\) and \(x \ne y\).

Let \(P=(X,{\leqslant _P})\) be a poset. A linear order \(L=(X,{\leqslant _L})\) is called a linear extension of P if \({\leqslant _{P}} \subseteq {\leqslant _L}\). Given a family of posets \({\mathcal {P}} = \{P_i = (X,{\leqslant _{P_i}}): i \in I\}\), we say that P is the intersection of \({\mathcal {P}}\) if for every \(x,y \in X\) we have \(x \leqslant _P y\) if and only if \(x \leqslant _{P_i} y\) for every \(i \in I\). The dimension of a poset P is the minimal number of linear extensions of P that intersect to P. In particular, we say that P is two-dimensional if it is the intersection of two linear extensions of P.

A comparability graph (incomparability graph) of a poset \(P=(X,{\leqslant _P})\) has X as the set of its vertices and the set including every two vertices comparable (incomparable, respectively) in P as the set of its edges. Note the following: if \((X,{\leqslant _P})\) is a poset, then \((X, {<_P})\) is a transitive orientation of the comparability graph of P. A graph \(G=(V,E)\) is a comparability graph (co-comparability graph) if G is a comparability (incomparability, respectively) graph of some poset defined on V. So, G is a comparability graph if and only if G admits a transitive orientation. A graph G is a permutation graph if and only if G and the complement of G are comparability graphs [24] (or equivalently, G and the complement of G admit transitive orientations). Baker, Fishburn, and Roberts [1] proved that G is a permutation graph if and only if G is the incomparability graph of a two-dimensional poset.

We say that two sets X and Y are comparable if X and Y are comparable with respect to \(\subseteq \)-relation (that is, \(X \subseteq Y\) or \(Y \subseteq X\) holds). We use the convenient (although non-standard) notation \([m]:=\{0,1,\dots ,m\},\) for every \(m \in {\mathbb {N}}\). For every \(i,j \in {\mathbb {Z}}\) such that \(i \leqslant j\) by [ij] we mean the set \(\{i,i+1,\ldots ,j\}\).

3 The Structure of (Almost) Bipartite Permutation Graphs

The characterization of bipartite permutation graphs presented below was proposed by Spinrad, Brandstädt, and Stewart [25].

Suppose \(G=(U,W,E)\) is a connected bipartite graph. A linear order \((W,{<_W})\) satisfies adjacency property if for each vertex \(u \in U\) the set N(u) consists of vertices that are consecutive in \((W,{<_W})\). A linear order \((W,{<_W})\) satisfies enclosure property if for every pair of vertices \(u,u' \in U\) such that N(u) is a subset of \(N(u')\), vertices in \(N(u') - N(u)\) occur consecutively in \((W,{<_W})\). A strong ordering of the vertices of \(U \cup W\) consists of linear orders \((U,{<_U})\) and \((W,{<_W})\) such that for every \((u,w'), (u',w) \in E\), where \(u,u' \in U\), and \(w,w' \in W\), it holds that \(u <_U u'\) and \(w <_W w'\) imply \((u,w) \in E\) and \((u',w') \in E\). Note that, whenever \((U,{<_U})\) and \((W,{<_W})\) form a strong ordering of \(U \cup W\), then \((U,{<_U})\) and \((W,{<_W})\) satisfy the adjacency and enclosure properties.

Theorem 3

(Spinrad, Brandstädt, Stewart [25]) The following three statements are equivalent for a connected bipartite graph \(G=(U,W,E)\):

  1. (a)

    (UWE) is a bipartite permutation graph.

  2. (b)

    There exists a strong ordering of \(U \cup W\).

  3. (c)

    There exists a linear order \((W,{<_W})\) of W satisfying adjacency and enclosure properties.

An example of a bipartite permutation graph \(G=(U,W,E)\) with linear order \(w_1<_W w_2<_W\ldots<_W w_8 <_W w_9\) of the vertices of W which satisfies the adjacency and the enclosure properties is shown in Fig. 2.

Another characterization of bipartite permutation graphs can be obtained by listing all minimal forbidden induced subgraphs for this class of graphs. Such a list can be compiled by taking all odd cycles of length \(\geqslant 3\) (forbidden structures for bipartite graphs) and all bipartite graphs from the list of forbidden structures for permutation graphs obtained by Gallai [12]. The whole list is shown in Fig. 4.

Fig. 4
figure 4

Forbidden structures for bipartite permutation graphs

3.1 Almost Bipartite Permutation Graphs

The goal of this section is to characterize graphs which do not contain small forbidden subgraphs for the class of bipartite permutation graphs. Following terminology of van ’t Hof and Villanger [27] we call such graphs almost bipartite permutation graphs.

Definition 1

A graph \(G=(V,E)\) is an almost bipartite permutation graph if G does not contain \(T_2\), \(X_2\), \(X_3\), \(K_3\), \(C_k\) for \(k \in [5,9]\) as induced subgraphs.

Suppose \(G=(V,E)\) is a connected almost bipartite permutation graph.

Proposition 1

Every hole in G is a dominating set.

Proof

Let \(C=\{c_0,c_1,\dots ,c_{m-1}\}\) be a hole in G. Hence, \(m \geqslant 10.\) Suppose, for contradiction, that there exists a vertex in the set \(V \setminus (C\cup N(C))\). As G is connected, there must exist \(v \in V\) at distance two from C. Let \(w\in N(v)\cap N(C)\) and let \(c_j\) be a neighbor of w in C. We now look at the neighborhood of w. As G contains no triangle, \(wc_{j-1}\) and \(wc_{j+1}\) are non-edges. Moreover, as G contains no copy of \(T_2\), vertex w is adjacent to at least one of \(c_{j-2}\) and \(c_{j+2}\), say \(c_{j-2}\). Thus, w is nonadjacent to \(c_{j-3}\). Therefore, the set \(\{c_{j-3},c_{j-2},c_{j-1},c_{j},c_{j+1},w,v\}\) induces a copy of \(X_2\) in G, which leads to a contradiction. \(\square \)

Let C be a shortest hole in G, m be the size of C, and \(c_0,c_1,\ldots ,c_{m-1}\) be the consecutive vertices of C, \(m \geqslant 10\). In the remaining part of the paper we use the following notation with respect to C. For any integral number i by \(c_i\) we denote the unique vertex \(c_{i \bmod m}\) from the cycle C. For any two different vertices \(c_i,c_j\) in C, by the set of all vertices between \(c_i\) and \(c_j\) from C we mean the set \(\{c_i,c_{i+1},\ldots ,c_{i+k}\}\), where k is the smallest natural number such that \(c_{i+k}=c_j\). Note that this notion is not symmetric, i.e., the set of all vertices between \(c_j\) and \(c_i\) from C contains \(c_i,c_j\) and all the vertices from C that are not between \(c_i\) and \(c_j\).

Proposition 2

For every vertex \(v \in V\) either:

  1. (1)

    \(N(v) \cap C = \{c_i\}\) for some \(i \in [m-1]\), or

  2. (2)

    \(N(v) \cap C = \{c_{i},c_{i+2}\}\) for some \(i \in [m-1]\).

Proof

Since C is an induced cycle, (2) clearly holds for the vertices from C, so let v be a vertex in \(V\setminus C\). As C is a dominating set, by Proposition 1, vertex v has at least one neighbor in C. If v has exactly one neighbor in C, then (1) holds and we are done. So assume that it has more than one neighbor. We now distinguish two cases. First, suppose that there exist two vertices \(c_j, c_\ell \in N(v)\cap C\) at distance at least three in C such that v has no neighbor in the set of vertices between \(c_j\) and \(c_l\), except \(c_j\) and \(c_l\). Then, \(\{c_j,c_{j+1},\dots ,c_\ell ,v\}\) induces a cycle \(C'\) on at least five vertices in G. As \(c_j\) and \(c_\ell \) are at distance at least three in C, \(C'\) is shorter than C. In particular, \(C'\) contradicts either G containing no copy of \(C_\ell \), for \(\ell \in \{5,\ldots ,9\}\), or C being a shortest hole in G. Therefore, this case never occurs.

Hence, v has either (i) exactly two neighbors in C and those are at distance two as there is no triangle in G, so (2) holds, or (ii) C has an even number of vertices and v is adjacent to every second vertex of C. It remains to show that the latter never occurs. Indeed, if it does, then without loss of generality \(c_0\in N(v)\). But observe that since C has at least ten vertices, the set \(\{c_0,c_1,c_2,c_3,c_4,c_6,v\}\) induces a copy of \(X_3\). This concludes the proof. \(\square \)

Given Proposition 2, for every \(i\in [m-1]\) we can set \(A_i = \big \{v \in V: N(v) \cap C = \{c_{i-1},c_{i+1}\}\!\big \}\) and \(B_i = \big \{v \in V: N(v) \cap C = \{c_i\}\big \}\). Note that sets \(A_0,B_0,\ldots ,A_{m-1},B_{m-1}\) form a partition of V. Moreover, for every \(i \in [m-1]\) we have \(c_i\in A_i\). Following our notation, for any integer i by \(A_i\) and \(B_i\) we denote the sets \(A_{i\bmod m}\) and \(B_{i \bmod m}\), respectively. Furthermore, for every \(i \leqslant j\) we set:

$$\begin{aligned} A_G[i,j]&= \left\{ \begin{array}{ll} A_i \cup B_{i+1} \cup A_{i+2}\cup B_{i+3} \cup \ldots \cup A_{j-1} \cup B_{j} &{} \text {if j-i is odd}, \\ A_i \cup B_{i+1} \cup A_{i+2}\cup B_{i+3} \cup \ldots \cup B_{j-1} \cup A_{j} &{} \text {if j-i is even}, \end{array} \right. \\ B_G[i,j]&= \left\{ \begin{array}{ll} B_i \cup A_{i+1} \cup B_{i+2}\cup A_{i+3}\cup \ldots \cup B_{j-1} \cup A_{j} &{} \text {if j-i is odd}, \\ B_i \cup A_{i+1} \cup B_{i+2}\cup A_{i+3}\cup \ldots \cup A_{j-1} \cup B_{j} &{} \text {if j-i is even}, \end{array} \right. \\ \text {and } V_G[i,j]&= A_G[i,j] \cup B_G[i,j]. \end{aligned}$$

We write just A[ij], B[ij], and V[ij], respectively, instead of \(A_G[i,j]\), \(B_G[i,j]\), and \(V_G[i,j]\), when there is no confusion.

We now characterize the neighborhoods of the vertices in sets \(A_i\) and \(B_i\), see also Fig. 5.

Fig. 5
figure 5

A possible neighborhood of u in \(A_i\) and w in \(B_i\)

Proposition 3

Let \(i \in [m-1]\). Then:

  1. (1)

    \(A_i\) and \(B_i\) are independent sets.

  2. (2)

    For every \(u \in A_i\) and every \(w \in B_i\) we have \(uw \in E\).

  3. (3)

    For every \(u \in A_i\) we have \(B_i \subseteq N(u) \subseteq B[i-2,i+2]\).

  4. (4)

    For every \(w \in B_i\) we have \(A_i \subseteq N(w) \subseteq A[i-2,i+2]\).

Proof

Statement (1) follows trivially from the fact that G contains no triangle. To show statement (2), assume for a contrary that \(uw \notin E\) for some \(u \in A_i\) and some \(w \in B_i\). Since \(u \in A_i\), we have \(N(u) \cap C =\{c_{i-1}, c_{i+1}\}\), and since \(w \in B_i\) we have \(N(w) \cap C =\{c_i\}\). Hence, the set \(\{c_{i-2},u,c_i,c_{i+2},c_{i-1},w,c_{i+1}\}\) induces an \(X_2\) in G, which cannot be the case.

To prove statements (3) and (4), consider a graph G induced by the set \(U \cup W\), where

$$\begin{aligned} U = A[i-2,i+2] \quad \text {and} \quad W = B[i-2,i+2]. \end{aligned}$$

Since any edge with two endpoints in U (or two endpoints in W) could be extended by some vertices from \(\{c_{i-2},c_{i-1},c_{i},c_{i+1},c_{i+2}\}\) to an odd cycle of size \(\leqslant 7\) in G, the graph \(G[U \cup W]\) is bipartite with bipartition classes U and W.

To see that (3) holds, first note that \(B_i \subseteq N(u)\) by statement (2). Therefore, suppose that u has a neighbor v in the set \(V \setminus (U \cup W)\).

Consider the case when \(v \in A_j\) for some \(j \notin [i-2,i+2]\). Since \(N(u) \cap C = \{c_{i-1},c_{i+1}\}\) and \(N(v) \cap C = \{c_{j-1},c_{j+1}\}\), uv and the vertices between \(c_{j+1}\) and \(c_{i-1}\) in C as well as uv and the vertices between \(c_{i+1}\) and \(c_{j-1}\) in C induce cycles in G of size \(\leqslant m-2\). Since \(|C| \geqslant 10\), at least one from these cycles has size \(\geqslant 6\), and as such it cannot occur in G.

So suppose \(v \in B_j\) for some \(j \notin [i-2,i+2]\). Since \(N(v) \cap C = \{c_j\}\), uv and the vertices between \(c_{i+1}\) and \(c_j\) in C as well as uv and the vertices between \(c_{j}\) and \(c_{i-1}\) in C induce holes in G of size \(\leqslant m-2\), and as such they cannot occur in G. So, \(N(u) \subseteq W\), which completes the proof of statement (3).

Statement (4) is proved by similar arguments. \(\square \)

Proposition 3 asserts that all the neighbors of the vertices from \(A_i\) and from \(B_i\) are contained in the set \(B[i-2,i+2]\) and \(A[i-2,i+2]\), respectively. The next proposition describes the relations that hold between the neighborhoods of the vertices from \(B[i-2,i+2]\) restricted to the set \(A_i\) and between the neighborhoods of the vertices from \(A[i-2,i+2]\) restricted to the set \(B_i\).

Proposition 4

Let \(i \in [m-1]\). For \((i \pm 2,i \pm 1) \in \{(i-2,i-1),(i+2,i+1)\}\), the following hold:

  1. (1)

    For every \(w,w' \in B_{i \pm 2} \cup A_{i \pm 1}\) the sets \(N(w) \cap A_i\) and \(N(w') \cap A_i\) are comparable.

    Moreover, if \(w \in B_{i \pm 2}\) and \(w' \in A_{i \pm 1}\), then \(N(w) \cap A_i \subseteq N(w') \cap A_i\).

  2. (2)

    For every \(u,u' \in A_{i \pm 2} \cup B_{i \pm 1}\) the sets \(N(u) \cap B_i\) and \(N(u') \cap B_i\) are comparable.

    Moreover, if \(u \in A_{i \pm 2}\) and \(u' \in B_{i \pm 1}\), then \(N(u) \cap B_i \subseteq N(u') \cap B_i\).

Proof

To prove (1), we consider the case \((i \pm 2,i \pm 1) =(i-2,i-1)\), as the other one follows by symmetry. Suppose that \(w,w' \in B_{i-2} \cup A_{i-1}\) are such that neither \(N(w) \cap A_i \subseteq N(w') \cap A_i\) nor \(N(w') \cap A_i \subseteq N(w) \cap A_i\) holds. It means that there are \(u,u' \in A_i\) such that \(wu \in E\), \(w'u' \in E\), \(wu' \notin E\), and \(w'u \notin E\). Since \(w,w' \in B_{i-2} \cup A_{i-1}\), we have \(c_{i-2}w,c_{i-2}w' \in E\) and \(c_{i-4}w, c_{i-3}w, c_{i-4}w', c_{i-3}w' \notin E\). Furthermore, \(ww'\notin E\) and \(uu'\notin E\) as G contains no triangle. Consequently, the set \(\{c_{i-3},w,w', c_{i-4},c_{i-2},u,u'\}\) induces a copy of \(T_2\) in G, which cannot be the case. Moreover, if \(w \in B_{i-2}\), \(w' \in A_{i-1}\), then since \(c_i \in (N(w') \cap A_i) \setminus (N(w) \cap A_i)\), the latter statement holds.

To show (2), we again only consider the case \((i \pm 2,i \pm 1) =(i-2,i-1)\). Suppose that \(u,u' \in A_{i-2} \cup B_{i-1}\) are such that neither \(N(u') \cap B_i \subseteq N(u) \cap B_i\) nor \(N(u) \cap B_i \subseteq N(u') \cap B_i\) holds. It means that there are \(w,w' \in B_i\) such that \(uw,u'w' \in E\) and \(u'w, uw' \notin E\). Since \(u,u' \in A_{i-2} \cup B_{i-1}\), we have \(uc_{i-1},u'c_{i-1} \in E\) and \(uc_{i+1},u'c_{i+1} \notin E\). Furthermore, \(uu'\notin E\) and \(ww'\notin E\) as G contains no triangle. Hence, the set \(\{c_{i-1}, w, w', c_{i+1},u,c_i,u'\}\) induces a copy of \(X_3\) in G, which cannot be the case.

To see the second part of the statement, assume that \(N(u) \cap B_i \nsubseteq N(u') \cap B_i\) for some \(u \in A_{i-2}\), \(u' \in B_{i-1}\). That is, there is \(w \in B_i\) such that \(uw \in E\) and \(u'w \notin E\). In particular, it means that \(u\ne c_{i-2}\). Note that \(uc_{i-1},u'c_{i-1} \in E\). Consequently, the set \(\{c_{i-3},c_{i-2},c_{i-1},c_i,u,u',w\}\) induces a copy of \(X_3\) in G, which is a contradiction. \(\square \)

Proposition 4 allows us to order vertices of \(A_i\) based on two properties. We now define relation \(<_{A_i}\) which combines them and we show that \(<_{A_i}\) is a partial order (see Fig. 6 for an illustration). We define for every \(u,u' \in A_i\):

$$\begin{aligned} u <_{A_i} u' \text { iff } \begin{array}{l} \text {there is }w \in B_{i-2} \cup A_{i-1} \text { such that }u \in N(w)\text { and }u' \notin N(w),\text { or} \\ \text {there is }w \in A_{i+1} \cup B_{i+2}\text { such that }u' \in N(w)\text { and }u \notin N(w), \end{array} \end{aligned}$$

Similarly, we define a relation \({<_{B_i}}\) for every \(w,w' \in B_i\):

$$\begin{aligned} w <_{B_i} w' \text { iff } \begin{array}{l} \text {there is }u \in A_{i-2} \cup B_{i-1}\text { such that }w \in N(u) \text { and }w' \notin N(u), \text { or} \\ \text {there is }u \in B_{i+1} \cup A_{i+2}\text { such that }w' \in N(u) \text { and }w \notin N(u). \end{array} \end{aligned}$$
Fig. 6
figure 6

The neighborhoods of the vertices from \(B_{i-2} \cup A_{i-1} \cup A_{i+1} \cup B_{i+2}\) restricted to \(A_i\). We have \(u_1<_{A_i} \{u_2,u_3\}<_{A_i} u_4<_{A_i} u_5<_{A_i} u_6 <_{A_i} u_7\)

Proposition 5

The following statements hold for every \(i \in [m-1]\):

  1. (1)

    \((A_i,{<_{A_i}})\) is a strict partial order. Moreover, \(u,u' \in A_i\) are incomparable in \((A_i,{<_{A_i}})\) if and only if \(N(u) = N(u')\).

  2. (2)

    \((B_i,{<_{B_i}})\) is a strict partial order. Moreover, \(w,w' \in B_i\) are incomparable in \((B_i,{<_{B_i}})\) if and only if \(N(w) = N(w')\).

Proof

Let \(i \in [m-1]\) be fixed. To prove that \((A_i,<_{A_i})\) is a strict partial order, we need to show that \(<_{A_i}\) is irreflexive and transitive. The irreflexivity follows from the definition, in aim to show transitivity, we first prove that \(<_{A_i}\) is antisymmetric. Suppose for a contrary that there are \(u,u' \in A_i\) such that \(u <_{A_i} u'\), and \(u' <_{A_i} u\). Suppose \(u <_{A_i} u'\) is witnessed by a vertex \(w \in B_{i-2} \cup A_{i-1}\) such that \(u \in N(w)\) and \(u' \notin N(w)\); the other case \(w \in A_{i+1} \cup B_{i+2}\) is analogous. By Proposition 4.(1), there is no \(w' \in B_{i-2} \cup A_{i-1}\) such that \(u' \in N(w')\) and \(u \notin N(w')\). Hence, since \(u' <_{A_i} u\), there must be a vertex \(w' \in A_{i+1} \cup B_{i+2}\) such that \(u \in N(w')\) and \(u' \notin N(w')\). We have \(uc_{i+1}, u'c_{i+1} \in E\) and \(uc_{i+2},u'c_{i+2}, uc_{i+3},u'c_{i+3} \notin E\) as \(\{u,u'\} \subseteq A_i\). We have also \(wc_{i+1},wc_{i+2},wc_{i+3},w'c_{i+1},w'c_{i+3} \notin E\) and \(w'c_{i+2} \in E\) as \(w \in B_{i-2} \cup A_{i-1}\) and \(w' \in A_{i+1} \cup B_{i+2}\). Moreover, \(uu', ww'\notin E\), by Proposition 3. Consequently, the set \(\{w,w',c_{i+1},c_{i+3}, u,u',c_{i+2}\}\) induces a copy of \(X_2\) in G, which cannot be the case.

To show transitivity, suppose for a contrary that there are vertices \(u,u',u''\in A_i\) such that \(u <_{A_i} u'\) and \(u' <_{A_i} u''\), but \(u <_{A_i} u''\) does not hold. Suppose \(u <_{A_i} u'\) is witnessed by a vertex \(w \in B_{i-2} \cup A_{i-1}\) such that \(u \in N(w)\) and \(u' \notin N(w)\); the other case \(w \in A_{i+1} \cup B_{i+2}\) is symmetric. We have \(u'' \in N(w)\) as otherwise \(u <_{A_i} u''\), by definition. Suppose \(u' <_{A_i} u''\) is witnessed by a vertex \(w' \in B_{i-2} \cup A_{i-1} \cup A_{i+1} \cup B_{i+2}\). Note that if \(w' \in B_{i-2} \cup A_{i-1}\), then \(u''\notin N(w')\) and \(u' \in N(w')\), which enforces also \(u \in N(w')\) as \(u <_{A_i} u'\) and we already proved that \(<_{A_i}\) is antisymmetric. Thus, \(u \in N(w')\) and \(u'' \notin N(w')\), which shows \(u <_{A_i} u''\). Hence, we must have \(w' \in A_{i+1} \cup B_{i+2}\), and so \(u' \notin N(w')\) and \(u'' \in N(w')\). Moreover, \(u \in N(w')\) as otherwise \(u <_{A_i} u''\). As \(\{u',u''\} \subseteq A_i\), \(w \in B_{i-2} \cup A_{i-1}\), and \(w' \in A_{i+1} \cup B_{i+2}\), we have \(u'u'', ww'\notin E\), by Proposition 3. Consequently, \(\{w, w',c_{i+1},c_{i+3},u',u'',c_{i+2}\}\) induces a copy of \(X_2\) in G, which is not possible. We conclude that \((A_i,<_{A_i})\) is a strict partial order.

By definition, if \(N(u)=N(u')\), then u and \(u'\) are incomparable in \({(A_i,<_{A_i})}\). Hence, for the second statement of (1), it is enough to show that \(N(u)\ne N(u')\) implies that u and \(u'\) are comparable in \((A_i,<_{A_i})\). Let w be a vertex such that \(wu \in E\) and \(wu' \notin E\). By Proposition 3.(2) and (3), \(w \in B_{i-2} \cup A_{i-1} \cup A_{i+1} \cup B_{i+2}\). However, if \(w \in B_{i-2} \cup A_{i-1}\) then \(u <_{A_i} u'\) and if \(w \in A_{i+1} \cup B_{i+2}\) then \(u' <_{A_i} u\), by definition. Hence, u and \(u'\) are comparable in \(<_{A_i}\).

The proof of (2) is similar. For antisymmetry, suppose that we have \(w, w' \in B_i\) such that \(w <_{B_i} w'\) and \(w' <_{B_i} w\). Let \(w <_{B_i} w'\) and \(w' <_{B_i} w\) be witnessed by u and \(u'\) from \(A_{i-2} \cup B_{i-1} \cup B_{i+1} \cup A_{i+2}\), respectively. Analogously to (1), by Proposition 4.(2), we can assume that \(u \in A_{i-2} \cup B_{i-1}\) and \(u' \in B_{i+1} \cup A_{i+2}\) and \(uw,u'w \in E\), \(uw',u'w' \notin E\). Observe that the set \(\{c_{i-1},w,w',c_{i+1},u,c_i,u'\}\) induces a copy of \(X_3\) in G, a contradiction.

For transitivity of \(<_{B_i}\), suppose that for some \(w,w'\), and \(w'' \in B_i\) we have \(w <_{B_i} w'\) and \(w' <_{B_i} w''\), but \(w <_{B_i} w''\) does not hold. By symmetry of the proof of (1), we reach the case \(u \in A_{i-2} \cup B_{i-1}\) and \(u' \in B_{i+1} \cup A_{i+2}\), \(uw, uw'',u'w,u'w'' \in E\) and \(uw',u'w' \notin E\). Then, one can easily check that the set \(\{w',w'',c_{i+1},u,c_i,u',c_{i+2}\}\) induces a copy of \(X_2\) in G, a contradiction.

Now, assume that \(N(w)\ne N(w')\). Without loss of generality assume that there exists \(u \in A_{i-2} \cup B_{i-1} \cup B_{i+1} \cup A_{i+2}\) such that \(u \in N(w) \setminus N(w')\). Analogously as before, observe that if \(u \in A_{i-2} \cup B_{i-1}\) then \(w <_{B_i} w'\) and if \(u \in B_{i+1} \cup A_{i+2}\) then \(w' <_{B_i} w\). Therefore, w and \(w'\) are comparable, which finishes the proof. \(\square \)

Finally, for every \(i \in [m-1]\) we order arbitrarily the elements inside every antichain of \((A_i,{<_{A_i}})\) and of \((B_i,{<_{B_i}})\), obtaining strict linear orders \((A_i,{<_{A_i}})\) and \((B_{i},{<_{B_i}})\). We introduce a binary relation \(\prec \) defined on the set V, such that \(v \prec v'\) for \(v,v' \in V\) if one of the following conditions holds for some \(i \in [m-1]\):

  • \(v,v' \in A_i\), \(v <_{A_i} v'\), and \(v,v'\) are consecutive in \((A_i,{<_{A_i}})\),

  • \(v,v' \in B_i\), \(v <_{B_i} v'\), and \(v,v'\) are consecutive in \((B_i,{<_{B_i}})\),

  • v is the maximum of \((A_i,{<_{A_i}})\) and \(v'\) is the minimum of \((B_{i+1},{<_{B_{i+1}}})\),

  • v is the maximum of \((B_i,{<_{B_i}})\) and \(v'\) is the minimum of \((A_{i+1},{<_{A_{i+1}}})\).

Informally, to get an embedding of G into a cylinder (the shortest hole is even) or into a Möbius strip (the shortest hole is odd) which locally satisfies the adjacency and the enclosure properties, we place the vertices \(v,v'\) satisfying \(v \prec v'\) next to each other, v before \(v'\) assuming that the border of the cylinder or the Möbius strip are oriented as shown in Fig. 3. In what follows we extend \({\prec }\) relation as follows:

  • For every \(V' \subsetneq V\) by \({<_{V'}}\) we denote the transitive closure of \({\prec }\) restricted to \(V'\),

  • For \(v,v' \in V\) we set \(v <_{cl} v'\) if \(v,v' \in A[i-2,i+2]\) and \(v <_{A[i-2,i+2]} v'\) for some \(i \in [m-1]\) or \(v,v' \in B[i-2,i+2]\) and \(v <_{B[i-2,i+2]} v'\) for some \(i \in [m-1]\).

Finally, the following lemma characterizes the global structure of an almost bipartite permutation graph.

Lemma 1

Let ij be such that \(i \leqslant j\), \(|j-i| = m-3\). Let \(U = A[i,j]\) and \(W=B[i,j].\) Then \(G[U \cup W]\) is a bipartite permutation graph with bipartition classes U and W.

Moreover, \((U,{<_U})\) and \((W,{<_W})\) are strict linear orders that satisfy the adjacency and enclosure properties in \(G[U \cup W]\).

Proof

Proposition 3 asserts there is no edge between a vertex in \(V[j-1,j]\) and a vertex in \(V[i,i+1]\). In particular, \(G[U \cup W]\) is a bipartite graph and \((U,{<_U})\) and \((W,{<_W})\) are strict linear orders. Given Theorem 3.(c), to prove the lemma we need to show that \((W,{<_W})\) satisfies the adjacency and enclosure properties in \(G[U \cup W]\).

To prove the adjacency property, consider \(u\in A_k\subseteq U\) for some suitable k. Recall that by Proposition 3.(3), \(B_k\subseteq N(u) \subseteq B[k-2,k+2]\). To show that N(u) consists of consecutive vertices in W it suffices to note that:

  • if \(w\in A_{k+1}\), \(w'\in B_{k+2}\) and \(uw'\in E\) then \(uw\in E\), by Proposition 4,

  • if \(w,w'\in A_{k+1}\) (resp. \(w,w'\in B_{k+2}\)) are such that \(w <_{A_{k+1}} w'\) (resp. \(w <_{B_{k+2}} w'\)) and \(uw'\in E\), then \(uw\in E\), by Proposition 5,

and that analogous statements hold by symmetry for the part of N(u) contained in \(A_{k-1}\cup B_{k-2}\). If \(u\in B_k\subseteq U\), the case analysis is similar (one needs to swap letters A and B in the reasoning above). Therefore, the adjacency property is proved.

To show that \((W,{<_W})\) satisfies the enclosure property assume for a contradiction that there are \(w,w',w'' \in W\) and \(u,u' \in U\) such that \(N(u')\subseteq N(u)\), \(w<_{W} w' <_{W} w''\) and \(uw,uw',uw'' \in E\), \(u'w' \in E\), and \(u'w,u'w'' \notin E\).

Claim

There is \(k \in [i,j]\) such that either \(u,u' \in A_k\), or \(u,u' \in B_k\).

Proof of Claim

If \(u\in B_{k}\), then since \(N(u') \cap C \subseteq N(u) \cap C = \{c_k\}\), we have \(u' \in B_k\), so the claim holds. Therefore, assume that \(u\in A_{k}\), and suppose that \(u' \notin A_k\). Then \(N(u') \cap C \subseteq N(u) \cap C = \{c_{k-1},c_{k+1}\}\). Assuming \(u <_{U} u'\) (the other case is symmetric), we have that \(u' \in B_{k+1}\). Due to Proposition 3 and \(w' <_W w''\) we have \(w',w'' \in A[k-1,k+2]\). Moreover, as we already proved that \(N(u')\) is consecutive in \((W,<_W)\) (adjacency property), and \(c_{k+1}\in N(u')\), we have \(c_{k+1}<_W w''\). Therefore \(w''\in A_{k+1}\cup B_{k+2}\). Note that:

  • if \(w''\in B_{k+2}\), then, since \(uw''\in E\), we have that \(w'' \in N(u) \cap B_{k+2}\). However, by Proposition 4.(2), we have \(N(u) \cap B_{k+2} \subseteq N(u') \cap B_{k+2}\), so it implies that \(u'w'' \in E\), a contradiction,

  • if \(w'' \in A_{k+1}\), then by Proposition 3.(2) we would have \(u'w''\in E\), a contradiction.

This concludes the proof of claim. \(\square \)

Suppose \(u,u' \in A_k\). Since \(u'w, u'w'' \notin E\) and \(u'c_{k-1}, u'c_{k+1}\in E\), we have by adjacency property of \((W,<_{W})\) that \(w<_{W}c_{k-1}<_W c_{k+1}<_W w''\). Therefore, we must have \(w \in B_{k-2} \cup A_{k-1}\) and \(w'' \in A_{k+1} \cup B_{k+2}\). Observe that \(w''\) witnesses that \(u'<_{A_k} u\) by definition, however, w witnesses the opposite, that is \(u<_{A_k} u'\). We have a contradiction by Proposition 5.

Suppose \(u,u' \in B_k\). An analysis, which is analogous to the one in the previous case (again, it is enough to swap letters A and B in that reasoning above), gives us that we must have \(w \in A_{k-2} \cup B_{k-1}\) and \(w'' \in B_{k+1} \cup A_{k+2}\). Again, we obtain a contradiction by the definition of \(<_{B_k}\) and Proposition 5. \(\square \)

Lemma 1 provides an interesting view on classification of almost bipartite permutation graphs. Specifically, if m is even, then the graph may be drawn on a cylinder, whose boundary consists of two closed curves, one of which traverses the vertices of \(A_0, B_1, \ldots A_{m-2}, B_{m-1}\), and the second one—the vertices of \(B_0,A_1,\ldots , B_{m-2}, A_{m-1}\). If in turn m is odd, then the graph can be represented on a Möbius strip, whose boundary traverses the vertices of \(A_{0},B_{1}, \ldots , B_{m-2},A_{m-1}\) and then \(B_{0}, A_{1}, \ldots A_{m-2}, B_{m-1}\). In both cases we draw the vertices of \(A_{i}\) and of \(B_{i}\) on the opposite side of the strip according to the orders given by \(<_{A_i}\) and \(<_{B_i}\), for \(i \in [m-1]\) (recall Fig. 3).

The following definitions are taken from [27]. A hole cut of G is a vertex set \(X \subseteq V\) such that \(G - X\) is a bipartite permutation graph. Lemma 1 asserts that for every \(i \in [m-1]\) the set \(V[i,i+1]\) is a hole cut in G. A hole cut X of G is minimum if G does not have a hole cut whose size is strictly smaller than the size of X. A hole cut X of G is minimal if any proper subset of X is not a hole cut in G.

The next proposition describes the structure of every hole in G.

Proposition 6

Suppose \(C'\) is a hole of size t in G for some \(t \geqslant m\). Then, the consecutive vertices of \(C'\) can be labeled by \(c'_0,c'_1,\ldots ,c'_{t-1}\) so as the following conditions hold (the indices are taken modulo k):

  • \(c'_ic'_{i+1} \in E\) for every \(i \in [t-1]\),

  • \(c'_{i} <_{cl} c'_{i+2}\) for every \(i \in [t-1]\),

  • \(\{c'' \in C': c'_i<_{cl} c'' <_{cl} c'_{i+2}\} = \emptyset \) for every \(i \in [t-1]\).

Proof

Let \(c'_0\), \(c'_1\), \(c'_2\), \(\dots \), \(c'_{t-1}\) be consecutive vertices of \(C'\) denoted in such a way that \(c'_0<_{cl} c'_2\). We can assume it, since \(c'_0, c'_2\in N(c'_1)\), thus, by Proposition 3.(3) and (4), both \(c'_0,c'_2\) belong to \(A[\ell -2,\ell +2]\) or both belong to \(B[\ell -2,\ell +2]\) for some \(\ell \in [m-1]\).

Now, we show that if there exists \(j\in [t-1]\) such that \(c'_{j}<_{cl} c'_{j+2}\), then \(c'_{j+1}<_{cl} c'_{j+3}\). Suppose, for contradiction that \(c'_{j}<_{cl} c'_{j+2}\) and \(c'_{j+1}\nless _{cl} c'_{j+3}\). Let \(i\in [m-1]\) be such that \(c'_{j+2}\in (A_i\cup B_i)\). Similarly, as \(c'_{j+1},c'_{j+3}\in N(c'_{j+2})\), either \(c'_{j+1}, c'_{j+3} \in B[i-2,i+2]\) if \(c'_{j+2}\in A_i\) or \(c'_{j+1},c'_{j+3}\in A[i-2,i+2]\) if \(c'_{j+2}\in B_i\). In both cases Lemma 1 implies that \(<_{cl}\) restricted to \(V[i-4,i+2]\) is a strong ordering of \(G[V[i-4,i+2]]\). Moreover, \(c'_{j+1},c'_{j+3}\) are comparable in \(<_{cl}\), by Proposition 3.(3) or (4), and the definition of \(<_{cl}\). Since we assumed that \(c'_{j+1}\nless _{cl} c'_{j+3}\), we must have \(c'_{j+3}<_{cl} c'_{j+1}\), and from Theorem 3.(b) we get that \(c'_jc'_{j+3}\in E\), so \(C'\) has a chord—contradiction. Therefore \(c'_{j}<_{cl} c'_{j+2}\) implies \(c'_{j+1}<_{cl} c'_{j+3}\) for every integer j. Applying the above observation repeatedly for \(j=0,1,2,\ldots \), we get that \(c'_0<_{cl} c'_2<_{cl} c'_4<_{cl}\ldots \) and \(c'_1<_{cl} c'_3<_{cl} c'_5<_{cl}\ldots \)

For the last property, suppose for the sake of contradiction that there exists \(j\notin \{i,i+2\}\) such that \(c'_i<_{cl} c'_j <_{cl} c'_{i+2}\). Then, by Lemma 1, \(c'_jc'_{i+1}\in E\) due to the adjacency property. But then the edge \(c'_jc'_{i+1}\) is a chord in \(C'\). This completes the proof. \(\square \)

The structure of holes described above asserts that for every \(i \in [m-1]\) the sets \(A[i-2,i+2]\) and \(B[i-2,i+2]\) are hole cuts. We use this observation to prove the following statement about minimal hole cuts in G.

Proposition 7

Every minimal hole cut X in G is fully contained in the set \(V[i-2,i+2]\) for some \(i \in [m-1]\).

Proof

Let X be a minimal hole cut. Since X is minimal, we can choose elements \(z_1,x_1,x_2,z_2\) in V such that the following conditions hold:

  • we have \(z_1 \prec x_1 \leqslant _{cl} x_2 \prec z_2\), the set \(X' = \{x: x_1 \leqslant _{cl} x \leqslant _{cl} x_2\}\) is non-empty and is contained in X, and the elements \(z_1,z_2\) are not in X.

Note that either \(\{z_1,z_2\} \cup X' \subseteq B[i-2,i+2]\) or \(\{z_1,z_2\} \cup X' \subseteq A[i-2,i+2]\) for some \(i \in [m-1]\). Otherwise, we have \(B[j,j+3] \subseteq X'\) or \(A[j,j+3] \subseteq X'\) for some \(j \in [m-2]\). However, Proposition 6 and Proposition 3.(3) and (4) imply that the sets \(A[j,j+3]\) and \(B[j,j+3]\) are hole cuts for every \(j \in [m-1]\). Otherwise, the set \(A[j,j+3]\) (\(B[j,j+3]\)) is contained in the neighbourhood of some vertex of a hole avoiding \(A[j,j+3]\) (\(B[j,j+3]\), respectively) in G and the neighborhood of this vertex intersects also \(B_{j-1}\) and \(A_{j+4}\) (\(A_{j-1}\) and \(B_{j+4}\), respectively), which cannot be the case due to Proposition 3.(3) and (4). So, we have either \(B[j,j+3] = X' = X\) or \(A[j,j+3] = X' = X\) as X is a minimal hole cut. But then, we have \(X \subseteq V[j,j+3]\), which completes the proof of our claim.

Therefore, for the rest of the proof we assume \(\{z_1,z_2\} \cup X' \subseteq B[i-2,i+2]\); the other case is proved similarly. Moreover, we may assume that i is picked such that:

  • \(z_1 \in B[i-2,i]\), \(z_2 \in B[i,i+2]\), and \(X' \subset B[i-2,i+2]\).

See Fig. 7 for an illustration.

Fig. 7
figure 7

Illustration of the proof: the cycle \(C'\) is marked with a dashed line. The set \(X'\) is shaded

Suppose \(Y'\) is the set consisting of all the neighbors of both \(z_1\) and \(z_2\); that is, \(Y' = N(z_1) \cap N(z_2)\). Clearly, we have \(Y' \subset A[i-2,i+2]\). To complete the proof of the proposition we show that:

  • every element of \(Y'\) is a member of X,

  • \(X' \cup Y'\) is a hole cut in G.

Then, since \(X' \subseteq X\), we have \(X' \cup Y' = X\) by minimality of X and consequently \(X \subset V[i-2,i+2]\). So, it remains to prove the claims about the set \(Y'\).

Suppose we have \(y \in Y'\) such that \(y \notin X\). We fix some \(x \in X'\), clearly, since X is a minimal hole cut, there is a hole \(C'\) in \(G - (X \setminus \{x\})\). Note that \(C'\) must contain x. Suppose \(c'_0,\ldots ,c'_{\ell -1}\) for some \(\ell \geqslant 9\) are consecutive vertices in \(C'\) chosen such that \(c'_j <_{cl} c'_{j+2}\) for every \(j \in [\ell -1]\) (indices are taken modulo \(\ell \)). Now we pick \(p,q \in [\ell -1]\) such that \(c'_p <_{cl} z_1 \leqslant _{cl} c'_{p+2}\) and \(c'_q \leqslant _{cl} z_2 <_{cl} c'_{q+2}\). Since \(x \in C'\), we have \(c'_{p+2} \leqslant _{cl} x\) and \(x \leqslant _{cl} c'_{q}\). Note that \(c'_{p+1}\) is adjacent to \(z_1\) and \(c'_{q+1}\) is adjacent to \(z_2\) due to the adjacency property. Next we replace in \(C'\) all the vertices between \(c'_{p+2}\) and \(c'_q\) (this set includes x) with the vertices \(z_1,y,z_2\) and we obtain a cycle \(C''\) containing no elements from X. Clearly, we can easily find a hole among the elements from \(C''\) that avoids all the elements from X. This yields a contradiction as X is a hole cut.

To prove the second claim, suppose there is a hole \(C'\) in \(G - (X' \cup Y')\). By Proposition 6 there are \(c'_1,c'_2,c'_3 \in C'\) such that \(c'_1<_{cl} X' <_{cl} c'_3\) and \(c'_1,c'_3 \in N(c'_2)\). However, since \(c'_1 \leqslant _{cl} z_1 <_{cl} z_2 \leqslant _{cl} c'_3\) and \(c'_1,c'_3 \in N(c'_2)\), we have \(z_1 \in N(c'_2)\) and \(z_2 \in N(c'_2)\). So, we have \(c'_2 \in Y'\), which is a contradiction. \(\square \)

4 Proof of Theorem 1

The aim of this section is to provide a complete proof of Theorem 1 using structural results from the previous section. Let us start by showing that the Bipartite Permutation Vertex Deletion problem can be decided in polynomial time on almost bipartite permutation graphs.

Lemma 2

Let (Gk) be an instance of Bipartite Permutation Vertex Deletion where G is an n-vertex almost bipartite permutation graph. Then Bipartite Permutation Vertex Deletion can be decided in time \({\mathcal {O}}(n^6)\).

Proof

If G is a bipartite permutation graph, (Gk) is a yes-instance, thus, we are done in this case. If G is not connected, we can consider each connected component independently and, at the end, we compare k with the total number of deleted vertices over all components. Let \(G'\) be a connected r-vertex component of G such that \(G'\) is not a bipartite permutation graph (otherwise, clearly, no vertex needs to be deleted). Let \(C=\{c_0,\dots ,c_{m-1}\}\) be a shortest hole in \(G'\) (it exists as \(G'\) is not a bipartite permutation graph). It can be found in time \({\mathcal {O}}(r^6)\) as follows. We iterate over all possible four-element subsets \(S=\{v_1,v_2,v_3,v_4\}\) of \(V(G')\). For these S for which \(G'[S]\) is an induced \(P_4\), with consecutive vertices \(v_1,v_2,v_3,v_4\), we construct a graph \(\widetilde{G'}\) by removing the vertices from \((N(v_2) \cup N(v_3)) \setminus \{v_1,v_4\}\) (note that \(v_2\) and \(v_3\) also get removed). Then we find a shortest \(v_1\)-\(v_4\)-path in \(\widetilde{G'}\) in time \({\mathcal {O}}(r^2)\).

By Proposition 7, every minimal hole cut X in \(G'\) is contained in the set \(V'=V_{G'}[i-2,i+2]\) for some \(i \in [m-1]\). Therefore, we may check all the possibilities where a minimal cut is contained. For every i, we run an algorithm for finding a maximum flow in the following digraph \(H_i\).

Digraph \(H_{i}\) has the vertex set \(V'\times \{\mathsf {in},\mathsf {out}\}\cup \{s,t\}\) and arc set consisting of:

  • all arcs of the form \((u,\mathsf {out})(v,\mathsf {in})\), where uv is an edge of \(G'[V']\),

  • \(s(v,\mathsf {in})\) if there exists \(u\in V_{G'}[i-4,i-3]\) such that uv is an edge of \(G'\),

  • \((u,\mathsf {out})t\) if there exists \(v\in V_{G'}[i+3,i+4]\) such that uv is an edge of \(G'\),

  • \((u,\mathsf {in})(u,\mathsf {out})\) for all \(u\in V'\).

Set capacities of arcs of the form \((u,\mathsf {in})(u,\mathsf {out})\) to 1 and capacities of all the remaining arcs to \(\infty \) (practically \(|V_{G'}|\)). It is readily seen that minimum (st)-cut in the defined network \(H_i\) corresponds to minimum hole cut in \(G'[V']\) (arc of unit capacity \((u,\mathsf {in})(u,\mathsf {out})\) naturally corresponds to the vertex u of \(G'\)).

Therefore it remains to apply classical max-flow algorithm to each \(H_i\) for \(i\in [m-1]\) and remember the smallest size \(k_{G'}\) of minimal (st)-cuts. This can be performed in time \({\mathcal {O}}(m\cdot (|V'|+2)\cdot (|E_{G'[V']}|+2|V'|)^2)={\mathcal {O}}(r^6)\) [11]. Finally, (Gk) is a yes-instance if and only if the sum of remembered sizes \(k_{G'}\) over the all considered connected components \(G'\) is at most k. Clearly, the total running time is \({\mathcal {O}}(n^6)\). \(\square \)

We now propose the algorithm. Given an n-vertex graph \(G=(V,E)\) and number k, we want to answer the Bipartite Permutation Vertex Deletion problem. We say that (Gk) is the initial instance. We split our algorithm into two parts. The first part consists of a branching algorithm for deletion to almost bipartite permutation graphs. The output of the first part is a set of instances \((G',k')\) where \(G'\) is an almost bipartite permutation graph and \(0\le k'\le k\) (or no-answer is no such instance exists) such that the initial instance (Gk) is a yes-instance if and only if at least one of these instances is a yes-instance. In the second part, the algorithm runs an \({\mathcal {O}}(n^6)\)-time algorithm for Bipartite Permutation Vertex Deletion for each instance \((G',k')\) output by the first phase.

Let us start with the first part. We say that \(X \subseteq V\) is a forbidden set if G[X] is isomorphic to one of the graphs: \(K_3, T_2, X_2, X_3, C_5, C_6, C_7, C_8, C_9\). We define the following rule.

  1. Rule

    : Given an instance (Gk), \(k\ge 1\), and a minimal forbidden set X, branch into |X| instances, \((G - v, k - 1)\) for each \(v \in X\).

Starting with the initial instance, the algorithm applies the rule exhaustively. In other words, the algorithm forms a branching tree with leaves corresponding to instances \((G',k')\) where \(k'=0\) or \(G'\) is an almost bipartite permutation graph. Clearly, as at least one vertex from each forbidden set must be removed from G, the initial instance is a yes-instance if and only if at least one of the leaves is a yes-instance.

The algorithm continues to the second part only with such leaves \((G',k')\) that \(G'\) is an almost bipartite permutation graph (as otherwise, the leaf is no-instance). It runs the algorithm described in Lemma 2 to find if \(G'\) can be transformed into a bipartite permutation graph by using at most \(k'\) vertex deletions. It either finds a yes-instance or concludes after checking all the instances that there is no solution; that is, the initial instance is a no-instance.

We note that such a branching into a bounded number of smaller instances is a standard technique, see e.g., [27] for more details.

We now analyze the running time of the whole algorithm. In the first part, observe that the branching tree has depth at most k and has at most \({9^k}\) leaves, as k decreases by one whenever the algorithm branches and each of the listed forbidden subgraphs has at most nine vertices. Therefore the total number of nodes in the branching tree is \({\mathcal {O}}(9^k)\). Moreover, in each node \((G'',k'')\) the algorithm works in time \({\mathcal {O}}(n^9)\) as it checks if \(G''\) contains a forbidden set of size at most 9. So, the first part works in time \({\mathcal {O}}(9^k \cdot n^9)\). In the second part, the algorithm does a work \({\mathcal {O}}(n^6)\) in each of at most \(9^k\) leaves, by Lemma 2. Thus, the second part works in time \({\mathcal {O}}(9^k \cdot n^6)\). We conclude that the total running time of our algorithm for Bipartite Permutation Vertex Deletion is \({\mathcal {O}}(9^k\cdot n^9)\).

5 Proof of Theorem 2

In this section, we provide a proof of Theorem 2. The idea of the algorithm is very similar to the \(\mathsf {FPT}\) algorithm described in Sect. 4.

Let \(G=(V,E)\) be a graph and let \(Y\subseteq V\) be a subset of vertices of G such that \(G-Y\) is a bipartite permutation graph. We want to construct a set \(Z\subseteq V\) in polynomial time such that \(G-Z\) is a bipartite permutation graph and \(|Z|\leqslant 9|Y|\). We construct Z as follows. We start with \(Z=\emptyset \). Then, as long as \(G-Z\) contains a set X isomorphic to one of \(K_3, T_2, X_2, X_3, C_5, C_6, C_7, C_8, C_9\) we add all vertices of X to Z. Observe that \(Y\cap X \ne \emptyset \) and \(|X|\leqslant 9\).

After this step \(G-Z\) is an almost bipartite permutation graph. Note that \(|Z|\leqslant 9|Z\cap Y|\). We find a shortest hole \(C=\{c_0, \dots , c_{m-1}\}\) in \(G-Z\) and find a minimum hole cut X as described in Sect. 4. Since \((Y-Z)\) is a hole cut in \(G-Z\) we have \(|X|\leqslant |Y-Z|\). We add X to Z. Observe that \(G-Z\) is a bipartite permutation graph.

Since \(K_3, T_2, X_2, X_3, C_5, C_6, C_7, C_8, C_9\) have at most 9 vertices, we have that \(|Z|\leqslant 9|Y|\). This implies that the above algorithm is a 9-approximation algorithm. It runs in polynomial time because finding small forbidden subgraphs can be done in polynomial time and finding a minimum hole cut in an almost bipartite permutation graph can be done in polynomial time.

6 Conclusion

In this paper we investigate for the first time the modification problems in graph classes related to partial orders. Our main result says that the bipartite permutation vertex deletion problem is fixed parameter tractable. We leave open the following two questions that inspired our research.

Problem 1

What is the parameterized status of the vertex deletion problems to the class of permutation graphs and to the class of co-comparability graphs?

We recall that, due to the result of Lewis and Yannakakis [20], both of these problems are \(\mathsf {NP}\)-complete. Problem 1 appears to be difficult; in particular, in contrast to bipartite permutation graphs, in which sufficiently large forbidden structures are just cycles, arbitrarily large forbidden structures for permutation graphs and co-comparability graphs may belong to several different infinite families of graphs. One of the most important results of our work is the description of the structure of almost bipartite permutation graphs, which are defined as graphs which do not induce small graphs from the list of forbidden structures for bipartite permutation graphs. In a similar fashion we can define the class of almost permutation and almost co-comparability graphs. Although the families of forbidden structures for permutation graphs and co-comparability graphs are quite complex, the next two questions seem very natural in order to solve Problem 1.

Problem 2

What is the structure of almost permutation and almost co-comparability graphs?

We are aware that the two problems mentioned above can be quite difficult. Therefore, it is worth considering intermediate problems that may be easier to attack. One of the proposed simplifications relies on the transition from the world of graphs to the world of posets. The following vertex deletion into two-dimensional posets problem seems very natural in the context of our research: we are given in the input a poset P and a number k and we ask whether we can delete at most k points from P so that the remaining points induce a two-dimensional poset in P.

Problem 3

What is the parameterized status of the vertex deletion into two-dimensional poset problem?

Since permutation graphs are co-comparability graphs of two-dimensional posets and since permutation graphs are both comparability and co-comparability graphs, the vertex deletion into two-dimensional poset problem is equivalent to the vertex deletion into co-comparability graph (or into permutation graph) problem if we assume that only comparability graphs can be given in the input. The class of two-dimensional posets is very well understood; in particular, the list of minimal forbidden structures for this class of posets, which is still infinite, is known (obtained independently by Trotter and Moore [26] and by Kelly [18]). Of course, it is natural to ask the following question:

Problem 4

What is the structure of almost two-dimensional posets?

Since the comparability graphs of posets do not contain odd holes of size \(\geqslant 5\), we know the structure of almost two-dimensional posets that are bipartite. Indeed, these are the posets whose comparability graphs are almost bipartite permutation graphs embeddable into cylinder stripes. The last problem we want to ask is as follows:

Problem 5

Is there a polynomial kernel for the bipartite permutation vertex deletion problem?

A positive answer to this question obtained by indicating so-called irrelevant vertices may give some hope to solve Problem 1 with the use of irrelevant vertex technique.