Keywords

1 Introduction

A chain graph is a bipartite graph such that the neighbourhoods of the vertices in each part of its bipartition form a chain with respect to the inclusion relation. The class of chain graphs appeared in the literature under various names such as difference graphs [8] or half-graphs [5]. In model theory, half-graphs appear as an instance of the order property [17]. The class of chain graphs is closely related to one more well-studied class of graphs, known as threshold graphs, and together they share many nice and important properties. In particular,

  • chain graphs have bounded clique-width (and even linear clique-width), which implies polynomial-time solutions for a variety of algorithmic problems that are generally NP-hard;

  • chain graphs are well- (and even better-) quasi-ordered under induced subgraphs. This is because another important parameter, graph lettericity, is bounded for chain graphs [22];

  • chain graphs admit an implicit representation, which in turn implies a small induced-universal graph for the class. More specifically, there is a chain graph with 2n vertices containing all n-vertex chain graphs as induced subgraphs [14].

In the terminology of forbidden induced subgraphs, the class of chain graphs is precisely the class of \(2P_2\)-free bipartite graphs, i.e., bipartite graphs that do not contain the disjoint union of two copies of \(P_2\) as an induced subgraph (\(P_n\) denotes the chordless path on n vertices).

In the present paper, we study a class of bipartite graphs that forms an extension of chain graphs defined by relaxing the chain property of the neighbourhoods in the following way. We say that a linear ordering \((a_1,\ldots ,a_\ell )\) of vertices is good if for all \(i<j\), the neighbourhood of \(a_j\) contains at most 1 non-neighbour of \(a_i\). We call a bipartite graph G a quasi-chain graph if the vertices in each part of its bipartition admit a good ordering. Alternatively, quasi-chain graphs are bipartite graphs that do not contain an “unbalanced” induced copy of \(2P_3\). To explain what we mean by this, we observe that \(2P_3\) admits two bipartitions: one with parts of equal size (balanced) and the other with parts of different sizes (unbalanced). In the unbalanced bipartition, one of the parts does not admit a good ordering and hence quasi-chain graphs are free of unbalanced \(2P_3\). On the other hand, if a bipartite graph G does not contain an unbalanced induced copy of \(2P_3\), then by ordering the vertices in each part in a non-increasing order of their degrees we obtain a good ordering, i.e., G is a quasi-chain graph.

The class of quasi-chain graphs is substantially richer and more complex than the class of chain graphs. In particular, it is not well-quasi-ordered by induced subgraphs [13] and the clique-width is not bounded in this class [15]. To emphasize the complex nature of this class, in Sect. 2 we establish a bijection f between the class of all permutations and a subclass of quasi-chain graphs such that a permutation \(\pi \) contains a permutation \(\rho \) as a pattern if and only if the graph \(f(\pi )\) contains the graph \(f(\rho )\) as an induced subgraph. Together with the NP-completeness of the pattern matching problem for permutations this implies the NP-completeness of the induced subgraph isomorphism problem for quasi-chain graphs.

In spite of the more complex structure, the quasi-chain graphs inherit some attractive properties of chain graphs. To show this, in Sect. 3 we propose a structural characterisation that describes any quasi-chain graph as the symmetric difference of two graphs Z and H, where Z is a chain graph and H is a graph of vertex degree at most 2. This characterisation allows us to prove that quasi-chain graphs admit an implicit representation (Sect. 4) and that some algorithmic problems that are NP-complete for general bipartite graphs admit polynomial-time solutions when restricted to quasi-chain graphs (Sect. 5).

All graphs in this paper are simple, i.e., undirected, with neither loops nor multiple edges. The vertex set and the edge set of a graph G are denoted V(G) and E(G), respectively. The neighbourhood of a vertex \(v\in V(G)\) is the set of vertices adjacent to v. We denote the neighbourhood of v in the graph G by \(N_G(v)\) and omit the subscript if it is clear from the context. The subgraph of G induced by a set \(U\subseteq V(G)\) is denoted G[U].

A bipartite graph \(G=(V,E)\) given together with a bipartition \(V=A\cup B\) is denoted \(G=(A,B,E)\). Once such a bipartition has been fixed, we may define the bipartite complement \(\widetilde{G}=(A,B,E')\) of G, in which two vertices \(a\in A\) and \(b\in B\) are adjacent if and only if they are not adjacent in G (that is, \(E' = (A \times B) - E)\).

2 Quasi-chain Graphs and Permutations

