1 Introduction

A graph G is an intersection graph if there exists a family of non-empty sets \(\mathcal {F}=\{S_1,\ldots ,S_n\}\) such that for each vertex \(v_i\) of G, a set \(S_i\in \mathcal {F}\) is assigned in a way that there is the edge \(v_iv_j\) in G if and only if \(S_i\cap S_j\ne \emptyset \). We say that G has an \(\mathcal {F}\)-intersection representation. Every graph can be represented as an intersection graph since per each vertex, we can use the set of its incident edges. However, many important graph classes can be described as intersection graphs of a restricted family of sets. Depending on the geometrical representation, different types of intersection graphs are defined, for instance, interval, circular-arc, disk graphs, etc. Interval graphs are intersection graphs of segments of the real line, called intervals. Such a representation is being referred to as interval representation. They have been a well known and widely studied class of graphs from both the theoretical and the algorithmic points of view since 1957. They were first mentioned independently in combinatorics (Hajos [10, 22]) and genetics (Benzer [3]).

Interval graphs have a nice structure, they are chordal and, therefore, also perfect which provides a variety of graph decompositions and models. Such properties are often useful tools for the algorithm design—the most common algorithms on them are based on dynamic programming. Therefore, many classical \(\mathsf {NP}\)-hard problems are polynomial-time solvable on interval graphs, for instance Hamiltonian cycle (Keil [31]), Graph isomorphism (Booth [6]) or Colorability (Golumbic [19]) are solvable even in linear time. Surprisingly, the complexity of some well-studied problems is still unknown despite extensive research, e.g. the \(L_{2,1}\)-labeling problem, or the packing coloring problem.

Interval graphs have many real applications in diverse areas including genetics [3], economics, and archaeology [37, 38]. According to Golumbic [19], many real-world applications involve solving problems on graphs which are either interval graphs themselves or are related to interval graphs in a natural way. An important subclass of interval graphs is the class of proper interval graphs, graphs which can be represented by such an interval representation that no interval properly contains another one. Another interval representation is a representation with intervals of only unit lengths, graphs which have such a representation are called unit interval graphs. Roberts proved in 1969 [36] that a graph is a proper interval graph if and only if it is a unit interval graph. Later, Gardi came up with a constructive combinatorial proof [17].

The mentioned results do not specifically care about what types of intervals (open, closed, semi-closed) are used in the interval representation. However, as far as there are no restrictions on lengths of intervals, it does not matter which types of intervals are used [40]. The same applies if there is only one type of interval in the interval representation. However, this is not true when all intervals in the interval representation have unit length and at least two types of intervals are used. In particular, the claw \(K_{1,3}\) can be represented using one open interval and three closed unit intervals whereas it cannot be represented with unit intervals of the same type.

Recently, it has been observed that a restriction on different types of intervals in the unit interval representation leads to several new subclasses of interval graphs. We denote the set of all open, closed, open-closed, and closed-open intervals of unit length by \({\mathcal {U}} ^{--}\), \({\mathcal {U}} ^{++},\) \({\mathcal {U}} ^{-+}\), and \({\mathcal {U}} ^{+-}\), respectively. Let \({\mathcal {U}} \) be the set of all types of unit intervals. Although there are 16 different combinations of types of unit intervals, it was shown in [13, 25, 35, 40, 41] in the years 2012–2018 that they form only four different classes of mixed unit interval graphs. In particular, the following holds:

$$\begin{aligned} \emptyset \subsetneq \text {unit}&\text { interval} \subsetneq \text {unit open and closed interval} \subsetneq \text {semi-mixed unit interval} \subsetneq \\&\text {mixed unit interval} \subsetneq \text {interval graphs,} \end{aligned}$$

where unit open and closed interval graphs have \(\left( {\mathcal {U}} ^{++}\cup {\mathcal {U}} ^{--}\right) \)-intersection representation, semi-mixed unit interval graphs have \(\left( {\mathcal {U}} ^{++}\cup {\mathcal {U}} ^{--}\cup {\mathcal {U}} ^{-+}\right) \)-intersection representation, and mixed unit interval graphs have \({\mathcal {U}} \)-intersection representation. Hence, mixed unit interval graphs allow all types of intervals of unit length.

Definition 1

A graph G is a mixed unit interval graph if it has a \({\mathcal {U}} \)-intersection representation. We call such representation a mixed unit interval representation.

There are lots of characterizations of interval and unit interval graphs. Among many of the characterizations, we single out a matrix-like representation called bubble model [23]. A similar notion was independently discovered by Lozin [30] under the name canonical partition. In the bubble model, vertices of a unit interval graph G are placed into a “matrix” where each matrix entry may contain any number (possibly zero) of vertices. Edges of G are represented implicitly with the following conditions: each column forms a clique; and in addition, edges are only between consecutive columns where they form nested neighborhood (two vertices u and v from consecutive columns are adjacent if and only if v occurs in a higher row than u). In particular, there are no edges between non-consecutive columns. This representation can be computed in linear time given a proper interval ordering representation.

We introduce a similar representation of mixed unit interval graphs, called \({\mathcal {U}}\)-bubble model, and we extend some results from unit interval graphs to mixed unit interval graphs using this representation. The representation has almost the same structure as the original bubble model, except that edges are allowed in the same row under specific conditions. We show that a graph is mixed unit interval graph if and only if it can be represented by a \({\mathcal {U}}\)-bubble model.

Theorem 1

A graph is a mixed unit interval graph if and only if it has a \({\mathcal {U}}\)-bubble model. Moreover, given a mixed unit interval representation of graph G on n vertices, a \({\mathcal {U}}\)-bubble model can be constructed in \(\mathcal {O}(n)\) time.

In addition, we show properties of our model, such as the relation of the size of a maximum independent set or maximum clique, and the size of the model, see Sect. 2.6.

Given a graph G, the MaxCut problem is the problem of finding a partition of the vertices of G into two sets S and \(\overline{S}\) such that the number of edges with one endpoint in S and the other one in \(\overline{S}\) is maximum among all partitions. There were two results about polynomiality of the MaxCut problem in unit interval graphs in the past years; the first one by Bodlaender et al. in 1999 [5], the second one by Boyacı et al. which has been published in 2017  [7]. The result of the first paper was disproved by authors themselves a few years later [4]. In the second paper, the authors used a bubble model for proving the polynomiality. However, we realized that this algorithm is also incorrect. Moreover, it seems to us to be hardly repairable. We provide further discussion and also a concrete example, in Sect. 3.2. The complexity of the MaxCut problem in interval graphs was surprisingly unknown for a long time. Interestingly, a result about \(\mathsf {NP}\)-completeness by Adhikary et al. has appeared on arXiv [1] very recentlyFootnote 1.

Using the \({\mathcal {U}}\)-bubble model, we obtain at least a subexponential-time algorithm for MaxCut in mixed unit interval graphs. We are not aware of any subexponential algorithms on interval graphs. In general graphs, there has been extensive research dedicated to approximation of MaxCut in subexponential time, see e.g. [2] or [24]. Furthermore, we obtain a polynomial-time algorithm if the given graph has a \({\mathcal {U}}\)-bubble model with a constant number of columns. This extends a result by Boyacı et al. [8] who showed a polynomial-time algorithm for MaxCut on unit interval graphs which have a bubble model with two columns (also called co-bipartite chain graphs). The question of whether the MaxCut problem is polynomial-time solvable or \(\mathsf {NP}\)-hard in unit interval graphs still remains open.

Theorem 2

Let G be a mixed unit interval graph. A maximum cardinality cut can be found in time \(n^{\mathcal {O}(1)} \, 2^{\sqrt{n}(\log {n}+2)}.\)

From the proof of Theorem 2, we derive the following corollary.

Corollary 3

The size of a maximum cut in the graph class defined by \({\mathcal {U}}\)-bubble models with k columns can be determined in time \(\mathcal {O}(n^{k+5})\). Moreover, for \(k=2\) in time \(\mathcal {O}(n^5)\).

The third part of the paper is devoted to clique-width, one of the graph parameters that is used to measure the complexity of a graph. Many \(\mathsf {NP}\)-hard problems can be solved efficiently on graphs with bounded clique-width [11]. In general, it is \(\mathsf {NP}\)-complete to decide if the graph has clique-width at most k for a given number k, see [15].

Unit interval graphs are known to have unbounded clique-width [20]. It follows from results by Fellows et al. [14], and Kaplan and Shamir [26] that the clique-width of (mixed) unit interval graphs is upper-bounded by \(\omega \) (the maximum size of their clique) + 1. Heggernes et al.  [23] improved this result for unit interval graphs using the bubble model. There, the clique-width is upper-bounded by a minimum of \(\alpha \) (the maximum size of an independent set) + 1, and a parameter related to the bubble model representation which is in the worst case \(\omega + 1\). We use similar ideas to extend these bounds to mixed unit interval graphs using the \({\mathcal {U}}\)-bubble model. In particular, we obtain that the upper-bound on clique-width is the minimum of the analogously defined parameter for a \({\mathcal {U}}\)-bubble model and \(2\alpha +3\). The upper-bound is still in the worst case \(\omega + 1\). The upper-bound can be also expressed in the number of rows or columns of \({\mathcal {U}}\)-bubble model. Refer to Theorem 21 and Corollary 22 in Sect. 4 for further details. As a consequence, we obtain an analogous result to Corollary 3 for rows using the following result. Fomin et al. [16] showed that the MaxCut problem can be solved in time \(\mathcal {O}(n^{2t+\mathcal {O}(1)})\) where t is clique-width of the input graph. By the combination of their result and our upper-bounds on clique-width (Theorem 21 in Sect. 4) we derive not only polynomial-time algorithm when the number of columns is bounded (with worse running time than Corollary 3) but also a polynomial-time algorithm when the number of rows is bounded, formulated as Corollary 4Footnote 2. Moreover, the above combination provides an alternative proof of Theorem 2 with slightly worse running-time; see Remark 1 in Sect. 3.3 for more details.

Corollary 4

The size of a maximum cut in the graph class defined by \({\mathcal {U}}\)-bubble models with k rows can be determined in time \(\mathcal {O}(n^{4k+\mathcal {O}(1)})\).

1.1 Preliminaries and Notation

By a graph we mean a finite, undirected graph without loops and multiedges. Let G be a graph. We denote by V(G) and E(G) the vertex and edge set of G, respectively; with \(n=|V(G)|\) and \(m=|E(G)|\). Let \({\alpha (G)} \) and \({\omega (G)} \) denote the maximum size of an independent set of G and the maximum size of a clique in G, respectively. Let \(u,v\in V(G)\) be two adjacent vertices, we say that uv are twins if they have the same neighborhood in G. By a family we mean a multiset \(\{S_1,\ldots ,S_n\}\), i.e., it allows the possibility that \(S_i=S_j\) even though \(i\ne j\).

Let \(x, y \in \mathbb {R}\) be real numbers. We call the set \(\{z\in \mathbb {R}:\,x\le z\le y\}\) closed interval [xy], the set \(\{z\in \mathbb {R}:\,x<z<y\}\) open interval (xy), the set \(\{z\in \mathbb {R}:\,x<z\le y\}\) open-closed interval (xy], and the set \(\{z\in \mathbb {R}:\,x\le z<y\}\) closed-open interval [xy). By semi-closed interval we mean interval which is open-closed or closed-open. We denote the set of all open, closed, open-closed, and closed-open intervals of unit length by \({\mathcal {U}} ^{--}\), \({\mathcal {U}} ^{++},\) \({\mathcal {U}} ^{-+}\), and \({\mathcal {U}} ^{+-}\), respectively. Formally, \({\mathcal {U}} ^{++} {:}{=}\{[x,x+1]:\, x\in \mathbb {R}\},\) \({\mathcal {U}} ^{--} {:}{=}\{(x,x+1):\, x\in \mathbb {R}\},\) \({\mathcal {U}} ^{+-} {:}{=}\{[x,x+1):\, x\in \mathbb {R}\},\) and \({\mathcal {U}} ^{-+} {:}{=}\{(x,x+1]:\, x\in \mathbb {R}\}.\) We further denote the set of all unit intervals by