Given two permutations \(\pi =(\pi (1), \ldots , \pi (n))\) and \(\rho =(\rho (1), \ldots , \rho (m))\), we will write \(\pi \subseteq \rho \) to indicate that \(\pi \) is contained in \(\rho \) as a pattern, i.e., there is an order-preserving injection \(e: \{1,2,\ldots ,n\}\rightarrow \{1,2,\ldots ,m\}\) such that \(\pi (i)<\pi (j)\) if and only if \(\rho (e(i))< \rho (e(j))\) for all \(1 \le i < j \le n\). The pattern containment relation on permutations is the subject of a vast literature, see, e.g., the book [12] and the references therein. By mapping each permutation to its permutation graph, we transform the pattern containment relation on permutations into the induced subgraph relation on graphs. This mapping, however, is not injective, as it can map different permutations to the same (up to an isomorphism) graph. In the present section we propose an alternative mapping from permutation to graphs: we map permutations to quasi-chain graphs, in such a way that two permutations are comparable if and only if their images are comparable. To make this mapping injective, we require the quasi-chain graphs to be coloured. That is, we will assume that every quasi-chain graph is given together with a partition of its vertex set into an independent set A of white vertices and an independent set B of black vertices and we will write \(G\subseteq H\) to indicate that G is a coloured induced subgraph of H, i.e., there is an induced subgraph embedding of G into H that respects the colours. The distinction between coloured and uncoloured graphs matters, for instance, in the assignment problem.

We denote our mapping from permutations to graphs by f and define it as follows. If \(\pi =(\pi (1), \pi (2), \ldots , \pi (n))\) is an n-entry permutation, then \(f(\pi )\) is a bipartite graph with parts \(A=\{a_1, a_2, \ldots , a_{2n}\}\) and \(B=\{b_1, b_2, \ldots , b_{2n}\}\) and the following edges:

  1. (i)

    For any \(1\le i \le j \le 2n\), we have \(a_ib_j \in E(G)\).

  2. (ii)

    For any \(1\le i \le n\), we have \(a_{n+i} b_{\pi (i)} \in E(G)\).

We write \(G_\pi :=f(\pi )\) and say that \(G_\pi \) is the quasi-permutation graph of \(\pi \). Any graph G isomorphic to \(G_\pi \) for some \(\pi \) will be called a quasi-permutation graph. It follows easily from the definition that f is order-preserving, in that \(\pi \subseteq \rho \) implies \(f(\pi ) \subseteq f(\rho )\).

Claim

Any quasi-permutation graph G is a quasi-chain graph.

Proof

We observe that the edges of type (i) define a chain subgraph of G in which \(N(a_j)\subseteq N(a_i)\) for all \(1 \le i < j \le 2n\). The edges of type (ii) form a matching and therefore in the graph G we have \(|N(a_j) - N(a_i)| \le 1\) for all \(1 \le i < j \le 2n\). Similarly, \(|N(b_i) - N(b_j)| \le 1\) for all \(1 \le i < j \le 2n\) in G. This shows that A and B have good orderings, and so any quasi-permutation graph G is a quasi-chain graph.    \(\square \)

Claim

f is a bijection from the class of all permutations to the (non-hereditary) class of quasi-permutation graphs.

Proof

f is surjective by the definition of quasi-permutation graphs. Now notice that in the graph \(f(\pi )\) the degree sequence of vertices in both A and B is \((2,3,4, \ldots , n+1, n+1, n+2, \ldots , 2n)\). In particular, \(f(\pi )\) uniquely determines the size of \(\pi \).

The unique vertex of A with degree 2 is adjacent to vertices \(b_{2n}\) and \(b_{\pi (n)}\) in part B. Vertex \(b_{2n}\) has degree 2n and vertex \(b_{\pi (n)}\) has degree k, for some \(k \le n + 1\). Inspecting the value of k allows us to determine the value of \(\pi (n)\), which is \(k-1\). Similarly, the unique vertex of degree 3 has three neighbours: \(b_{2n}, b_{2n-1}\) and \(b_{\pi (n-1)}\), which allows us to determine the value of \(\pi (n-1)\). In this way, we see that \(f(\pi )\) uniquely determines \(\pi (i)\) for all \(2 \le i \le n\). But two permutations with the same number of elements cannot disagree in exactly one entry, hence the graph \(f(\pi )\) uniquely determines the permutation \(\pi \). Therefore f is injective.    \(\square \)

Lemma 1

Let \(\pi \) and \(\rho \) be two permutations with n and m entries, respectively, with \(n \le m\) and \(\pi (1) \ne n\). If \(f(\pi ) \subseteq f(\rho )\), then \(\pi \subseteq \rho \).

Proof

Assume \(f(\pi ) \subseteq f(\rho )\). We denote the vertices of \(f(\rho )\) as \(A=\{a_1, \ldots , a_{2m}\}\) and \(B=\{b_1, \ldots , b_{2m}\}\) and edges \(a_ib_j\) if either \(1 \le i \le j \le 2m\) or \(m+1 \le i \le 2m\) and \(j=\rho (i-m)\). Also, we denote the vertices of \(f(\pi )\) as \(A'=(a_1', a_2', \ldots , a_{2n}')\), and \(B'=(b_1', b_2', \ldots , b_{2n}')\) with edges \(a_i'b_j'\) if either \(1 \le i \le j \le 2n\) or \(n+1 \le i \le 2n\) and \(j=\pi (i-n)\). The mapping that embeds \(f(\pi )\) into \(f(\rho )\) as an induced subgraph will be denoted by \(a_i' \mapsto a_{e(i)}\), \(b_i' \mapsto b_{w(i)}\).

Firstly, observe that all but at most one entry from the set \(\{w(1), \ldots , w(n)\}\) are less than or equal to m. Indeed, the vertices \(b_{1}', b_{2}', \ldots , b_{n}'\) have pairwise incomparable neighbourhoods, and this must also be the case for their images; however, if \(i, j > m\), the neighbourhoods of \(b_i\) and \(b_j\) are comparable. Moreover, since \(b_{i+1}'\) has two private neighbours with respect to \(b_i'\) for any \(i \le n-1\), we must have \(w(i) < w(i+1)\) for any \(i \le n-1\), and hence we must have \(w(1)< w(2)< \ldots < w(n-1) \le m\) and \(w(n-1) < w(n)\). Similarly, we can deduce that \(m+1 \le e(n+2)<e(n+3)<\ldots <e(2n)\) with \(e(n+1)<e(n+2)\).

Now, \(a_1', a_2', \ldots , a_{n-2}'\) are adjacent to two vertices \(b'_{n-2}, b'_{n-1}\) with \(w(n-2) < w(n-1) \le m\). Therefore, we conclude that \(\{e(1), e(2), \ldots , e(n-2)\}\) must all be smaller than or equal to m. As \(a_1, a_2, \ldots , a_m\) form a chain graph together with the vertices in B, in order to have \(N(a_{e(i)})\supsetneq N(a_{e(j)})\) for \(1 \le i < j \le n-2\), we conclude that we must have \(1 \le e(1)< e(2)< \ldots < e(n-2) \le m\). To preserve correct adjacencies between \(\{a_1', \ldots , a_{n-2}'\}\) and \(\{b'_1, \ldots , b_{n-1}'\}\) we must have

$$e(1) \le w(1)<e(2) \le w(2)< \ldots< e(n-2) \le w(n-2) < w(n-1) \le m.$$

Now \(b_{w(n-1)}\) is already adjacent to \(a_{e(1)}, a_{e(2)}, \ldots , a_{e(n-2)}\), but it has to be adjacent to two more vertices, \(a_{e(n-1)}\) and \(a_{e(n+\pi ^{-1}(n-1))}\). Clearly, at least one of \(e(n+\pi ^{-1}(n-1))\) and \(e(n-1)\) must be at most \(w(n-1)\). Hence there are two cases: either both \(e(n+\pi ^{-1}(n-1))\) and \(e(n-1)\) are at most \(w(n-1)\), or one of them is at most \(w(n-1)\) and the other is at least \(m+1\), in which case \(e(n-1)\) is the one that is at most \(w(n-1)\), as \(a'_{n-1}\) has a private neighbour with respect to \(a'_{n+\pi ^{-1}(n-1)}\). In either case, we must have \(e(n-1) \le w(n-1)\). As \(a_{n-1}'\) is non-adjacent to \(b_{n-2}'\), we must also have \(w(n-2)<e(n-1)\), implying that

$$e(1) \le w(1)<e(2) \le w(2)< \ldots< e(n\,-\,2) \le w(n\,-\,2) < e(n\,-\,1) \le w(n\,-\,1) \le m.$$

By symmetry, we derive that

$$m+1 \le e(n+2) \le w(n+2)< e(n+3) \le \ldots <e(2n) \le w(2n).$$

We are only left with determining the location of the embeddings of the four vertices \(a'_n, b'_n, a'_{n+1}\), \(b'_{n+1}\). Since \(\pi (1) \ne n\), we have that \(a'_{n+1}\) is not connected to \(b'_n\), but connected to \(b'_{\pi (1)}\) (with \(\pi (1)<n\)). It follows that \(e(n+1) \ge m+1\). Clearly, for \(a_{n+1}'\) to have two private neighbours with respect to \(a_{n+2}'\) we must also have \(e(n+1) < e(n+2)\). The two private neighbours of \(a'_{n+1}\) are \(b_{\pi (1)}'\) and \(b_{n+1}'\); since \(a_{e(n+1)}\) only has one neighbour \(b_i\) with \(i < e(n + 1)\) (namely \(b_{\pi (1)}\)), the embedding of \(b_{n+1}'\) must satisfy \(e(n+1) \le w(n+1)<e(n+2)\). Now \(b_n'\), which is not adjacent to \(a_{n+1}'\) but adjacent to \(a'_{n+\pi ^{-1}(n)}\) (note \(e(n + \pi ^{-1}(n)) \ge m + 1\) since \(\pi ^{-1}(n) > 1\)) must therefore satisfy \(w(n) \le m\). As \(b_n'\) has two private neighbours with respect to \(b_{n-1}'\), we must have \(w(n-1) < w(n)\), and as above, the private neighbour \(a_n'\) of \(b_n'\) must satisfy \(w(n-1) < e(n) \le w(n)\).

Summarizing, we conclude that

$$ \begin{array}{rl} e(1) &{} \le w(1)< \ldots< e(n) \le w(n) \le m< m+1 \\ &{}\le e(n+1) \le w(n+1)< \ldots < e(2n) \le w(2n). \end{array} $$

We may now alter this embedding of \(f(\pi )\) into \(f(\rho )\) if necessary to guarantee that \(e(i)=w(i)\) for all \(i=1,2, \ldots , 2n\). Indeed, it follows from the above inequalities that, for \(1 \le i \le n\), \(a_{e(i)}\) and \(a_{w(i)}\) have the same set of neighbours among the embedded b-vertices, and similarly, for \(n + 1 \le i \le 2n\), \(b_{w(i)}\) and \(b_{e(i)}\) have the same set of neighbours among the embedded a-vertices. We may thus keep the embeddings of \(b'_1, \dots , b'_n, a'_{n + 1}, \dots , a'_{2n}\) where they are, and move the embeddings of the remaining vertices as appropriate to ensure \(e(i) = w(i)\) for \(1 \le i \le 2n\). From this altered embedding, it is easy to see that \(\pi \subseteq \rho \) as claimed (for instance, interpret the matching between \(b_1, \dots , b_m\) and \(a_{m + 1}, \dots , a_{2m}\) as a line segment intersection model for \(\rho \), and note that the intersection of this matching with the embedded graph \(f(\pi )\) gives a line segment intersection model for \(\pi \)).    \(\square \)

Lemma 1 cannot, in general, be extended to permutations \(\pi \) with \(\pi (1)=n\) (except trivially, when \(n = 1\) or \(m = n\)). For example, if \(\pi =(2,1)\) and \(\rho =(1,2,3,4)\), then one can easily see that \(f(\rho ) \supseteq f(\pi )\), but \(\rho \) does not contain \(\pi \). One underlying reason for this phenomenon is that whenever \(\pi (1)=n\), the vertices \(a_n\) and \(a_{n+1}\) have exactly the same neighbourhoods, which makes it possible for the graphs to be embedded with more flexibility, not necessarily forcing embedding of permutations. For this reason, we introduce a slight modification of the embedding, which allows us to always avoid the case \(\pi (1)=n\).

Definition 1

Given a permutation \(\pi =(\pi (1), \pi (2), \ldots , \pi (n))\), define \(\pi ^*=(1, \pi (1)+1, \pi (2)+1, \ldots , \pi (n)+1)\). Define \(f^*(\pi ) = f(\pi ^*)\), where f is the map from permutations to quasi-permutation graphs.

Theorem 1

\(f^*\) is an injection from the class of permutations to the class of quasi-permutation graphs such that for any two permutations \(\pi \) and \(\rho \) we have \(f^*(\pi ) \subseteq f^*(\rho )\) if and only if \(\pi \subseteq \rho \).

Proof

\(f^*\) is a composition of two injective maps \(\pi \mapsto \pi ^*\) and \(\pi ^* \mapsto f(\pi ^*)\), with the image of the second map being a quasi-permutation graph. Therefore, \(f^*\) is an injection from the class of permutations to the class of quasi-permutation graphs. Further, \(f^*(\pi ) \subseteq f^*(\rho )\) means, by definition, that \(f(\pi ^*) \subseteq f(\rho ^*)\), which happens if and only if \(\pi ^* \subseteq \rho ^*\) (this follows from Lemma 1 as \(\pi ^*(1)=1 \ne n\)). Finally, it is easy to see that \(\pi ^*\subseteq \rho ^*\) if and only if \(\pi \subseteq \rho \), from which the second part of the theorem follows.    \(\square \)

3 The Structure of Quasi-chain Graphs

For two graphs \(G_1=(V,E_1)\) and \(G_2=(V,E_2)\) on the same vertex set we denote by \(G_1\otimes G_2\) the graph \(G=(V,E_1\otimes E_2)\), where \(\otimes \) denotes the symmetric difference of two sets. The main result in this section is the following theorem.

Theorem 2

If a bipartite graph \(G=(A,B,E)\) is a quasi-chain graph, then \(G=Z\otimes H\) for a chain graph Z and a graph H of vertex degree at most two such that \(E(H)\cap E(Z)\) and \(E(H)-E(Z)\) are matchings. Such a decomposition \(G=Z\otimes H\) can be obtained in polynomial time.

In the proof of this result, we use a word representation for our graphs, which builds on a special case of letter graph representations, introduced in [22]. The starting point is as follows: there is a bijective, order-preserving mapping between words over the alphabet \(\{a, b\}\) (under the subword relation) and coloured chain graphs (under the coloured induced subgraph relation). This mapping sends a word w to the graph whose vertices are the entries of w, and we have edges between each a and each b appearing after it in w. See Fig. 1 for an example (the indices of the letters indicate the order of their appearance in w).

Fig. 1.
figure 1

The graph corresponding to the word \(w = aababbab\)

We would like to extend this representation to graphs with the structure claimed in Theorem 2. To do so, we enhance the letter representation described above by allowing bottom edges between pairs ab with the a appearing before the b in w and top edges between pairs ab with the a appearing after the b in w. We require, in addition, that the set of top edges forms a matching and the set of bottom edges forms a matching, and interpret the bottom edges as an instruction to remove the corresponding matching from the chain graph represented by w, and the top edges as an instruction to add the corresponding matching. We call such a word an enhanced word. For instance, \(w'=\underline{aab}a\overline{bba}b\) is an enhanced word obtained from \(w=aababbab\) by adding the bottom edge connecting the first a to the first b and the top edge connecting the second b to the last a.

If G is the graph described by an enhanced word w, we say that w is an enhanced letter representation for G. In particular, \(w'=\underline{aab}a\overline{bba}b\) is an enhanced letter representation of the graph obtained from the graph in Fig. 1 by removing the edge \(a_1b_1\) and adding the edge \(b_2a_4\). It is immediate from our discussion that Theorem 2 can be restated as follows.

Theorem 3

Any quasi-chain graph admits an enhanced letter representation that can be found in polynomial time.

The proof is by induction on the number of vertices of a quasi-chain graph G, noting that either G or \(\widetilde{G}\) has a vertex of degree at most 1. By considering various cases, we show that such a vertex can always be added to an enhanced letter representation obtained inductively. The case analysis can be made algorithmic, yielding a polynomial bound.

4 Implicit Representation of Quasi-chain Graphs

The idea of implicit representation of graphs (also known in the literature as adjacency labelling scheme) was introduced in [11] and can be described as follows. A representation of an n-vertex graph G is said to be implicit if it assigns to each vertex of G a binary code of length \(O(\log n)\) so that the adjacency of two vertices is a function of their codes.

Not every class of graphs admits an implicit representation, since a bound on the length of a vertex code implies a bound on the number of graphs admitting such a representation. More precisely, only classes containing \(2^{O(n \log n)}\) labelled graphs with n vertices can admit an implicit representation. In the terminology of [3], hereditary classes containing \(2^{O(n \log n)}\) labelled graphs on n vertices are at most factorial, i.e., they have at most factorial speed of growth. Whether all hereditary classes with at most factorial speed admit an implicit representation is a big open question known as the implicit representation conjecture [23]. The conjecture holds for a variety of factorial classes such as interval graphs, permutation graphs (which include chain graphs), line graphs, planar graphs, etc. It also holds for all graph classes of bounded vertex degree, of bounded clique-width, of bounded arboricity (including all proper minor-closed classes), etc.; see [2] and the references therein for more information on this topic.

The class of quasi-chain graphs is known to be factorial, which was shown in [1]. However, the question whether this class admits an implicit representation remains open. In this section, we answer this question in the affirmative. To this end, we introduce the following general tool.

For a graph \(G=(V,E)\), let \(A_G\) denote the adjacency matrix of G, and for two vertices \(x,y\in V\), let \(A_G(x,y)\) be the element of the matrix corresponding to x and y. Given a Boolean function f of k variables and graphs \(H_1=(V,E_1),\ldots ,H_k=(V,E_k)\), we will write \(G=f(H_1,\ldots ,H_k)\) if

$$A_G(x,y)=f(A_{H_1}(x,y),\ldots ,A_{H_k}(x,y))$$

for all distinct vertices \(x,y\in V\). If \(G=f(H_1,\ldots ,H_k)\), we say that G is an f-function of \(H_1,\ldots ,H_k\).

Theorem 4

Let X be a class of graphs, k a natural number, f a Boolean function of k variables, and \(Y_1,\ldots ,Y_k\) classes of graphs admitting an implicit representation. If every graph in X is an f-function of graphs \(H_1\in Y_1,\ldots ,H_k\in Y_k\), then X also admits an implicit representation.

Proof

To represent a graph \(G=f(H_1,\ldots ,H_k)\) in X implicitly, we assign to each vertex of G k labels, each of which represents this vertex in one of the graphs \(H_1,\ldots ,H_k\). Given the labels of two vertices \(x,y\in V(G)\), we can compute the adjacency of these vertices in each of the k graphs and hence, using the function f (which we may encode in each label with a constant number of bits), we can compute the adjacency of x and y in the graph G.    \(\square \)

According to Theorem 2, any quasi-chain graph is a \(\oplus \)-function of a chain graph and a graph of vertex degree at most 2, where \(\oplus \) is addition modulo 2. As we mentioned earlier, chain graphs and graphs of vertex degree at most 2 admit an implicit representation. Together with Theorem 4 this implies the following conclusion.

Corollary 1

The class of quasi-chain graphs admits an implicit representation.

The same conclusion can be derived in an alternative way, which is of independent interest, because it deals with a parameter motivated by some biological applications. This parameter was introduced in [7] under the name contiguity and it can be defined as follows.

Graphs of contiguity 1 are graphs that admit a linear order of the vertices in which the neighbourhood of each vertex forms an interval. Not every graph admits such an ordering, in which case one can relax this requirement by looking for an ordering in which the neighbourhood of each vertex can be split into at most k intervals. The minimum value of k which allows a graph G to be represented in this way is the contiguity of G.

Theorem 5

Contiguity of quasi-chain graphs is at most 3.

Proof

It is not difficult to see that chain graphs have contiguity 1. Let G be a quasi-chain graph, and use Theorem 2 to obtain a decomposition \(G = Z \otimes H\). Consider a linear order of the vertices of G such that their neighbourhoods in Z are intervals. Z can be transformed into G by adding at most one edge and at most one non-edge incident to each vertex. By adding a non-edge, we split the interval of neighbours of v into at most two intervals, and by adding a neighbour to v, its neighbourhood spans at most one additional interval consisting of a single vertex.    \(\square \)

It is routine to check that graphs of bounded contiguity admit an implicit representation. Therefore, Corollary 1 follows from Theorem 5 as well.

5 Optimisation in Quasi-chain Graphs

Many algorithmic problems that are NP-complete for general graphs remain computationally intractable for bipartite graphs, which is the case, for instance, for hamiltonian cycle [20], maximum induced matching [16], alternating cycle-free matching [19], balanced biclique [10], maximum edge biclique [21], dominating set, steiner tree [18], independent domination [6], induced subgraph isomorphism [9].

The simple structure of chain graphs implies bounded clique-width and therefore polynomial-time solvability of all these and many other problems. However, in quasi-chain graphs the clique-width is unbounded and hence no solution comes for free in this class. Moreover, induced subgraph isomorphism remains intractable, as we show in Sect. 5.1 based on the relationship between quasi-chain graphs and permutations revealed in Theorem 1.

On the other hand, the structure of quasi-chain graphs revealed in Theorem 2 allows us to prove polynomial-time solvability of three problems in the above list, which we do in Sect. 5.2.

5.1 NP-completeness of Induced Subgraph Isomorphism in Quasi-chain Graphs

The induced subgraph isomorphism problem can be stated as follows: given two graphs H and G, decide whether H is an induced subgraph of G or not. This problem is known to be NP-complete even when both graphs are bipartite permutation graphs [9]. A related problem on permutations is known as pattern matching: given two permutations \(\pi \) and \(\rho \), it asks whether \(\pi \) contains \(\rho \) as a pattern. This problem is also NP-complete [4]. Together with Theorem 1 this immediately implies that coloured induced subgraph isomorphism is NP-complete for quasi-chain graphs. Below we extend this conclusion to uncoloured graphs.

Theorem 6

The induced subgraph isomorphism problem is NP-complete for quasi-chain graphs.

Proof

Let H and G be two coloured connected quasi-chain graphs. The NP-completeness of pattern matching together with Theorem 1 imply that determining whether there is an embedding of H into G as an induced subgraph that respects the colours is an NP-complete problem. To reduce the problem to uncoloured graphs, we modify the instance of the problem as follows.

Let p be a natural number greater than the maximum vertex degree in G, and let \(K_{1,p}\) be a star with the center x. We add this star to G, connect x to all the black vertices of G and denote the resulting graph by \(G^*\). Similarly, we add this star to H, connect x to all the black vertices of H and denote the resulting graph by \(H^*\). Clearly, \(G^*\) and \(H^*\) are quasi-chain graphs.

Now we ignore the colours and ask whether \(G^*\) contains \(H^*\) as an induced subgraph. If \(G^*\) contains \(H^*\), then vertex x in \(H^*\) must map to vertex x in \(G^*\) (due to the degree condition), and the vertices of H in \(H^*\) are mapped to the vertices of G in \(G^*\) in a colour-preserving way (due to the connectedness of G and H). Therefore, G contains H as a coloured induced subgraph if and only if \(G^*\) contains \(H^*\) as an induced subgraph. Since \(G^*\) and \(H^*\) are quasi-chain graphs and these graphs can be obtained from G and H in polynomial time, we conclude that induced subgraph isomorphism is NP-complete for quasi-chain graphs.

   \(\square \)

5.2 Polynomial-Time Algorithms for Quasi-chain Graphs

In this section, we use Theorem 2 to prove polynomial-time solvability of the following problems in quasi-chain graphs: balanced biclique, maximum edge biclique, and independent domination. We emphasize that Theorem 2 not only provides a structural characterisation of quasi-chain graphs, it also proves that a quasi-chain graph can be transformed into a chain graph by removing a matching and adding a matching in polynomial time, which is an important ingredient in all three solutions. We start with an auxiliary lemma.

Lemma 2

A quasi-chain graph G with n vertices contains a collection \(\mathcal I\) of O(n) subsets of vertices that can be found in polynomial time such that every subset \(I \in \mathcal I\) induces a graph of vertex degree at most 1, and every independent set in G is contained in one of these subsets.

Proof

First, we observe that there are O(n) inclusion-wise maximal independent sets in a chain graph, and that all of them can be found in polynomial time.

Now let \(G=Z\otimes H\) be a quasi-chain graph and let S be an independent set in G. Then in the graph Z, the vertices of S either form an independent set, or induce some bottom edges, i.e., some edges of \(E(H)\cap E(Z)\). Since bottom edges form a matching and Z is \(2P_2\)-free, we conclude that S contains at most one bottom edge in the graph Z.

If S is an independent set in Z, then it is contained in a maximal independent set I in Z. For each maximal independent set I in the graph Z, the vertices of I induce in G a subgraph G[I] of vertex degree at most 1, because all edges of G[I] are top edges and therefore they form a matching.

Assume now that S contains an edge \(a_ib_j\) in the graph Z. We denote the set of non-neighbours of \(a_i\) in G by \(A_i\) and the set of non-neighbours of \(b_j\) in G by \(B_j\), and let \(I=A_i\cup B_j\). In particular, \(S\subseteq I\). In Z, the vertices of I induce a subgraph Z[I] containing exactly one edge \(a_ib_j\). Indeed, no edge \(e\ne a_ib_j\) in Z[I] can be incident to \(a_i\) or \(b_j\), because otherwise both e and \(a_ib_j\) are bottom edges, which is impossible, and if e is not incident to \(a_i\) and \(b_j\), then e and \(a_ib_j\) create an induced \(2P_2\) in Z, which is not possible either. Since \(a_ib_j\) is the only edge in Z[I] and this edge is not present in G[I], we conclude that all edges of G[I] are top edges and hence G[I] is a graph of vertex degree at most one.

Putting everything together, our collection \(\mathcal I\) consists of two types of sets: the maximal independent sets from Z, and the sets constructed as above from each of the bottom edges. This collection thus has O(n) sets, and can be found in polynomial time as claimed.    \(\square \)

Bicliques in Quasi-chain Bipartite Graphs. A biclique is a complete bipartite graph \(K_{p,q}\) for some p and q. In a bipartite graph, the problem of finding a biclique with the maximum number of vertices can be solved in polynomial time. However, the problem of finding a biclique with the maximum number of edges, known as the maximum edge biclique problem, is NP-complete for bipartite graphs [21]. Additionally, the problem of finding a biclique \(K_{p,p}\) with the maximum value of p, known as the balanced biclique problem, is NP-complete for bipartite graphs [10]. We show that both problems can be solved in polynomial time when restricted to quasi-chain graphs.

Theorem 7

The maximum edge biclique and balanced biclique problems can be solved in polynomial time for quasi-chain graphs.

Proof

Let \(G=(A,B,E)\) be a quasi-chain graph. A biclique in G becomes an independent set in the bipartite complement \(\widetilde{G}\) of G. Since an unbalanced \(2P_3\) is self-complementary in the bipartite sense, we note that \(\widetilde{G}\) is a quasi-chain graph too.

Let \(\mathcal I\) be as in Lemma 2 for \(\widetilde{G}\). Every independent set in \(\widetilde{G}\) is contained in a maximal independent set, which in turn is contained in one of the subsets of \(\mathcal I\). In G, those subsets induce almost complete bipartite graphs, i.e., graphs in which every vertex has at most one non-neighbour in the opposite part. Therefore, to solve both problems for G, it suffices to solve them for this collection of O(n) almost complete bipartite graphs.

But those problems are both easy for almost complete bipartite graphs: suppose a graph is obtained from \(K_{s,t}\) by deleting a matching of size \(m\le s\le t\). It is not difficult to see that the number of edges in a maximum edge biclique in this graph equals \(\max \limits _{0\le i\le m}(t-m+i)\cdot (s-i)\). As for the balanced biclique problem, the optimal solution is given by \(p = s\) if \(t - s \ge m\), and by \(\left\lfloor \frac{t - m + s}{2}\right\rfloor \) if \(t - s < m\).    \(\square \)

Independent Domination in Quasi-chain Graphs. The independent dominating set problem asks to find in a graph G an inclusion-wise maximal independent set of minimum cardinality. This problem is NP-complete for general graphs and remains intractable in many restricted graph families. In particular, it is NP-complete both for \(2P_3\)-free graphs [24] and for bipartite graphs [6]. In the following theorem, we prove polynomial-time solvability of the problem for quasi-chain graphs.

Theorem 8

The independent dominating set problem can be solved for quasi-chain graphs in polynomial time.

Proof

Let \(G=(A,B,E)\) be a quasi-chain graph and S an optimal solution to the problem in G, and let \(\mathcal I\) be as in Lemma 2. Note that S is contained in at least one of the elements of \(\mathcal I\). Moreover, crucially, for any \(I \in \mathcal I\), all maximal independent sets in G[I] have the same size. This suggests the following way of finding an optimal solution:

  1. 1.

    For each \(I \in \mathcal I\), determine if I contains an independent set that dominates G, and if yes, find such a set.

  2. 2.

    Among the sets we found, pick one with minimum size.

We claim that this produces an optimal solution to the problem. Indeed, this procedure is guaranteed to produce a set S, since any optimal solution to the problem dominates G and is contained in some \(I \in \mathcal I\). Moreover, since all maximal independent sets in G[I] have the same size (and S dominates G, so it is maximal in both G and G[I]), S must be an optimal solution.

It thus suffices to show that Step 1 can be done efficiently. To do this, let \(I \in \mathcal I\). Let \(I'\subseteq I\) be the subset of I of vertices that have degree 1 in G[I], and put \(I'':=I-I'\). We note that any independent subset of I dominating G must contain all vertices of \(I''\), and exactly one vertex from each edge of \(G[I']\). Let \(A''\) and \(B''\) be the sets of vertices in A, respectively B that have at least one neighbour in \(I''\). We also denote \(I'_A:=I'\cap A\) and \(I'_B:=I'\cap B\), and let \(A'\) and \(B'\) be the sets of vertices in \(A - (A''\cup I'_A)\), respectively \(B - (B''\cup I'_B)\) that have at least one neighbour in \(I'\).

If I does not dominate G, then no subset of I dominates G; we may thus assume I dominates G, that is, \(A-I = A' \cup A''\) and \(B-I = B' \cup B''\). Since G does not contain an unbalanced \(2P_3\), the graphs \(G[I'_A\cup B']\) and \(G[I'_B\cup A']\) are \(2P_2\)-free, i.e., chain graphs. It follows that \(I'_A\) and \(I'_B\) each have vertices that dominate \(B'\) and \(A'\) respectively. If there exists such a pair \(x \in I'_A\) and \(y \in I'_B\) that is non-adjacent, then we are done: we pick x and y in their respective edges, and arbitrarily choose vertices from each other edge of \(I'\) to complete our independent dominating set. Otherwise, the unique vertices \(x \in I'_A\) and \(y \in I'_B\) that dominate \(B'\) and \(A'\) respectively belong to the same edge of \(I'\). In this case, no independent set of I dominates G, since vertices \(A'\) and \(B'\) have no neighbours in \(I''\) by construction, and (using \(2P_2\)-freeness) \(I'_A - \{x\}\) does not dominate \(A'\), and \(I'_B - \{y\}\) does not dominate \(B'\). This proves the theorem.    \(\square \)