$$\begin{aligned} {\mathcal {U}} {:}{=}{\mathcal {U}} ^{++}\cup {\mathcal {U}} ^{--}\cup {\mathcal {U}} ^{+-}\cup {\mathcal {U}} ^{-+}. \end{aligned}$$

From now on, we will be speaking only about unit intervals.

Let I be an interval, we define the left and right end of I as \(\ell (I) {:}{=}\inf (I)\) and \({r}(I) {:}{=}\sup (I)\), respectively. Let \(I,J\in {\mathcal {U}} \) be unit intervals, IJ are almost-twins if \(\ell (I) =\ell (J).\) The type of an interval I is a pair (rs) where \(I\in {\mathcal {U}} ^{r,s},\,r,s\in \{+,-\}.\)

Let \(G=(V,E)\) be a graph and \(\mathcal {I}\) an interval representation of G. Let \(v\in V\) be represented by an interval \(I_v\in {\mathcal {U}} ^{r,s}\), where \(r,s\in \{+,-\}\), in \(\mathcal {I}\). The type of a vertex \(v\in V\) in \({\mathcal {I}} \), denoted by \({\text {type}}_{\mathcal {I}} (v) \), is the pair (rs). We use \({\text {type}}(v)\) if it is clear which interval representation we have in mind. We follow the standard approach where the maximum over the empty set is \(-\infty \). The notion of \(\tilde{\mathcal {O}}\) denotes the standard \(\mathcal {O}\) which ignores polylogarithmic factors, i.e, \(\mathcal {O}(f(n) \log ^k n) = \tilde{\mathcal {O}}(f(n))\), where k is a constant.

1.1.1 Recognition and \({\mathcal {U}}\)-Intersection Representation of Mixed Unit Interval Graphs

All the classes of mixed unit interval graphs can be characterized using forbidden induced subgraphs, sometimes by infinitely many. Rautenbach and Szwarcfiter [35] gave a characterization of unit open and closed interval graphs using five forbidden induced subgraphs. Joos [25] gave a characterization of mixed unit interval graphs without twins by an infinite class of forbidden induced subgraphs. Shuchat et al. [40] proved independently also this characterization, moreover, they complemented it by a quadratic-time algorithm that produces a mixed proper interval representation. Finally, Kratochvíl and Talon [41] characterized the remaining classes.

Le and Rautenbach [29] characterized graphs that have a mixed unit interval representations in which all intervals have integer endpoints, and provided a quadratic-time algorithm that decides whether a given interval graph admits such a representation. We refer the reader to the original papers for more details and concrete forbidden subgraphs. More structural results can be found in [41].

Theorem 5

([41]) The classes of semi-mixed and mixed unit interval graphs can be recognized in time \(\mathcal {O}(n^2)\). Moreover, there exists an algorithm which takes a semi-mixed interval graph G on input, and outputs a corresponding \(\left( {\mathcal {U}} ^{++}\cup {\mathcal {U}} ^{--}\right) \)-intersection representation of G in time \(\mathcal {O}(n^2)\).

Corollary 6

([41]). It is possible to modify the algorithm for semi-mixed unit interval graphs such that given a mixed unit interval graph G, it outputs a mixed unit interval representation of G in time \(\mathcal {O}(n^2)\).

2 Bubble Model for Mixed Unit Interval Graphs

In this section, we present a \({\mathcal {U}}\)-bubble model, a new representation of mixed unit interval graphs which is inspired by the notion of bubble model for proper interval graphs created by Heggernes et al. [23] in 2009.

2.1 Definition of Bubble Model

First, we present the bubble model for proper interval graphs as it was introduced by Heggernes et al.

Definition 2

(Heggernes et al. [23], reformulated). If A is a finite non-empty set, then a 2-dimensional bubble structure for A is a partition \({\mathcal {B}} = \langle B_{i,j}\rangle _{1\le j\le k, 1\le i\le r_j}\), where \(A=\bigcup _{i,j} {B_{i,j}}, \) \(\emptyset \subseteq B_{i,j} \subseteq A\) for every ij with \(1\le j\le k\) and \(1\le i\le r_j\), and \(B_{1,1}\ldots B_{r_k,k}\) are pairwise disjoint. The graph given by \({\mathcal {B}}\), denoted as \(G({\mathcal {B}})\), is defined as follows:

  1. 1.

    the vertex set of \(G({\mathcal {B}})\) is A, and

  2. 2.

    uv is an edge of \(G({\mathcal {B}})\) if and only if there are indices \(i,i',j,j'\) such that \(u \in B_{i,j},\) \(v \in B_{i',j'},\) \(|j-j'|\le 1\), and one of the two conditions holds: either \(j=j'\) or \((i-i')(j-j')<0\).

A bubble model for a graph \(G=(V,E)\) is a 2-dimensional bubble structure \({\mathcal {B}}\) for V such that \(G=G({\mathcal {B}}).\)

Theorem 7

(Heggernes et al. [23]). A graph is proper interval if and only if it has a bubble model.

We define a similar matrix-type structure for mixed unit interval graphs where each set \(B_{i,j}\) is split into four parts and edges are allowed also in the same row under specific conditions.

Definition 3

Let A be a finite non-empty set and \({\mathcal {B}} = \langle B_{i,j}\rangle _{1\le j\le k, 1\le i\le r_j}\) be a 2-dimensional bubble structure for A such that \(B_{i,j} = {B_{i,j}^{++}} \cup B_{i,j}^{+-} \cup B_{i,j}^{-+} \cup B_{i,j}^{--} \), \(B_{i,j}^{r,s}\) are pairwise disjoint, and \(\emptyset \subseteq B_{i,j}^{r,s} \subseteq B_{i,j}\) for every \(r,s\in \{+,-\}\) and ij with \(1\le j\le k\) and \(1\le i\le r_j\). We call the partition \({\mathcal {B}}\) a 2-dimensional \({\mathcal {U}}\)-bubble structure for A.

We call each set \(B_{i,j}\) a bubble, and each set \(B_{i,j}^{r,s}, r,s\in \{+,-\},\) a quadrant of the bubble \(B_{i,j}\). The type of a quadrant \(B_{i,j} ^{r,s}\), \(r,s\in \{+,-\}\), is the pair (rs). We denote by \(*\) both \(+\) and −, for example \(B_{i,j}^{*+} =B_{i,j}^{-+} \cup B_{i,j}^{++} \). Bubbles with the same i-index form a row of \({\mathcal {B}}\), and with the same j-index a column of \({\mathcal {B}}\), we say vertices from bubbles \(B_{i,1}\cup \cdots \cup B_{i,k}\) appear in row i, and we denote i as their row-index. We define an analogous notion for columns. We denote the index of the first row with a non-empty bubble as \({\text {top}}(j) {:}{=}\min {\{i\mid B_{i,j} \in {\mathcal {B}} \text { and } B_{ij}\ne \emptyset \}}\). Thus, \({B_{{\text {top}}(j), j}} \) is the first non-empty bubble in the column j. Let B be a bubble, then \({\text {row}}(B) \) and \({\text {col}}(B) \) is the row-index and column-index of B, respectively. Let \(u\in B_{i,j} \), \(v\in B_{i',j'}\); we say that u is under v and v is above u if \(i>i'\).

Fig. 1
figure 1

Different representations of a mixed unit interval graph G

Definition 4

Let \({\mathcal {B}} = \langle B_{i,j}\rangle _{1\le j\le k, 1\le i\le r_j}\) be a 2-dimensional \({\mathcal {U}}\)-bubble structure for A. The graph given by \({\mathcal {B}}\), denoted as \(G({\mathcal {B}})\), is defined as follows:

  1. 1.

    \(V(G({\mathcal {B}})) = A\),

  2. 2.

    uv is an edge of \(G({\mathcal {B}})\) if and only if there are indices \(i,i',j,j'\) such that \(u \in B_{i,j},\) \(v \in B_{i',j'}\), or \(v\in B_{i,j} \), \(u\in B_{i',j'}\), and one of the three conditions holds:

    1. (a)

      \(j = j'\), or

    2. (b)

      \(j = j' - 1\) and \(i > i'\), or

    3. (c)

      \(j = j' - 1\) and \(i = i'\) and \(u\in B_{i,j}^{*+}, v\in B_{i',j'}^{+*} \).

The definition says that the edges are only between vertices from the same or consecutive columns and if \(u\in B_{i,j} \) and \(v\in B_{i',j+1}\), there is an edge between u and v if and only if u is under v (\(i > i'\)), or they are in the same row and \(u\in B_{i,j}^{*+},v\in B_{i',j+1}^{+*}. \)

Observation 8

Vertices from the same column in \(G({\mathcal {B}})\) form a clique. Moreover, the neighborhoods of vertices from the same bubble can differ only in the same row, and vertices from the same bubble quadrant are twins.

Definition 5

Let \(G=(V,E)\) be a graph. A \({\mathcal {U}}\)-bubble model for a graph G is a 2-dimensional \({\mathcal {U}}\)-bubble structure \({\mathcal {B}} = \langle B_{i,j}\rangle _{1\le j\le k, 1\le i\le r_j}\) for V such that

  1. (i)

    G is isomorphic to \(G({\mathcal {B}})\), and

  2. (ii)

    each column and each row contains a non-empty bubble, and

  3. (iii)

    no column ends with an empty bubble, and

  4. (iv)

    \({\text {top}}(1) =1\), and for every \(j\in \{1,\ldots ,k-1\}: {\text {top}}(j) \le {\text {top}}(j+1).\)

For a \({\mathcal {U}}\)-bubble model \({\mathcal {B}} = \langle B_{i,j}\rangle _{1\le j\le k, 1\le i\le r_j}\), by the number of rows of \({\mathcal {B}} \) we mean \(\max \{r_j\mid 1\le j\le k\}\). We define the size of the \({\mathcal {U}}\)-bubble model \({\mathcal {B}}\) as the number of columns multiplied by the number of rows, i.e., \(k\cdot \max \{r_j\mid 1\le j\le k\}.\)

See Fig. 1 with an example of a mixed unit interval graph, given by a mixed unit interval representation, and by a \({\mathcal {U}}\)-bubble model.

2.2 Construction of \({\mathcal {U}}\)-Bubble Model

First, we construct a mixed unit interval representation \({\mathcal {I}}\) of a mixed unit interval graph G using the quadratic-time algorithm, see Corollary 6; then each vertex of G is represented by a corresponding interval in \({\mathcal {I}}\). Having a mixed unit interval representation of the graph, our algorithm outputs a \({\mathcal {U}}\)-bubble model for the graph in \(\mathcal {O}(n)\) time.

We now describe the creation of bubbles. Given a mixed unit interval representation \({\mathcal {I}}\), all the vertices that are represented by almost-twins in \({\mathcal {I}}\) form a single bubble where they belong to the particular quadrants according to the type of their corresponding intervals in \({\mathcal {I}}\). We denote the set of all bubbles by \(\mathscr {B} \). From now on, we speak about bubbles only. We are going to determine their place (row and column) to create a 2-dimensional \({\mathcal {U}}\)-bubble structure for \(\mathscr {B} \). We show that the \({\mathcal {U}}\)-bubble structure is a \({\mathcal {U}}\)-bubble model for our graph. Based on the order \(\sigma \) by endpoints of intervals in the representation \({\mathcal {I}}\) from left to right, we obtain the same order on bubbles in \(\mathscr {B} \). In line with that, we denote \(\ell (B) {:}{=}\ell (I_v) \) and \({r}(B) {:}{=}{r}(I_v) \) for a bubble \(B\in \mathscr {B} \) and an interval \(I_v\in {\mathcal {I}} \) corresponding to \(v\in B\) (note that it is well-defined as every bubble contains only vertices which are represented by almost-twins in \({\mathcal {I}}\)). The idea of the algorithm is to process the bubbles in the order \(\sigma \), and assign to each bubble its column immediately after processing it. During the processing, the algorithm maintains an auxiliary path in order to assign rows at the end. Thus, rows are assigned to each bubble after all bubbles are processed.

For bubbles \(A, B\in \mathscr {B} \), \(A<_\sigma B\) denotes that A is smaller than B in order \(\sigma .\) For technical reasons, we create two new bubbles: \(B_{start}\), \(B_{end}\) such that \(\ell (B_{start}) ={r}(B_{start}) =-\infty \) and \(\ell (B_{end}) ={r}(B_{end}) =\infty \). We refer to them as auxiliary bubbles, in particular, if we speak about bubbles, we exclude auxiliary bubbles (also \(B_{start}\), \(B_{end}\notin \mathscr {B} \)). We enhance the representation in a way that each bubble \(B\in \mathscr {B} \) has a pointer \(prev:\mathscr {B} \rightarrow \mathscr {B} \cup \{B_{start}\}\) defined as follows.

$$\begin{aligned} prev(B)= {\left\{ \begin{array}{ll} B_{start} &{} \text {if } \ell (B) <{r}(\min _\sigma \mathscr {B}),\\ \max _\sigma \bigl \{A\in \mathscr {B} \mid \ell (B) \ge {r}(A) \bigr \} &{} \text {otherwise}. \end{array}\right. } \end{aligned}$$

In order to set rows at the end, the algorithm is creating a single oriented path P that has the information about the height of elements in the \({\mathcal {U}}\)-bubble structure being constructed. Some of the arcs of the path can be marked with level indicator (\(\mathsf {L}\)). Intuitively, a consecutive level indicators create a row. For ease of notation, we use \({next^{P}}(B_i)=B_j\) to say that \(B_j\) is the next element on path P after \(B_i\). We note that we can view P as an order of bubbles; we denote by \(A<_P B\), \(A,B\in \mathscr {B},\) the information that A occurs earlier than B on P. Also from technical reasons, P starts and ends with \(B_{start}\) and \(B_{end}\), respectively. Except P and pointers \(prev\) and \({next^{P}}\), the algorithm remembers the highest bubble of column i, denoted by \(C^\mathsf {{top}}_{i} \). Also, denote by \(\mathsf {curr}\), the index of the currently processed column.

Now, we are able to state the algorithm for assigning columns and rows to bubbles in \(\mathscr {B} \) and its properties (which are discussed in the Correctness section but are also straightforward to verify while reading the algorithm).

Property 1::

Bubbles are processed (and therefore added somewhere to P) one by one respecting the order \(\sigma \).

Property 2::

The order induced by P of already processed vertices never changes, i.e., once \(A\le _P B\) then \(A\le _P B\) for the rest of the algorithm.

Property 3::

The arc of P between bubbles A and B has the level indicator (\(\mathsf {L}\)) if and only if \({r}(A) =\ell (B) \). Moreover, if the arc from A to B has level indicator, then \({\text {col}}(A) <{\text {col}}(B) \).

Property 4::

\({\text {col}}(A) \le {\text {col}}(B) \) whenever \(A\le _\sigma B\).

Property 5::

\(prev(B)\) is the closest ancestor of B on P in the previous column, i.e., \(prev(B)=\max \{A \mid A\le _P B, {\text {col}}(A) ={\text {col}}(B)-1\}\).

Property 6::

The order induced by P of vertices in the same column is exactly the order of those vertices induced by \(\sigma \).

2.3 Algorithm

Given bubbles in \(\mathscr {B} \) ordered by \(\sigma \), the algorithm creates P by processing bubbles one by one in order \(\sigma \). For the purpose of the algorithm description, we denote the order \(\sigma \) of bubbles in \(\mathscr {B} \) by subscripts, i.e., \(B_1<_\sigma B_2<_\sigma \ldots \) are all bubbles in \(\mathscr {B} \) in the described order \(\sigma \) (do not confuse with the notation \(B_{i,j}\) where subscripts denote the row and column). See Fig. 2 for an example of a step of the algorithm. The algorithm outputs a row and a column to each bubble. Initially, set \({\text {col}}(B_1) =1\), \(P=(B_{start},B_1,B_{end})\), \(\mathsf {curr}\) =1 and \(C^\mathsf {{top}}_{1} =B_1\).

Suppose that \(i-1\) bubbles have been already processed, for \(i\ge 2\). Split the cases of processing bubble \(B_{i}\) based on the following possibilities:

  1. i.

    \({\ell (B_i) >{r}(C^\mathsf {{top}}_{\mathsf {curr}})}\): First increase \(\mathsf {curr}\) by one, then set \({\text {col}}(B_i) =\mathsf {curr} \) and \(C^\mathsf {{top}}_{\mathsf {curr}} =B_i.\)

  2. ii.

    \({\ell (B_i) ={r}(C^\mathsf {{top}}_{\mathsf {curr}})}\): First increase \(\mathsf {curr}\) by one, then set \({\text {col}}(B_i) =\mathsf {curr} \) and \(C^\mathsf {{top}}_{\mathsf {curr}} =B_i\). Let Q be \({next^{P}}(C^\mathsf {{top}}_{\mathsf {curr}-1})\). Substitute arc in P from \(C^\mathsf {{top}}_{\mathsf {curr}-1} \) to Q with two new arcs \(C^\mathsf {{top}}_{\mathsf {curr}-1} \) to \(B_i\) that has \(\mathsf {L}\) indicator set and from \(B_i\) to Q.

  3. iii.

    \({\ell (B_i) <{r}(C^\mathsf {{top}}_{\mathsf {curr}})}\): Set \({\text {col}}(B_i) =\mathsf {curr} \).

We continue only with cases i. and iii. and distinguish multiple possibilities:

  1. 1.

    \({{r}(prev(B_i)) =\ell (B_i)}\): Let Q be \({next^{P}}(prev(B_i))\). Then substitute arc in P from \(prev(B_i)\) to Q with two new arcs \(prev(B_i)\) to \(B_i\) that has \(\mathsf {L}\) indicator set and from \(B_i\) to Q.

  2. 2.

    \({{r}(prev(B_i)) <\ell (B_i)}\): Split this case further based on the properties of \(B_{i-1}\).

    1. 2a.

      \({prev(B_{i-1})=prev(B_{i})}\): Let Q be \({next^{P}}(B_{i-1})\). Substitute arc in P from \(B_{i-1}\) to Q with two new arcs \(B_{i-1}\) to \(B_i\) and from \(B_i\) to Q.

    2. 2b.

      \({prev(B_{i-1})\ne prev(B_{i})}\): Let Q be \({next^{P}}(prev(B_i))\). Then substitute arc in P from \(prev(B_i)\) to Q with two new arcs \(prev(B_i)\) to \(B_i\) and from \(B_i\) to Q.

After processing all the bubbles in \(\mathscr {B} \), assign rows to bubbles by a single run over P, inductively: Take the first bubble B of P and assign \({\text {row}}(B) {:}{=}1\). Let B be the last bubble on P with already set row index. We are about to determine \({\text {row}}({next^{P}}(B)) \). If arc in P from B to \({next^{P}}(B)\) has \(\mathsf {L}\) indicator, set \({\text {row}}({next^{P}}(B)) {:}{=}{\text {row}}(B) \), otherwise \({\text {row}}({next^{P}}(B)) {:}{=}{\text {row}}(B) +1\).

Fig. 2
figure 2

An example of an input and one step of the construction algorithm

Fig. 3
figure 3

A maximum clique of G in a \({\mathcal {U}}\)-bubble model. Dark gray color represents the bubbles that are fully contained in the clique. Light gray color highlights two bubbles where only parts of them are contained in the clique, concretely the one of the sets \(B_{i,j}, B_{i,j+1}\), and \(B_{i,j}^{*+}\cup B_{i,j+1}^{+*}\) with the maximum size

2.4 Correctness

Here, we show that the algorithm above gives us a \({\mathcal {U}}\)-bubble model for a graph given by mixed unit interval representation. It gives us the forward implication of Theorem 1.

Lemma 9

Given a mixed unit interval representation \({\mathcal {I}}\) of a connected graph G on n vertices, a \({\mathcal {U}}\)-bubble model for G can be constructed in \(\mathcal {O}(n)\) time.

Proof of Lemma 9

We show the correctness of the construction, i.e., that the constructed object satisfies Definition 5 and that declared Properties 1–6 are satisfied during the whole algorithm. Let \(\mathscr {B} \) be the set of bubbles created from \({\mathcal {I}}\) as in Sect. 2.2. It follows immediately from the construction that Properties 1–4 are satisfied. Observe that \(prev(B)\) is always in the previous column than B, for \(B\in \mathscr {B} \). Moreover, observe that in step ii. of the algorithm, \(C^\mathsf {{top}}_{{\text {col}}(B)-1} =prev(B), B\in \mathscr {B}.\) Then, Property 5 follows from the construction. Property 6 can be seen by examining the construction. Let \(A,B\in \mathscr {B} \) be two bubbles in the same column such that \(A <_\sigma B\). Either \(prev(A) = prev(B)\), then B is put later than A on P. Or \(prev(A)<_\sigma prev(B)\), then, by the construction, \(prev(B)\) is put after A and B is put after \(prev(B)\). In both cases, \(A<_P B\). Using Property 2, the Property 6 holds.

It is readily seen that the algorithm outputs a 2-dimensional \({\mathcal {U}}\)-bubble structure for the vertex set of G. Let \({\mathcal {B}}\) denote the \({\mathcal {U}}\)-bubble structure and \(G({\mathcal {B}})\) denote the graph given by \({\mathcal {B}}\). We want to show that \({\mathcal {B}}\) is a \({\mathcal {U}}\)-bubble model for G. Parts (ii), (iii) from Definition 5 are clearly satisfied. It remains to show (i) and (iv).

Let us start with (i), that is, \(G({\mathcal {B}})\) is isomorphic to G. Let \(u\in A\), \(v\in B\), where AB are bubbles in \(G({\mathcal {B}})\). Recall from the construction of \(\mathscr {B} \) that u and v are represented by almost-twins in \({\mathcal {I}}\) if and only if \(A=B\). The former implies that u and v are adjacent in G, the latter implies that u and v are adjacent in \(G({\mathcal {B}})\). Since the case of \(A=B\) is trivially satisfied, without loss of generality, we assume \(A<_\sigma B\). We distinguish a few cases based on the position of A and B in \({\mathcal {B}}\).

First, let A and B be in non-consecutive columns in \({\mathcal {B}}\). Denote by \(c={\text {col}}(A) \). By Definition 4, u and v are non-adjacent in \(G({\mathcal {B}})\). By the construction, there exists a non-empty bubble \(C^\mathsf {{top}}_{c+1} \) in \({\mathcal {B}}\) such that it is the top bubble of column \(c+1\). It follows that \(C^\mathsf {{top}}_{c+1} >_\sigma A\), by Property 4, and also \(C^\mathsf {{top}}_{c+1} \ne A\). Since the construction assigns B to a different column than \(C^\mathsf {{top}}_{c+1} \), we know that \({r}(C^\mathsf {{top}}_{c+1}) \le \ell (B) \). It gives immediate conclusion that uv are not adjacent in G.

Second, let A and B be in the same column c in \({\mathcal {B}}\). Vertices uv are adjacent in \(G({\mathcal {B}})\) by Definition 4. By the construction, there exists a non-empty bubble \(C^\mathsf {{top}}_{c} \) in \({\mathcal {B}}\) such that it is the top bubble in column c and \(\ell (C^\mathsf {{top}}_{c}) \le \ell (A)<\ell (B) <{r}(C^\mathsf {{top}}_{c}) =1+\ell (C^\mathsf {{top}}_{c}) \). Therefore, uv are adjacent in G.

Third, let A and B appear in consecutive columns in \({\mathcal {B}}\). We denote \(c={\text {col}}(A) ={\text {col}}(B)-1\). By Definition 4, vertices uv are adjacent in \(G({\mathcal {B}})\) if and only if either \({\text {row}}(A) >{\text {row}}(B) \), or \({\text {row}}(A) ={\text {row}}(B) \) and \(u\in A^{*+}, v\in B^{+*}\). By Properties 1 and 2 of P, it is sufficient to verify only the situation when bubble B was added. Observe that if \(B'<_P B''\) then \({\text {row}}(B') \le {\text {row}}(B'') \). We split the case into the following all possibilities:

  • \(prev(B)>_\sigma A\): By the definition of \(prev\) and the interval property, u is non-adjacent to v in G and \({r}(A) \ne \ell (B) \). By Property 6, \(A<_P prev(B)\). By Property 5, \(prev(B)<_P B\). As \(A<_P B\), \({\text {row}}(A) \le {\text {row}}(B) \). By Property 3, \({\text {row}}(A) <{\text {row}}(B) \). Therefore, uv are non-adjacent in \(G({\mathcal {B}})\).

  • \(prev(B)= A\): By Properties 3, 5 and the rows assignment, \({\text {row}}(B) ={\text {row}}(A) \) if and only if \(\ell (B) ={r}(A) \). Therefore, there is an edge in both models if and only if u and v are of correct types; that is, u has a type \((*,+)\) and v has a type \((+,*)\).

  • \(prev(B)<_\sigma A\): By the definition of \(prev\) and the interval property, u is adjacent to v in G and \({r}(A) >\ell (B) \). By Property 6, \(prev(B)<_P A\), therefore, \({\text {row}}(prev(B)\le {\text {row}}(A)) \). By Property 5, \({\text {row}}(A) \ge {\text {row}}(B) \). By Property 3, the equality cannot occur. Therefore, \({\text {row}}(A) >{\text {row}}(B) \).

Indeed, \(G({\mathcal {B}})\) is isomorphic to G.

Part (iv) follows by the construction of P. When \(B=C^\mathsf {{top}}_{j},j\ge 2\) is added on P, by Property 5, \(prev(B)<_P B\). We note that \(C^\mathsf {{top}}_{j-1} \le _P prev(B)\). We obtain \({\text {row}}(C^\mathsf {{top}}_{j-1}) \le {\text {row}}(C^\mathsf {{top}}_{j}) \) for every possible j. Also note that \({\text {row}}(\min _\sigma \mathscr {B}) ={\text {row}}(C^\mathsf {{top}}_{1}) =1\).

It remains to show the running-time of the algorithm. We note that \(prev\) can be easily computed by a single run over the representation, as well as the assigning columns can be done simultaneously by a single run over the representation (having \(prev\) and remembering top bubbles of columns). Moreover, rows are assigned by a single run over path P which leads to overall running time \(\mathcal {O}(n)\) where n is the number of intervals of the given mixed unit interval representation. \(\square \)

2.5 Proof of Theorem 1

Proof of Theorem 1

First, we prove the reverse implication: given a \({\mathcal {U}}\)-bubble model for a graph G, we construct a mixed unit interval representation of G. Let \({\mathcal {B}} = \langle B_{i,j}\rangle _{1\le j\le k, 1\le i\le r_j}\) be a \({\mathcal {U}}\)-bubble model of G. Let

$$\begin{aligned} \varepsilon {:}{=}\frac{1}{\max {\{r_j\mid 1\le j \le k\}}}. \end{aligned}$$

We create a mixed unit interval representation \({\mathcal {I}} \) of G as follows. Let \(v\in B_{i,j}^{r,s}\), where \(r,s\in \{+,-\}\). The corresponding interval \(I_v\) of v has the properties:

$$\begin{aligned} I_v\in {\mathcal {U}}\;^{r,s}\text { and }\ell (I_v) {:}{=}j+(i-1)\varepsilon . \end{aligned}$$

We note that all vertices from the same bubble are represented by intervals that are almost-twins and the type of an interval corresponds with the type of the bubble quadrant. Since \(\varepsilon \) was chosen such that \(\varepsilon (i-1) < 1\) for any row i in \({\mathcal {B}} \), the graph given by the constructed mixed unit interval representation is isomorphic to the graph given by \({\mathcal {B}}\). The forward implication follows from Lemma 9. \(\square \)

2.6 Properties of \({\mathcal {U}}\)-Bubble Model

In this section, we give basic properties of a \({\mathcal {U}}\)-bubble model which are used later in the text. It is readily seen that a \({\mathcal {U}}\)-bubble model of graph \(G=(V,E)\) has at most n rows and n columns where n is the number of vertices of G since each column and each row contains at least one vertex. Consequently, the size of a \({\mathcal {U}}\)-bubble model is at most \(n^2.\)

Two basic characteristics of a graph are the size of a maximum clique and the size of a maximum independent set in the graph. The problem of finding those numbers is \(\mathsf {NP}\)-complete in general but it is polynomial-time solvable in interval graphs. We show a relation between those two numbers and the size of a \({\mathcal {U}}\)-bubble model for the graph. We start with the size of a maximum independent set.

Lemma 10

Let G be a mixed unit interval graph, and let \({\mathcal {B}}\) be a \({\mathcal {U}}\)-bubble model for G. The number of columns of \({\mathcal {B}}\) is at least \({\alpha (G)}\) and at most \(2{\alpha (G)} \).

Proof

Let I be a maximum independent set of G, and let k be the number of columns of \({\mathcal {B}}\). We have that \({\alpha (G)} \ge \lceil k/2 \rceil \) from the property that two non-consecutive columns from \({\mathcal {B}}\) are not adjacent in \(G({\mathcal {B}})\). Since each column forms a clique, only one vertex from each column can be in I. Therefore, \({\alpha (G)} \le k.\) \(\square \)

In the bubble model for unit interval graphs, \({\alpha (G)} \) is equal to the number of columns [23]. However, the gap in Lemma 10 cannot be narrowed in general—consider an even number k and the following unit interval graphs: path on k-vertices (\(P_k\)) and a clique on k vertices (\(K_k\)). There exists a unit interval representation of \(P_k\) using only closed intervals which leads to a \({\mathcal {U}}\)-bubble model of \(P_k\) containing one row and k columns, where \({\alpha (P_k)} =\lceil k/2 \rceil \). A \({\mathcal {U}}\)-bubble model of \(K_k\) contains k rows and one column, where \({\alpha (K_k)} =1=\text {number of columns}\).

Another important and useful property of graphs is the size of a maximum clique. We show that a maximum clique of a mixed unit interval graph can be found in two consecutive columns of a \({\mathcal {U}}\)-bubble model of the graph, see Fig. 3.

Fig. 4
figure 4

A counterexample to the original algorithm, a bubble model \({\mathcal {B}}\) where the numbers denote the number of vertices in each bubble, and dashed lines indicate the edges between bubbles

Lemma 11

Let G be a mixed unit interval graph, and let \({\mathcal {B}}\) be a \({\mathcal {U}}\)-bubble model for G. Then the size of a maximum clique is

$$\begin{aligned} {\omega (G)}&= \max _{\begin{array}{c} j\in \{1, \dotsc , k-1\} \\ i\in \{1,\dotsc ,r_{j+1}\} \end{array}} {\left( \sum _{i'=i+1}^{r_j}|B_{i',j}| + \sum _{i'=1}^{i-1}|B_{i',j+1}| + a_i\right) },\\ a_i&= {\left\{ \begin{array}{ll} \max {\left\{ |B_{i,j}|, |B_{i,j+1}|, |B_{i,j}^{*+}| + |B_{i,j+1}^{+*}| \right\} } &{} i\le r_j,\\ |B_{i,j+1}| &{} \text {otherwise.} \end{array}\right. } \end{aligned}$$

Proof

Let K be a maximum clique of G. Notice, K does not contain two vertices from non-consecutive columns, as there are no edges between non-consecutive columns. Furthermore, vertices u and v from two consecutive columns \(C_j\) and \(C_{j+1}\), respectively, can be in K only if u is under v or they are in the same row in quadrants of types \(\{*+\}\) and \(\{+*\}\), respectively.

On the other hand, vertices from one column of \({\mathcal {B}} \) create a clique in \(G({\mathcal {B}}) \). Moreover, if we split any two consecutive columns \(C_j\) and \(C_{j+1}\) in row i (for any index \(i\in \{1,\ldots ,\min {\{r_j,r_{j+1}\}}\}\)), the second part of \(C_j\) with the first part of \(C_{j+1}\) form a clique. This is true even together with bubble quadrants \(B_{i,j}^{*+} \cup B_{i,j+1}^{+*}\). \(\square \)

3 Maximum Cardinality Cut

This section is devoted to the time complexity of the MaxCut problem on (mixed) unit interval graphs.

3.1 Notation

A cut of a graph G(VE) is a partition of V(G) into two subsets \(S, \bar{S}\), where \(\bar{S}=V(G)\setminus S\). Since \(\bar{S}\) is the complement of S, we say for the brevity that a set S is a cut and similarly we use terms cut vertexFootnote 3 and non-cut vertex for a vertex \(v\in S\) and \(v\in \bar{S}\), respectively. The cut-set of cut S is the set of edges of G with exactly one endpoint in S, we denote it \(E(S,\bar{S})\). Then, the value \(|E(S,\bar{S}) |\) is the cut size of S. A maximum (cardinality) cut on G is a cut with the maximum size among all cuts on G. Finally, the MaxCut problem is the problem of determining the size of the maximum cut.

3.2 Time Complexity is Still Unknown on Unit Interval Graphs

As it was mentioned in the introduction, there is a paper A polynomial-time algorithm for the maximum cardinality cut problem in proper interval graphs by Boyacı et al. from 2017 [7], claiming that the MaxCut problem is polynomial-time solvable in unit interval graphs and giving a dynamic programming algorithm based on the bubble model representation. We realized that the algorithm is incorrect; this section is devoted to it.

We start with a counterexample to the original algorithm.

Example

Let \({\mathcal {B}} = \langle B_{i,j}\rangle _{1\le j\le 2, 1\le i\le 2}\), where \(B_{1,1} = \{v_1\}\), \(B_{2,1}=\{v_2\}\), \(B_{1,2}=\{v_3,v_4,v_5\}\), \(B_{2,2}=\{v_6\}\), be a bubble model for a graph G, see also Fig. 4. In other words, this bubble model corresponds to a unit interval graph on vertices \(v_1, v_2,v_3,v_4,v_5,v_6\) where there is the edge \(v_1v_2\), and vertices \(v_2,v_3,v_4,v_5,v_6\) create a complete graph without the edge \(v_2v_6\).

Fig. 5
figure 5

A heavy part with light columns L and R and the highlighted subgraph \(G_i\)

Then, according to the paper [7], the size of a maximum cut in G is eight. To be more concrete, the algorithm from [7] fills the following values of dynamic table: \(F_{0,1}(0,0) = 4\), \(F_{2,1}(1,1) = 8\) for \(s_{2,1} = 1, s_{2,2}=1\), and finally, \(F_{0,0}(0,0) = 8\) which is the output of the algorithm. However, the size of a maximum cut in G is only seven. Suppose, for contradiction, that the size of a maximum cut is eight. As there are ten edges in total in G, at least one vertex of the triangle \(v_3,v_4,v_5\) must be a cut-vertex and one not. Then, those two vertices have three common neighbors. Therefore, the size of a maximum cut is at most seven which is possible; for example, \(v_1,v_4,v_5\) are cut-vertices.

The brief idea of the algorithm in [7] is to process the columns from the biggest to the lowest column from the top bubble to the bottom one. Once we know the number of cut-vertices in the actual processed bubble B (in the column j) and the number of cut-vertices which are above B in the columns j and \(j+1\), we can count the exact number of edges. For each bubble and each such number of cut-vertices in the columns j and \(j+1\) (above the bubble), we remember only the best values of MaxCutFootnote 4.

We claim that the algorithm and its full idea from [7] are incorrect since we lose the consistency there—to obtain a maximum cut, we do not remember anything about the distribution of cut vertices within bubbles, that was used in the previously processed column. Therefore, there is no guarantee that the final outputted cut of the computed size exists. To be more specific, one of two problems is in the moving from the column j to the column \(j-1\) since we forget there too much. The second problem is that for each bubble \(B_{i,j}\) and for each possible numbers \(x, x'\) we count the size \(F_{i,j}(x,x')\) of a specific cut and we choose some values \(s_{i,j}\), \(s_{i,j+1}\) (possibly different; they represents the number of cut-vertices in the bubbles \(B_{i,j}, B_{i,j+1}\)) which maximize the values of \(F_{i,j}(x,x')\). In few steps later, when we are processing the bubble \(B_{i,j-1}\), again, for each possible values y and \(y'\) we choose some values \(s'_{i,j-1}\) and \(s'_{i,j}\) such that they maximize the size of \(F_{i,j-1}(y, y')\). However, we need to be consistent with the selection in the previous column, i.e., to guarantee that \(s_{i',j} = s_{i,j}\) for any particular values y, \(y'=x,\) and \(x'\).

A straightforward correction of the algorithm would lead to remembering too much for a polynomial-time algorithm. However, we can be inspired by it to obtain a subexponential-time algorithm. We attempted to correct the algorithm or extend the idea leading to the polynomiality. However, despite lots of effort, we were not successful and it seemed to us that the presented algorithm is hardly repairable. We note here, that there is another paper by the same authors [8] where a very similar polynomial algorithm is used for MaxCut of co-bipartite chain graphs with twins. Those graphs can be viewed as graphs given by bubble models with two columns; but having two columns is a crucial property for the algorithm.

To conclude, the time complexity of the MaxCut problem on unit interval graphs is still not resolved and it seems to be a challenging open question.

3.3 Subexponential Algorithm in Mixed Unit Interval Graphs

Here, we present a subexponential-time algorithm for the MaxCut problem in mixed unit interval graphs. Our aim is to have an algorithm running in \(2^{\tilde{\mathcal {O}}(\sqrt{n})}\) time. Some of the ideas, for unit interval graphs, originated in discussion with Karczmarz, Nadara, Rzążewski, and Zych-Pawlewicz at Parameterized Algorithms Retreat of University of Warsaw 2019 [34].

Let us start with a notation. Let H be a graph, \(W\subseteq V(H)\), and \(S\subseteq W\), we say that a cut X of H agrees with S in W if \(X\cap W=S\). We denote the size of a maximum cut of H that agrees with S in W as \(mcs(H,S,W)\). Let G be a mixed unit interval graph. We take a \({\mathcal {U}}\)-bubble model \({\mathcal {B}} = \langle B_{i,j}\rangle _{1\le j\le k, 1\le i\le r_j}\) for G and we distinguish columns of \({\mathcal {B}}\) according to their number of vertices. We denote by \(b_{ij}\) the number of vertices in bubble \(B_{i,j} \) and by \(c_j\) the number of vertices in column j, i.e., \(b_{ij}=|B_{i,j} |\) and \(c_j = \sum _{i=1}^{r_j}{b_{i,j}}\). We call a column j with \(c_j>\sqrt{n}\) a heavy column, otherwise a light column. We call consecutive heavy columns and their two bordering light columns a heavy part of \({\mathcal {B}}\) (if \({\mathcal {B}}\) starts or ends with a heavy column, for brevity, we add an empty column at the beginning or the end of \({\mathcal {B}}\), respectively), and we call their light columns borders. A heavy part might contain no heavy columns in the case that two light columns are consecutive.

We note that we can guess all possible cuts in one light column without exceeding the aimed time and that most of those light column guesses are independent of each other—once we know the cut in the previous column, it does not matter what the cut is in columns before. Furthermore, there are at most \(\sqrt{n}\) consecutive heavy columns which allow us to process them together in subexponential time. More formally, we show that we can determine a maximum cut independently for each heavy part, given a fixed cut on its borders, as stated in the following lemma.

Lemma 12

Let G be a mixed unit interval graph and \({\mathcal {B}} =\langle B_{x,y}\rangle _{1\le y\le k, 1\le x\le r_y}\) be a \({\mathcal {U}}\)-bubble model for G where \(\hat{{\mathcal {B}}}_1, \ldots , \hat{{\mathcal {B}}}_{p}\) are heavy parts of \({\mathcal {B}} \) in this order. If \(S = S_0\cup \cdots \cup S_p\) is a (fixed) cut of light columns \(\mathcal {L}=C_{i_0}\cup C_{i_1}\cup \cdots \cup C_{i_p}\) in \(G({\mathcal {B}})\), where \(1\le i_0< \ldots < i_p\le k\), such that \(S_j\) is a cut of \(C_{i_j}\), \(j\in \{0,\ldots ,p\}\), then

$$\begin{aligned} mcs(G,S,\mathcal {L}) = \sum _{j=1}^{p}mcs(G(\hat{{\mathcal {B}}}_j),S_{j-1}\cup S_{j},C_{i_{j-1}}\cup C_{i_j}) - \left( \sum _{j=1}^{p-1}{|S_j|\cdot |C_{i_j}\setminus S_j|}\right) . \end{aligned}$$

Proof

It is readily seen that once we have a fixed cut in an entire column C of a bubble model, a maximum cut of columns which are to the left of C (including C) is independent on a maximum cut of those which are to the right of C (including C). Therefore, we can sum the sizes of maximum cuts in heavy parts which are separated by fixed cuts. However, the cut size of middle light columns is counted twice since they are contained in two heavy parts. Therefore, we subtract them. \(\square \)

Now, our aim is to determine the size of a maximum cut for a heavy part \(\hat{{\mathcal {B}}}\) given a fixed cut on its borders. This can be also achived by clique-width approach using results in [16] with a slightly worse running time; see Remark 1 for details. We note that if \(\hat{{\mathcal {B}}}\) is a heavy part with no heavy columns, we can straightforwardly count the number of cut-edges of \(G(\hat{{\mathcal {B}}})\) assuming a fixed cut on borders is given. Therefore, we are focusing on a situation where at least one heavy column is present in a heavy part. We use dynamic programming to determine the size of a maximum cut on each such heavy part.

Let \(\hat{{\mathcal {B}}}\) be a heavy part with \(h\ge 1\) heavy columns (for simplicity numbered by \(1,\ldots ,h\)) and borders L and R (we also refer to L and R as columns 0 and \(h+1\), respectively). First, we present a brief idea of the dynamic programming approach, followed by technical definitions and proofs later. We take bubbles in \(\hat{{\mathcal {B}}}\) which are not in borders and process them one-by-one in top-bottom, left-right order. When processing a bubble, we consider all the possibilities of numbers of cut-vertices in each its quadrant. We refer to the already processed part after i-th step as \(G_i\), that is, \(G_i\) is the induced subgraph of \(G(\hat{{\mathcal {B}}})\) with \(V(G_i)=B_1\cup \cdots \cup B_i\cup L \cup R\) where \(B_j\), \(j\in \{1,\ldots ,i\}\) are first i bubbles in top-bottom, left-right order in \(\hat{{\mathcal {B}}}\) (as it is shown in Fig. 5).

We store all possible \((h+1)\)-tuples \((s_1,s_2,\ldots ,s_h,a)\), where \(s_j\) characterizes the number of all cut vertices in (heavy) column j, and number a characterizes the number of cut vertices of types \((*,+)\) in the last processed bubble. Then, we define recursive function f where \(f_i\) will be related to the maximum size of a cut that has exactly \(s_j\) cut vertices in column j (for all j) in the already processed part \(G_i\). More precisely, we want the recursive function f to satisfy the properties later covered by Lemma 13. Once, f satisfies the desired properties, we easily obtain the size of a maximum cut in the heavy part (Theorem 14, below).

Now, we present a key observation for the construction of f. Observe, by the properties of \({\mathcal {U}}\)-bubble model, that the edges of \(G_i\) can be partitioned into following disjoint sets:

  • \(E_1=\{\)edges of the graph \(G_{i-1}\}\),

  • \(E_2=\{\)edges inside \(B_i\}\),

  • \(E_3=\{\)edges between \(B_i\) and the same column above \(B_i\}\),

  • \(E_4=\{\)edges between \(B_i\) and the next column above \(B_i\}\),

  • \(E_5=\{\)edges between \(B_i\) and the bubble in the previous column and the same row as \(\quad\quad\quad B_i\}\),

  • \(E_6=\{\)edges between \(B_i\) and column L below \(B_i\}\),

  • \(E_7=\{\)edges between \(B_i\) and the bubble in column R in the same row as \(B_i\}\).

Therefore, the idea there is to count the size of a desired cut of \(G_i\) using the sizes of possible cuts in \(G_{i-1}\) and add the size of a cut using edges \(E_2-E_7\). The former is stored in \(f_{i-1}\) and the later can be counted from the number of cut vertices in currently processed bubble \(B_i\) and numbers in the \((h+1)\)-tuple we are processing.

Now, let us properly define the function f and prove Theorem 2 formally. We develop more notation. Let \(B_1\),...,\(B_m\) be bubbles in \(\hat{{\mathcal {B}}}\setminus (L\cup R)\) numbered in the top-bottom, left-right order. Let \(S_L\) and \(S_R\) be (fixed) cuts in L and R. To handle borders, we define auxiliary functions \(n^{\downarrow }, n^{\leftarrow }, n^{\uparrow }\), \(n^{\rightarrow }\) which output the number of cut vertices in borders in a specific position depending on the given row and column; they output 0 if the given column is not next to the borders. We define:

  • the number of (fixed) cut vertices in L under row r (or 0 if the previous column is not L):

    $$\begin{aligned} n^{\downarrow }(r,c){:}{=}{\left\{ \begin{array}{ll} |S_L\cap \bigcup _{k=r+1}^{r_0}{B_{k,0}}| &{} c=1\\ 0 &{} c\ne 1, \end{array}\right. }\\ \end{aligned}$$
  • the number of (fixed) cut vertices of type \((*,+)\) in the left border L in row r:

    $$\begin{aligned} n^{\leftarrow }(r,c){:}{=}{\left\{ \begin{array}{ll} |S_L\cap B^{*,+}_{r,0}| &{} c=1\\ 0 &{} c\ne 1, \end{array}\right. } \end{aligned}$$
  • the number of (fixed) cut vertices in the right border R above row r:

    $$\begin{aligned} n^{\uparrow }(r,c){:}{=}{\left\{ \begin{array}{ll} |S_R\cap \bigcup _{k=1}^{r-1}{B_{k,h+1}}| &{} c=h\\ 0 &{} c\ne h, \end{array}\right. }\\ \end{aligned}$$
  • the number of (fixed) cut vertices of type \((+,*)\) in the right border R in row r:

    $$\begin{aligned} n^{\rightarrow }(r,c){:}{=}{\left\{ \begin{array}{ll} |S_R\cap B_{r,h+1}^{+,*}| &{} c=h\\ 0 &{} c\ne h. \end{array}\right. }\\ \end{aligned}$$

We denote the number of vertices in \(B_i\) by \(b_i {:}{=}|B_i|\), analogously \(b_i^{xy}{:}{=}|B_i^{xy}|\), \(x,y\in \{+,-\}.\) We further denote

$$\begin{aligned} \beta _i {:}{=}\big \{ (n_1,n_2,n_3,n_4) \mid \,&n_1 \in \{0,\ldots ,b_{i}^{++} \}, n_2 \in \{0,\ldots ,b_{i}^{+-} \}, n_3 \in \{0,\ldots ,b_{i}^{-+} \},\\&n_4 \in \{0,\ldots ,b_{i}^{--} \} \big \}. \end{aligned}$$

In addition, we denote the set of \((h+1)\)-tuples characterizing all possible counts of cut-vertices in the h heavy columns and an auxiliary number characterizing the count of possible edges from the last processed bubble, by

$$\begin{aligned} T=\big \{(s_1,\ldots ,s_h, a) &\mid a\in \mathbb {N},\, 0\le a\le \max _{i\in \{1,\ldots ,m\}}{(b_{i}^{-+} +b_{i}^{++})},\,\\&\quad\forall j\in \{1,\ldots ,h\}: s_j\in \mathbb {N},\, 0\le s_j \le c_j \big \}. \end{aligned}$$

Let \(e(s_1,s_2)\) denote the number of cut-edges between two sets \(S_1\), \(S_2\) which are complete to each other and \(S_k\), \(k\in \{1,2\}\), contains \(s_k\) cut vertices and \(\overline{s_k}\) non-cut vertices, i.e., \(e(s_1,s_2) = s_1\cdot \overline{s_2}+\overline{s_1}\cdot s_2.\) We remark that it is important to know the numbers of non-cut vertices (\(\overline{s_1}\) and \(\overline{s_2}\)), however, we will not write them explicitly for the easier formulas. It will be seen that they can be, for instance, stored in parallel with the numbers of cut vertices (or counted in each step again).

Finally, we define a recursive function f by the following recurrence relation:

$$ \begin{aligned} &\forall (s_1,\ldots ,s_h, a)\in T{:} \\ &\qquad\quad {\text{if }} s_1 \le b_{1}, s_2=\cdots =s_h=0:\\ &\qquad\quad\qquad f_1((s_1,\ldots ,s_h, a))= \max _{\begin{subarray}{c} (b_{}^{++},b_{}^{-+},b_{}^{+-},b_{}^{--})\in \beta _1:\\ b_{}^{++} +b_{}^{-+} +b_{}^{+-} +b_{}^{--} =s_1,\\ b_{}^{++} +b_{}^{-+} = a \end{subarray}} { \begin{aligned} \bigg (&e\left( s_1, n^\downarrow (1,1)\right) + s_1\cdot (b_1-s_1) \\&+ e\left( n^\leftarrow (1,1),(b_{}^{++} +b_{}^{+-})\right) \\&+ e\left( n^\rightarrow (1,1), b_{}^{++} +b_{}^{-+} \right) \bigg ), \end{aligned} }\\ &\qquad\quad{\text{otherwise}}{:}\\ &\qquad\quad\qquad f_1((s_1,\ldots ,s_h, a))= -\infty .\\ &\forall i\in \{2,\ldots ,m\}, \forall (s_1,\ldots ,s_h, a)\in T:\\&\qquad\quad f_i((s_1,\ldots ,s_h,a))= \max _{ \begin{subarray}{c} (b_{}^{++},\,b_{}^{+-},\,b_{}^{-+},\,b_{}^{--}) \in \beta _i,\, z\in \mathbb {N}:\\ b_{}^{++} + b_{}^{-+} = a,\\ (s_1,\ldots ,s_c-b,\ldots ,s_h,z)\in T,\\ z\le |B_{i-1}^{*+}|\\ \end{subarray}} \begin{aligned} \bigg (&f_{i-1}((s_1,\ldots ,s_c-b,\ldots ,s_h,z)) \\&+ b\cdot (b_i-b) \\&+ e(b,s_{c+1}) + e(b,s_c-b) \\&+ e\left( n^\downarrow (r,c), b \right) \\&+ e\left( n^\leftarrow (r,c),(b_{}^{++} +b_{}^{+-}) \right) \\&+ e\left( (b_{}^{++} +b_{}^{-+}), n^\rightarrow (r,c) \right) + A \bigg ) \end{aligned}\\ &\qquad\quad{\text{where }} A = {\left\{ \begin{array}{ll} e(z\, , b_{}^{++} +b_{}^{+-}) &{} i>1,\, c={\text {col}}(B_{i-1}) +1,\\ 0 &{} \text {otherwise,} \end{array}\right. }\\ &\qquad\quad{\text{and }} b = b_{}^{++} +b_{}^{+-} +b_{}^{-+} +b_{}^{--}, c = {\text {col}}(B_i), r= {\text {row}}(B_i), \text { and } s_{h+1}= n^{\uparrow }(r,c). \end{aligned} $$

Recall that \(G_i\) denotes the induced subgraph of \(G(\hat{{\mathcal {B}}})\) with \(V(G_i)=B_1\cup \cdots \cup B_i\cup L \cup R.\)

Lemma 13

For each \(s=(s_1,\ldots ,s_h, a) \in T\) and for every \(i \in \{1,\ldots ,m\}\), the value \(f_i(s)\) is equal to the maximum size of a cut S in \(G_i\) that satisfies the following

  • for every \(j\in \{1,\ldots ,h\}\), the number of cut vertices in the column j in \(G_i\) is equal to \(s_j\), and S agrees with \(S_L\cup S_R\) in \(L\cup R\), and

  • a is equal to the number of cut vertices from \(B_{i}^{++} \cup B_{i}^{-+} \),

or \(f_i\) is equal to \(-\infty \) if there is no such cut.

Proof

We prove Lemma 13 by induction on the number of steps (bubbles). Since \(B_1\) is in the first heavy column, Lemma 13 is true for \(i=1\) by Definition 5 (iv).

In the inductive step, suppose that for every \(s=(v_1,v_2,\ldots ,v_h, z)\in T\), \(f_{i-1}(s)\) is equal to the size of a maximum cut \(S_{i-1}\) in \(G_{i-1}\) such that the number of cut vertices in each column j, for every \(j\in \{1,2,\ldots ,h\}\), in \(G_{i-1}\) is equal to \(v_j\), and the number of cut vertices from \(B_{i-1}^{*+}\) is equal to z. Or \(f_{i-1}(s)\) is equal to \(-\infty \) if such a cut does not exist.

As it was mentioned, the edges of \(G_i\) can be partitioned into disjoint sets \(E_1\)\(E_7\). Recall:

  • \(E_1=\{\)edges of the graph \(G_{i-1}\}\),

  • \(E_2=\{\)edges inside \(B_i\}\),

  • \(E_3=\{\)edges between \(B_i\) and the same column above \(B_i\}\),

  • \(E_4=\{\)edges between \(B_i\) and the next column above \(B_i\}\),

  • \(E_5=\{\)edges between \(B_i\) and the bubble in the previous column and the same row as \(B_i\}\),

  • \(E_6=\{\)edges between \(B_i\) and column L below \(B_i\}\),

  • \(E_7=\{\)edges between \(B_i\) and the bubble in column R in the same row as \(B_i\}\).

We note that \(E_6\) is non-empty only if \(B_i\) is in the column 1, similarly \(E_7\) is non-empty only if \(B_i\) is in the column h. Let \(s=(s_1,\ldots ,s_h,a)\in T\) be fixed. At first assume, S is a maximum cut in \(G_i\) (that agrees with \(S_L\cup S_R\) in \(L\cup R\)) such that it contains \(s_j\) vertices from the column j for each \(j\in \{1,2,\ldots ,h\}\) and a vertices from \(B_i^{*+}\); we say S satisfies the conditions s. We discuss the case where no such cut exists, later. We denote by \(s^{xy}\) the number of vertices in \(B_i^{xy}\cap S\), \(x,y\in \{+,-\}\), and by \(s'\) the sum of these values, i.e., \(s'=s^{++}+s^{+-}+s^{-+}+s^{--}\). We denote \({\text {col}}(B_i) \) by j, and \({\text {row}}(B_i) \) by r. Then,

$$\begin{aligned} E(S,\overline{S}) = (E(S,\overline{S})\cap E(G_{i-1}) ) \cup \left\{ uv\in E_k \mid u\in S,v\notin S, k\in \{2,\ldots ,6\}\right\} . \end{aligned}$$

Which leads to the expression:

$$\begin{aligned} |E(S,\overline{S})| &=|E(S,\overline{S})\cap E(G_{i-1})| \\&+ s' \cdot (b_i-s')\\&+ e(s', (s_j-s')) \\&+ e(s', s_{j+1}) \\&+ A \\&+ e(s', n^{\downarrow }(r,j)) + e(s^{++}+s^{+-}, n^{\leftarrow }(r,j)) \\&+ e(s^{++}+s^{-+}, n^{\rightarrow }(r,j)),\\ \text { where }A &={\left\{ \begin{array}{ll} e(|S\cap B_{i-1}^{*+}|, s^{++}+s^{+-}) &{} j={\text {col}}(B_{i-1}) +1,\\ 0 &{} otherwise. \end{array}\right. } \end{aligned}$$

By the induction hypothesis,

$$\begin{aligned} |E(S,\overline{S})\cap E(G_{i-1})| \le f_{i-1}(s_1,\ldots ,s_j-s',\ldots ,s_h, |S\cap B_{i-1}^{*+}|). \end{aligned}$$
(1)

It gives us together with the right part of the equation, the definition of \(f_i\) for \(b^{xy}=s^{xy}\), \(b=s'\) and \(z=|S\cap B_{i-1}^{*+}|\). Therefore,

$$\begin{aligned} |E(S,\overline{S})|\le f_i(s). \end{aligned}$$

Furthermore, we show that \(f_i(s)\) is the size of a cut satisfying the conditions s. Since the value of the function \(f_{i-1}((s_1,\ldots ,s_j-b,\ldots ,s_h, z))\) is for any number \(b\in \{0,\ldots ,\min {(s_j,b_i)}\}\) a size of a cut in \(G_{i-1}\) which satisfies the conditions \((s_1,\ldots ,s_j-b,\ldots ,s_h, z)\), or \(-\infty \) (if no such cut exists), we can extend that cut into \(G_i\) by adding \(b^{xy}\) vertices from \(B_i^{xy}\) where \(b_{}^{++} +b_{}^{-+} =a\) and \(b_{}^{++} +b_{}^{+-} +b_{}^{-+} +b_{}^{--} =b\). Consequently, \(f_i(s)\) is a size of a cut on \(G_i\) satisfying that it contains \(s_i\) vertices from the column i and a vertices from \(|B_{i}^{*+}|\). At least one such cut exists, by (1). Therefore, \(|E(S,\overline{S})|\ge f_i(s)\). It leads to the equation \(|E(S,\overline{S})|= f_i(s)\), otherwise, S is not a maximum cut.

In a similar way, we can extend every cut on \(G_{i-1}\) to \(G_i\). Therefore, if there exist no cut on \(G_i\) which satisfies the conditions s, there exists no cut in \(G_{i-1}\) which can be extended to the cut on \(G_i\) satisfying the conditions s. Consequently, \(f_i(s)=-\infty \) by the definition of f since \(f_{i-1}(v)=-\infty \) for all \((h+1)\)-tuples v which appear in the definition. \(\square \)

Finally, we obtain the next theorem about a maximum cut of a heavy part as a corollary of Lemma 13.

Theorem 14

Let \(\hat{{\mathcal {B}}}\) be a heavy part with \(h\ge 1\) heavy columns (numbered by \(1,\ldots ,h\)) and borders L and R. Let \(B_1\),...,\(B_m\) be bubbles in \(\hat{{\mathcal {B}}}\setminus (L\cup R)\) numbered in the top-bottom, left-right order. Let \(S_L\) and \(S_R\) be (fixed) cuts in L and R. Then,

$$\begin{aligned} mcs(G(\hat{{\mathcal {B}}}), S_L\cup S_R, L\cup R) = \max _{s\in T} f_m(s). \end{aligned}$$

Towards proving Theorem 2 and Corollary 3, it remains to prove the time complexity of processing a heavy part.

Lemma 15

Let \(\hat{{\mathcal {B}}}\) be a heavy part with \(h\ge 1\) columns, m bubbles, and a fixed cut in the borders. The size of a maximum cut of \(\hat{{\mathcal {B}}}\) that agrees with the fixed cut in the borders can be determined in time:

$$\begin{aligned} (c_1+1)\ldots (c_h+1)\cdot (a+1) \cdot \sum _{i=1}^m{\left( b_{i}^{++} \cdot b_{i}^{+-} \cdot b_{i}^{-+} \cdot b_{i}^{--} \right) } \end{aligned}$$

where \(c_j\) is the number of vertices in the column j, i.e., \(c_j = \sum _{i'=1}^{r_j}B_{i',j}\), and \(a = \max _{i}{|B_i^{*+}|}\).

Proof

We analyze the time complexity of the algorithm from Lemma 15. Let T denote all the possible \((h+1)\)-tuples. Then \(|T| = (c_1+1)\ldots (c_h+1)\cdot (a+1).\) The time for processing a bubble \(B_i\) is \(|T|\cdot b_{i}^{++} \cdot b_{i}^{+-} \cdot b_{i}^{-+} \cdot b_{i}^{--} \). The time complexity of processing \(\hat{{\mathcal {B}}}\) is then

$$\begin{aligned} |T|\cdot \sum _{i=1}^m{b_{i}^{++} \cdot b_{i}^{+-} \cdot b_{i}^{-+} \cdot b_{i}^{--}}. \end{aligned}$$

\(\square \)

Now, we are ready to prove Theorem 2.

Proof of Theorem 2

By Lemma 12, heavy parts can be processed independently on each other, given a cut on their borders. Moreover, it is sufficient for a light column C to remember only the biggest cuts on the left of C (containing C) for each possible cut in C. Therefore, there is no need to guess cuts in all light columns at once. It is sufficient to guess a cut only in two consecutive light columns at once.

Observe that there are at most \(2^{\sqrt{n}}\) guesses of cut vertices for a light column and there are at most n light columns. Therefore, the time complexity of determining the size of a maximum cut in G is at most \(n\cdot (2^{\sqrt{n}})^{2} \cdot P,\) where P is the maximum time for processing a heavy part. Now, we want to prove a time complexity of processing a heavy part \(\hat{{\mathcal {B}}}= \langle B_{i,j}\rangle _{1\le j\le l, 1\le i\le r_j}\) with a given guess of light columns.

By Lemma 15, the time complexity of processing a heavy part with a given guess of light columns is

$$\begin{aligned} P&=(c_1+1)\ldots (c_h+1)\cdot (a+1)\cdot \sum _{i=1}^m{\left( b_{i}^{++} \cdot b_{i}^{+-} \cdot b_{i}^{-+} \cdot b_{i}^{--} \right) }\\&\le (n+1)^{1+\sqrt{n}}\cdot \sum _{i=1}^m{b_i^4} \le (n+1)^{1+\sqrt{n}} \cdot n^4 \in \mathcal {O}\left( n^5 \, 2^{\sqrt{n}\log (n)}\right) . \end{aligned}$$

To sum up, we can determine the size of a maximum cut in time:

$$\begin{aligned} n\cdot (2^{\sqrt{n}})^{2} \cdot P\in \mathcal {O}\left( n^6 \, 2^{\sqrt{n}(\log (n)+2)}\right) . \end{aligned}$$
(2)

For brevity, we analyzed only the size of a maximum cut. However, the maximum cut itself can be determined retroactively in the same running time. \(\square \)

Remark 1

We wish to point out that Theorem 2 with slightly worse bound of \(n^{\mathcal {O}(1)} \, 2^{2\sqrt{n}(\log (n)+1)}\) can be derived by combination of the maxcut algorithm parameterized by the clique-width as presented in [16] together with our bounds on the clique-width expressed by the number of columns of the model (Corollary 22), and Lemma 12.

More precisely, the heavy part is composed of at most \(\sqrt{n}\) columns plus two additional light columns. Therefore, by Corollary 22 the clique-width of the heavy part is bounded by \(\sqrt{n}+5\). As the algorithm in [16] can be easily modified to determine the maximum cut size even when the cut on the light columns is given, we conclude by Lemma 12 and the expression in (2) where \(P=n^{\mathcal {O}(1)}\, n^{2(\sqrt{n}+5)}\).

Lemma 15 has a nice corollary for graphs with a \({\mathcal {U}}\)-bubble model with a constant number of columns. According to Lemma 15, we are able to solve the MaxCut problem in those graphs in polynomial time which is formulated as Corollary 3 in the introduction. Therefore, we improved another polynomial-time algorithm by Boyacı et al. [8] solving the MaxCut problem in co-bipartite chain graphs with possible twins (which is exactly the class of graphs defined by a classic bubble model with only two columns).

Proof of Corollary 3

Let G be a graph on n vertices which is defined by a \({\mathcal {U}}\)-bubble model \({\mathcal {B}} \) with k columns and m bubbles. The bubble model \({\mathcal {B}} \) can be seen as a heavy part with no cut-vertices in its borders. By Lemma 15, the size of a maximum cut in \({\mathcal {B}}\) can be determined in time \(T= (c_1+1)\ldots (c_k+1)\cdot (a+1) \cdot \sum _{i=1}^m{\left( b_{i}^{++} \cdot b_{i}^{+-} \cdot b_{i}^{-+} \cdot b_{i}^{--} \right) }\) where \(b_i^{xy}, xy\in \{+,-\}\) is the number of vertices in the bubble quadrant \(B_i^{xy},\) and \(c_j\) is the number of vertices in the column j, i.e., \(c_j = \sum _{i'=1}^{r_j}B_{i',j}\), and \(a = \max _{i}{|B_i^{*+}|}\).

By Arithmetic Mean-Geometric Mean Inequality (AM-GM) we obtain

$$\begin{aligned} T&\le (a+1)\cdot \left( \frac{1}{k}\cdot \sum _{j=1}^{k}(c_j+1)\right) ^k \cdot \sum _{i=1}^m{\left( \frac{b_{i}^{++} + b_{i}^{+-} + b_{i}^{-+} + b_{i}^{--}}{4}\right) ^4}\\&=(a+1)\cdot \left( \frac{n+k}{k} \right) ^k \cdot \sum _{i=1}^{m}\left( \frac{{b_i}}{4} \right) ^4\\&\le (a+1)\cdot \left( \frac{n+k}{k} \right) ^k \cdot \left( \frac{n}{4} \right) ^4 \in \mathcal {O}(n^{k+5}). \end{aligned}$$

It remains to prove the special case where \(k=2.\) Notice, it is sufficient to distinguish only between vertices in quadrants of types \((*,+)\) and \((*,-)\) in the first column, and similarly \((+,*)\) and \((-,*)\) in the second column. Therefore, we obtain \(\left( \frac{{b_i}}{2} \right) ^2\) instead of \(\left( \frac{{b_i}}{4} \right) ^4\) which leads to the time complexity \(\mathcal {O}(n^{k+1+2})=\mathcal {O}(n^5).\) \(\square \)

We note that Theorem 14 states the explicit size of a maximum cut.

4 Clique-Width Of Mixed Unit Interval Graphs

The clique-width is one of the parameters which are used to measure the complexity of a graph. Many \(\mathsf {NP}\)-hard problems, those which are expressible in Monadic Second-Order Logic using second-order quantifiers on vertices (\(MSO_1\)), can be solved efficiently in graphs of bounded clique-with [11]. For instance, 3-coloring. Definition of the clique-width is quite technical but it follows the idea that a graph of the clique-width at most k can be iteratively constructed such that in any time, there are at most k types of vertices, and vertices of the same type behave indistinguishably from the perspective of the newly added vertices.

Definition 6

(Courcelle 2000). The clique-width of a graph G, denoted by \(cwd(G)\), is the smallest integer number of different labels that is needed to construct the graph G using the following operations:

  1. 0.

    creation of a vertex with label i,

  2. 1.

    disjoint union (denoted by \(\oplus \)),

  3. 2.

    relabeling: renaming all labels i to j (denoted by \(\rho _{i\rightarrow j}\)),

  4. 3.

    edge insertion: connecting all vertices with label i to all vertices with label j, \(j\in \{1,\ldots ,k\},\) \(i\ne j\); already existing edges are not doubled (denoted by \(\eta _{i,j}\)).

Such a construction of a graph can be represented by an algebraic term composed of the operations \(\oplus \), \(\rho _{i\rightarrow j}\), and \(\eta _{i,j}\), called cwd-expression. We call k-expression a cwd-expression in which at most k different labels occur. Using this, we can say that the clique-width of a graph G is the smallest integer k such that the graph G can be defined by a k-expression.

Example

The diamond graph G on the four vertices uvwx (the complete graph \(K_4\) without the edge vw) is defined by the following cwd-expression:

$$\begin{aligned} \eta _{1,2}(\rho _{2\rightarrow 1}(\eta _{1,2}( 1(u) \oplus 2(v) \oplus 2(w)))\oplus 2(x)). \end{aligned}$$

Therefore, \(cwd(G)\le 2\).

Fellows et al. [15] proved in 2009 that the deciding whether the clique-width of a graph G is at most k is \(\mathsf {NP}\)-complete. Therefore, researchers put effort into computing an upper-bound of the clique-width.

Courcelle and Olariu [12] showed in 2000 that bounded treewidth implies bounded clique-width (but not vice versa). They showed that for any graph G with the treewidth k, the clique-width of G is at most \(4 \cdot 2^{k-1} + 1\).

Golumbic and Rotics [20] proved that unit interval graphs have unbounded clique-width via a construction that can be described as a bubble model where all bubbles contains exactly one vertex. Consequently, (mixed unit) interval graphs have unbounded clique-width as well. Therefore, computing upper-bounds are of particular interest. Fellows et al. [14] showed that the clique-width of a graph is bounded by its pathwidth + 2, therefore, the clique-width of interval graphs as well as of unit interval graphs is upper-bounded by the size of their maximum clique + 1 [14, 26]. Using a bubble model structure, subclasses of unit interval graphs were characterized in terms of (linear) clique-width [30, 32]. Courcelle [12] observed that clique-width can be computed componentwise.

Lemma 16

(Courcelle [12]). Any graph G satisfies that

$$\begin{aligned} cwd(G) = max{\{cwd(G') \mid G' \text { is a connected component of } G\}}. \end{aligned}$$

We provide an upper-bound of the clique-width of a graph G depending on the number of columns in a \({\mathcal {U}}\)-bubble model of G. We express it also in the size of a maximum independent set.

Lemma 17

Let G be a mixed unit interval graph and \({\mathcal {B}}\) be a \({\mathcal {U}}\)-bubble model of G. Then \(cwd(G)\le k + 3\), where k is the number of columns of \({\mathcal {B}}\). Moreover, a \((k+3)\)-expression defining the graph G can be constructed in \(\mathcal {O}(n)\) time from \({\mathcal {B}}\).

Proof

The proof is inspired by the proof for unit interval graphs [23].

We find a \((k+3)\)-expression defining G and, therefore, prove that \(cwd(G)\le k + 3\). We use \(k+3\) labels where label i will be assigned to i-th column of \({\mathcal {B}}\) and the remaining three labels, denoted by \(l_1, l_2, l_3\), are used for maintaining the last two added vertices.

We define a linear order on vertices of G according to \({\mathcal {B}}\) as follows:

  1. (i)

    We take the vertices from top to bottom, left to right. Formally, let \(x\in B_{i,j},\) \(y\in B_{l,m}\), we define \(x\prec y\) if \(i<l\) or \((i=l \text { and } j<m);\)

  2. (ii)

    we define the following order on bubble quadrants:

    $$\begin{aligned} x\prec y\prec z\prec w\text { for } x\in B_{i,j}^{--}, y\in B_{i,j}^{+-}, z\in B_{i,j}^{-+}, w\in B_{i,j}^{++}; \end{aligned}$$
  3. (iii)

    we define an arbitrary linear order on vertices in the same quadrant of the same bubble.

The idea of the proof is that every column has its own label and we need three more labels for maintaining the last added vertices. We will add vertices to G in the described order which ensures that a new vertex is complete to all vertices from the following column and anti-complete to all vertices from the previous column except those from the same row. Recall that according to the definition of \({\mathcal {U}}\)-bubble model, there is an edge between vertices \(x\in B_{i,j}\) and \(y\in B_{i,j+1}\) if and only if \(x\in B_{i,j}^{*,+}\) and \(y\in B_{i,j+1}^{+*}\). Therefore, vertices from the last constructed bubble in the previous column must have two distinct labels according to the types of the vertices. However, once we add all vertices from the actual bubble, we do not need to distinguish between vertices from the previous column, anymore. Therefore, we rename their labels to the label of their column.

Formally. Let x be the first (smallest) vertex of G according to the defined linear order. We know that x is from the first column by Definition 5 (iv). If x is of type \((-,+)\) or \((+,+)\), we label it by \(l_1\), otherwise by 1, so the expression for \(G[\{x\}]\) is 1(x) if x is of type \((+,-)\) or \((-,-)\), and \(l_1(x)\) otherwise.

Let y be the first non-processed vertex from G, i.e., a label is assigned to all preceding vertices. Let \(l_2, l_3 \in \{k+1, k+2, k+3\}\) are currently unused labels or \(l_2\) is used in the actual bubble \(B_{i,j}\) and \(l_3\) is unused, and \(l_1\) may be used (in the previous column). We note that at most one label from \(\{k+1,k+2,k+3\}\) is used in the previous column any time. We split the proof according to the type of y, the bubble quadrant where y belongs.

  1. (a)

    \(y\in B_{i,j}^{--}\). We use label \(l_2\) for y. Then, we make y (the only one vertex with label \(l_2\)) complete to vertices with labels \(j+1\) (if \(j<k\)) and j. Relabel \(l_2\) to j.

  2. (b)

    \(y\in B_{i,j}^{+-}\). We use label \(l_2\) for y. Then, we make y (the only one vertex with label \(l_2\)) complete to vertices with labels \(j+1\) (if \(j<k\)), j, \(l_1\). Relabel \(l_2\) to j.

  3. (c)

    \(y\in B_{i,j}^{-+}\). We use label \(l_2\) for y. Then, we make all vertices with label \(l_2\) complete to vertices with labels \(j+1\) (if \(j<k\)), j, \(l_2\). (Do not relabel vertices with label \(l_2\)).

  4. (d)

    \(y\in B_{i,j}^{++}\). We use label \(l_3\) for y. Then, we make y (the only one vertex with label \(l_3\)) complete to vertices with labels \(j+1\) (if \(j<k\)), j, \(l_1\), \(l_2\). Relabel \(l_3\) to \(l_2\).

If all vertices from \(B_{i,j}\) were used, we rename all vertices with the label \(l_1\) to \(j-1\) if \(j>1.\) If \(j=k\), we relabel \(l_2\) to k.

For the correctness, observe that the previous column has always at most two labels and in a), b), and d) the temporary label for y is unique (no other vertices are labeled by it at that time). The rest follows from the definition of adjacency in the \({\mathcal {U}}\)-bubble model. Since we constructed G using at most \(k+3\) labels, \(cwd(G)\le k+3\).

The described algorithm processes each vertex once and each vertex has at most three labels in total. Moreover, the algorithm needs a constant work for each vertex—for instance, a cwd-expression for the option a) is:

$$\begin{aligned} \rho _{l_2\rightarrow j}(\eta _{j,l_2}(\eta _{j+1,l_2}(l_2(y)\oplus G'))), \end{aligned}$$

where \(G'\) is the already constructed graph before adding the vertex y. Therefore, the \((k+3)\)-expression defining G is constructed in linear time given a \({\mathcal {U}}\)-bubble model in an appropriate structure. \(\square \)

Theorem 18

Let G be a mixed unit interval graph. Then \(cwd(G)\le 2{\alpha (G)} + 3\). Moreover, a \((2{\alpha (G)} +3)\)-expression defining the graph G can be constructed in \(\mathcal {O}(n)\) time provided a \({\mathcal {U}}\)-bubble model of G is given.

Proof

We apply Lemma 17 and Lemma 10 together to obtain the statements. \(\square \)

Next, we provide a different bound for clique-width which is obtained by a small extension of the proof for unit interval graphs using the bubble model by Heggernes et al. [23]. We include the full proof for completeness.

We need more notation. Let G be a mixed unit interval graph and let \({\mathcal {B}} = \langle B_{i,j}\rangle _{1\le j\le k, 1\le i\le r_j}\) be a \({\mathcal {U}}\)-bubble model for G. We say that vertices from the same column j of \({\mathcal {B}} \) create a group if they have the same neighbours in the following column \(j+1\) of \({\mathcal {B}}\). Let \(v\in B_{i,j} \), the group number of vertex v in \({\mathcal {B}}\), denoted by \(g_{\mathcal {B}} (v)\), is defined as the maximum number of groups in \(N(v)\cap \big ( \bigcup _{i'=i+1}^{r_{j-1}} B_{i',j-1} \cup \bigcup _{i'=1}^{i-1} B_{i',j} \cup A \big )\) over the sets \(A= B_{i,j-1}^{*+}\cup B_{i,j}^{+*}\) and \(A= B_{i,j}\). Then the group number of G in \({\mathcal {B}}\) is defined as

$$\begin{aligned} \varphi _{\mathcal {B}} (G) {:}{=}\max _{v\in V(G)}{g_{\mathcal {B}} (v)}. \end{aligned}$$

Lemma 19

Let G is a mixed unit interval graph and \({\mathcal {B}}\) a \({\mathcal {U}}\)-bubble model for G. The following inequality holds

$$\begin{aligned} \varphi _{\mathcal {B}} (G) \le {\omega (G)} - 1. \end{aligned}$$

Proof

Let \(v\in B_{i,j}.\) Observe that \(\bigcup _{i'=i+1}^{r_{j-1}} B_{i',j-1} \cup \bigcup _{i'=1}^{i-1} B_{i',j} \cup A \cup \{v\}\) is a clique (for both the possibilities of A), see Lemma 11. Moreover, v is not included in the counting the group number of v, and no vertex can be in more than one group. Therefore, \(g_{\mathcal {B}} (v) \le {\omega (G)} - 1\) for any vertex v which leads to the desired inequality. \(\square \)

Theorem 20

Let G be a mixed unit interval graph and \({\mathcal {B}}\) a \({\mathcal {U}}\)-bubble model for G. Then \(cwd(G)\le \varphi _{\mathcal {B}} (G)+2.\) Moreover, a \((\varphi _{\mathcal {B}} (G)+2)\)-expression defining the graph G can be constructed in \(\mathcal {O}(n+m)\) time provided a \({\mathcal {U}}\) -bubble model of G is given.

Proof

Our aim is to find a \((\varphi _{\mathcal {B}} (G)+2)\)-expression defining G. We add vertices in the order from left to right, top to bottom of \({\mathcal {B}}\) processing vertices of type \((+,*)\) at first, i. e., in the following linear order:

  1. (i)

    \(x\prec y\) for \(x\in B_{i,j},\) \(y\in B_{l,m}\), where \(j<m\) or \((j=m \text { and } i<l);\)

  2. (ii)

    \(x\prec y\prec z\prec w\text { for } x\in B_{i,j}^{++}, y\in B_{i,j}^{+-}, z\in B_{i,j}^{-+}, w\in B_{i,j}^{--}; \)

  3. (iii)

    an arbitrary linear order on the vertices in the same quadrant of the same bubble.

Now, we follow the original proof. Shortly, we add each vertex v in a proper way. We assume that a label is assigned for each previous vertex and all the vertices which belong to the same group have the same label. At first, we change to 1 the label of all the previous vertices which are non-adjacent to v. We know that at most \(g_{\mathcal {B}} (v)\) distinct labels are used in the remaining groups, say labels \(\{2,\ldots ,g_{\mathcal {B}} (v)+1\}\). This is true since all the groups are adjacent to v and because of the linear order.

We note that it is important to add first all the vertices of type \((+,*)\) from a bubble. Otherwise, \(g_{\mathcal {B}} (v)+1\) remaining groups could be there; in the situation that v is of type \((+,*)\), a potentially one distinct label is needed for \(B_{i,j-1}^{*+}\), and another for \(B_{i,j}^{*-}\). One the other hand, if all the vertices of type \((+,*)\) precede vertices of type \((-,*)\) in one bubble, this situation does not happen—a potential label of \(B_{i,j-1}^{*+}\) would be released. Therefore, it is enough to take into account only the parts \(A= B_{i,j-1}^{*+}\cup B_{i,j}^{+*}\), and \(A= B_{i,j}\), and not the bigger one \(A= B_{i,j-1}^{*+}\cup B_{i,j}\), in the definition of \(g_{\mathcal {B}} (v)\).

We use a free label, say \(g_{\mathcal {B}} (v)+2\), for v and join all the vertices with this label with vertices with labels \(2,\ldots ,g_{\mathcal {B}} (v)+1\). Next, change the label of v to a label of its group if v belongs to an already existing group. We continue with the next vertex. During the processing of each vertex, we need no more than its group number + 2 distinct labels. Therefore, \(cwd(G)\le \varphi _{\mathcal {B}} (G)+2.\)

It remains to determine the running time for the construction of the expression defining G. Assume a \({\mathcal {U}}\)-bubble model is given in a way that going over all vertices takes linear time in the number of vertices. First, we count the time for the creation of groups. For each vertex v we compare its neighbors from the next column with the neighbors of the previous vertex in this column. Therefore, the splitting vertices into groups and determining the group number of G take \(\mathcal {O}(m+n)\) time. In a constant time, we determine a free label for each vertex. Then, we need to check the labels of groups in the neighborhood of each vertex v and create a \(\mathcal {O}(g_{\mathcal {B}} (v))\) long cwd-expression, yielding \(\mathcal {O}(m+n)\) time in total. Furthermore, each vertex is at most once relabeled to 1 since once it is relabeled to 1, its label remains 1 for the rest of the algorithm. Therefore, the relabeling of vertices that are non-adjacent to a newly added vertex takes \(\mathcal {O}(n)\) time in total. To sum up, the algorithm outputs the construction in \(\mathcal {O}(n+m)\) time. \(\square \)

The combination of Theorems 18 and 20 gives us the following upper-bound that can be compared with the known upper-bound \({\omega (G)} + 1\) [14, 26].

Theorem 21

Let G be a mixed unit interval graph. Then

$$\begin{aligned} cwd(G) \le \min {\{ 2{\alpha (G)} +3, \varphi _{\mathcal {B}} (G) + 2 \}} \le {\omega (G)} + 1, \end{aligned}$$

where \({\mathcal {B}} \) is a \({\mathcal {U}}\)-bubble model for G. Moreover, the corresponding expression can be constructed in \(\mathcal {O}(n+m)\) time provided \({\mathcal {B}}\) is given, otherwise in \(\mathcal {O}(n^2)\) time.

Observe that \(\varphi _{\mathcal {B}} (G)\le 2\max {\{r_j \mid 1\le j\le k\}}\). A combination of Theorem 21 and Lemma 17 gives a useful Corollary 22. In particular, if the number of rows or number of columns is bounded, than clique-width is bounded.

Corollary 22

Let G be a mixed unit interval graph. Then \(cwd(G) \le \min {\{ k+3, 2r+2}\},\) where k is the number of columns and r is the length of a longest column in a \({\mathcal {U}}\)-bubble model for G.

We note that by an application of Lemma 4.1 in [30], slightly worse bounds on clique-width in terms of rows and columns can also be derived. In particular, if we take two natural orderings of the bubbles in the \({\mathcal {U}}\)-bubble model, one taking rows first and the other taking columns first, we obtain two times larger multiplicative factor than in Corollary 22.

5 Conclusion

The main contribution of this work is a new representation of mixed unit interval graphs—the \({\mathcal {U}}\)-bubble model. This structure is particularly useful in the design of algorithms and their analysis. Using the \({\mathcal {U}}\)-bubble model, we presented new upper-bounds for the clique-width of mixed unit interval graphs and designed a subexponential-time algorithm for the MaxCut problem on mixed unit interval graphs. We further realized that the state-of-the-art polynomial-time algorithm for the MaxCut problem on unit interval graphs is incorrect. A long-term task is to determine the difference between the time complexity of basic problems on unit interval graphs compared to interval graphs. In particular, on a more precise scale of mixed unit interval graphs, determine what is a key property for the change of the complexity. Independently, a long-standing open problem is the time complexity of the MaxCut problem on unit interval graphs, in particular, decide if it is NP-hard or polynomial-time solvable.

An interesting direction to pursue the first task could be the study of labeling problems; either \(L_{2,1}\)-labeling or Packing Coloring. Both problems were motivated by assigning frequencies to transmitters. The \(L_{2,1}\)-labeling problem was first introduced by Griggs and Yeh in 1992 [21]. The packing coloring problem is newer, it was introduced by Goddard et al. in 2008 [18]. Although, these are well-known problems, quite surprisingly, their time complexity is open for interval graphs.

The \(L_{2,1}\)-labeling problem assigns labels \(\{0,\ldots ,k\}\) to vertices such that the labels of neighboring vertices differ by at least two and the labels of vertices in distance two are different. The time complexity of this problem is still wide open even for unit interval graphs, despite partial progress on specific values for the largest used label. Sakai proved that the value of the largest label lies between \(2\chi -2\) and \(2\chi \) where \(\chi \) is the chromatic number [39].

The packing coloring problem asks for an existence of such a mapping \(c:V\rightarrow \{1,\ldots ,m\}\) that for all \(u\ne v\) with \(c(u)=c(v)=i\) the distance between u and v is at least i. This problem is wide open on interval graphs. Recently, there was a small progress on unit interval graphs leading to an FPT algorithm (time \(f(k)\cdot n^{\mathcal {O}(1)}\) for some computable function f and parameter k). It is shown in [27] that the packing coloring problem is in FPT parameterized by the size of a maximum clique. We note that the algorithm can be straightforwardly extended to mixed unit interval graphs. However, a polynomial-time algorithm or alternatively NP-hardness for (unit) interval graphs is of a much bigger interest.