1 Introduction

A queue layout of a graph consists of a total order \(\prec \) of its vertices and a partition of its edges into queues such that no two edges in a single queue nest, that is, there are no edges (uv) and (xy) in a queue with \(u \prec x \prec y \prec v\). If the input graph is directed, then the total order has to be compatible with its edge directions, that is, it has to be a topological ordering of it [13, 14]. The minimum number of queues needed in a queue layout of a graph is commonly referred to as its queue number.

There is a rich literature exploring bounds on the queue number of different classes of graphs [1, 11, 15, 17,18,19]. A remarkable work by Dujmović et al. [7] proves that the queue number of (undirected) planar graphs is constant, thus improving upon previous (poly-)logarithmic bounds [3, 5, 6] and resolving in the positive an old conjecture by Heath, Leighton and Rosenberg [11]. For a survey, we refer to [8].

In this paper, we investigate bounds on the queue number of posets. Recall that a poset \(P=\langle X,< \rangle \) consists of a finite set of elements X equipped with a partial order <; refer to Sect. 2 for formal definitions. The queue number of the poset P is the queue number of the acyclic digraph \({G(P)}\) associated with P, called cover digraph, that contains all non-transitive relations among the elements of X. This digraph can be visualized using a Hasse diagram, in which elements correspond to points in the plane and each edge (xy) is drawn as a y-monotone curve from x to y; see Fig. 1 for an example.

Fig. 1
figure 1

a The Hasse diagram of a width-4 poset; gray elements are pairwise incomparable; the chains of a certain decomposition are shown by vertical lines. b A 2-queue layout with a 2-rainbow formed by edges \((v_2, v_5)\) and \((v_6, v_8)\)

The study of the queue number of posets was initiated in 1997 by Heath and Pemmaraju [12], who, among others, provided bounds on the queue number of posets expressed in terms of their width, that is, the maximum number of pairwise incomparable elements with respect to <. In particular, they observed that the queue number of a poset of width w cannot exceed \(w^2\) and they further posed the following conjecture.

Conjecture 1

(Heath and Pemmaraju [12]) Every poset of width w has queue number at most w.

Heath and Pemmaraju [12] made a step towards settling the conjecture by providing a linear upper bound of \(4w-1\) on the queue number of planar posets of width w, that is, of posets whose Hasse diagrams are planar. This bound was recently improved to \(3w-2\) by Knauer, Micek, and Ueckerdt [16], who also gave a planar poset whose queue number is exactly w, thus establishing a lower bound. Furthermore, they investigated (non-planar) posets of width 2, and proved that their queue number is at most 2, therefore establishing that Conjecture 1 holds when \(w=2\).Footnote 1 Note that, in general, there exist planar posets of width w whose queue number is exactly w [16].

Our Contribution. We present improvements upon the aforementioned results, thus continuing the study of the queue number of posets expressed in terms of their width, which is one of the open problems by Dujmović et al. [7].

  • For a fixed total order of a graph, the queue number is the size of a maximum rainbow, that is, of a set of pairwise nested edges [11]. Thus to determine the queue number of a poset \(P = \langle X, <\rangle \) one has to compute a linear extension (that is, a total order of X complying with <), which minimizes the size of a maximum rainbow. In Theorem 1 in Sect. 3, we present a width-w poset and a corresponding linear extension that yields a rainbow of size \(w^2\), which suggests that a linear extension has to be chosen carefully, if one seeks for an upper bound on the queue number of width-w posets that is strictly less than \(w^2\).

  • Knauer et al. [16] studied a special type of linear extensions, called lazy linear extensions, for posets of width 2 to show that their queue number is at most 2. Thus, it is tempting to generalize and analyze lazy linear extensions for posets of width \(w > 2\). We provide such an analysis and show that the maximum size of a rainbow in a lazy linear extension of a width-w poset is at most \(w^2-w\) (Theorem 2 in Sect. 3). Furthermore, we show that the bound is worst-case optimal for lazy linear extensions (Theorem 3 in Sect. 3).

  • The above bound already provides an improvement over the existing upper bound on the queue number of width-w posets by Heath and Pemmaraju [12]. However, a carefully chosen lazy linear extension, which we call most recently used (MRU), further improves the bound to \((w-1)^2+1\) (Theorem 4 in Sect. 4). Again we show this bound to be worst-case optimal for MRU extensions (Theorem 5 in Sect. 4).

  • We demonstrate a non-planar poset of width 3 whose queue number is 4 (Theorem 6 in Sect. 5) and generalize this example to width-w posets of queue number \(w+1\) (Theorem 7 in Sect. 5), thus disproving Conjecture 1.

Paper organization. Section 2 introduces necessary definitions and notations. Lazy and MRU linear extensions are introduced and studied in Sects. 3 and 4, respectively. Section 5 is devoted in disproving Conjecture 1. Finally, Sect. 6 concludes the paper with a list of open problems.

2 Preliminaries

A partial order over a finite set of elements X is a binary relation < that is irreflexive and transitive. A finite set X together with a partial order < is a partially ordered set (or simply a poset). Let \(P = \langle X, < \rangle \) be a poset. Two elements x and y of X with \(x < y\) or \(y < x\) are called comparable; otherwise x and y are incomparable. A subset of pairwise comparable (incomparable) elements of X is called a chain (antichain, respectively). The width of poset P is defined as the cardinality of a largest antichain. For two elements x and y of X with \(x<y\), we say that x is covered by y if there is no element \(z \in X\) such that \(x< z < y\). Poset P can be naturally associated with an acyclic digraph \({G(P)}\), whose vertex-set consists of the elements of X, and there exists an edge from u to v if u is covered by v; see Fig. 1a. We refer to \({G(P)}\) as the cover digraph of P. Observe that by definition \({G(P)}\) has no transitive edges, that is, \({G(P)}\) is transitively reduced.

A linear extension L of poset P is a total order of the elements of X that complies with <, that is, for every two elements x and y in X with \(x < y\), x precedes y in L. Given a linear extension L of poset P, we write \(x \prec y\) to denote that x precedes y in L; if in addition x and y may coincide, we write \(x \preceq y\). We use \([x_1\ldots x_2 \ldots x_k]\) to denote \(x_i \prec x_{i+1}\) for all \(1 \le i < k\); such a subsequence of L is also called a pattern. Let \(F=\{(x_i,y_i);\;i=1,2,\ldots ,k\}\) be a set of \(k \ge 2\) independent (that is, having no common endpoints) edges of \({G(P)}\). It follows that \(x_i \prec y_i\) for all \(1 \le i \le k\). If \([x_1 \ldots x_k \ldots y_k \ldots y_1]\) holds in L, then the edges of F form a k-rainbow (see Fig. 1b). Edge \((x_i, y_i)\) nests edge \((x_{j}, y_{j})\), if \(1 \le i<j \le k\). To ease the presentation, in the following we often illustrate patterns as in-line figures, which allows us to additionally show critical edges on the involved vertices, e.g., a k-rainbow \([x_1, \ldots , x_k, \ldots , y_k, \ldots , y_1]\), along with edges \((x_1,y_1),\ldots ,(x_k,y_k)\), is visualized as follows:

figure a

In this visualization, gray dots between two vertices indicate that these vertices are not necessarily consecutive in the order. Also, note that in several occasions, we do not illustrate all vertices and edges that may be involved in a pattern, but we rather focus on a meaningful subset of important ones.

A queue layout of an acyclic digraph G consists of a total order of its vertices that is compatible with the edge directions of G and of a partition of its edges into queues, such that no two edges in a queue are nested. The queue number of G is the minimum number of queues required by its queue layouts. Accordingly, the queue number of poset P is the queue number of its cover digraph \({G(P)}\). Equivalently, the queue number of P is at most k if and only if it admits a linear extension L such that no \((k+1)\)-rainbow is formed by some of the edges of \({G(P)}\) [15]. If certain edges form a rainbow in L, we say that L contains the rainbow.

Assume now that poset P has width w. Then, it is known that its elements can be partitioned into w chains [4]. Note that such a partition is not necessarily unique. In the following, we fix this partition, and treat it as a function \({\mathcal {C}}:X \rightarrow \{1,\ldots ,w\}\) such that if \({\mathcal {C}}(u) = {\mathcal {C}}(v)\) and \(u \ne v\), then either \(u < v\) or \(v < u\). We use \({\mathcal {R}}\), \({\mathcal {B}}\), and \({\mathcal {G}}\) to denote specific chains from a chain decomposition. A set of edges of the cover digraph \({G(P)}\) of poset P that form a rainbow in a linear extension is called an incoming \({\mathcal {R}}\)-rainbow \(T_{\mathcal {R}}\) of size s if it consists of s edges \((u_1,r_1), \dots , (u_s,r_s)\) such that \(r_i \in {\mathcal {R}}\) for all \(1 \le i \le s\) and \({\mathcal {C}}(u_i) \ne {\mathcal {C}}(u_j)\) for all \(1 \le i,j \le s\) with \(i \ne j\). If \(s=w\), \(T_{\mathcal {R}}\) is called complete and is denoted by \(T^*_{\mathcal {R}}\). An edge e of \(T_{\mathcal {R}}\) with both endpoints in \({\mathcal {R}}\) is called an \({\mathcal {R}}\)-self edge. For example, \(T^*_{\mathcal {R}}\setminus \{e\}\) is an incoming \({\mathcal {R}}\)-rainbow of size \(w-1\) without the \({\mathcal {R}}\)-self edge e. Similar notation is used for chains \({\mathcal {B}}\) and \({\mathcal {G}}\).

3 Lazy Linear Extensions

In this section, we formally introduce and study lazy linear extensions. We start by recalling two elementary properties of (general) linear extensions, whose proofs immediately follow from the fact that the cover digraph of a poset contains no transitive edges.

Proposition 1

A linear extension of a poset P does not contain pattern \([r_1 \dots r_2 \dots r_3]\), where \({\mathcal {C}}(r_1) = {\mathcal {C}}(r_2) = {\mathcal {C}}(r_3)\) and \((r_1, r_3)\) is an edge of \({G(P)}\).

Proposition 2

A linear extension of a poset P does not contain pattern \([r_1 \dots r_2 \dots b_2 \dots b_1]\), where \({\mathcal {C}}(r_1) = {\mathcal {C}}(r_2)\), \({\mathcal {C}}(b_1) = {\mathcal {C}}(b_2)\), and \((r_1, b_1)\) and \((r_2, b_2)\) are edges of \({G(P)}\).

Note that Proposition 2 directly implies that for any linear extension of a poset, the maximum size of a rainbow is at most \(w^2\), as shown by Heath and Pemmaraju [12].

3.1 Motivation

In the following, we show that, for every \(w \ge 2\), there exists a width-w poset and a linear extension of it containing a \(w^2\)-rainbow, which suggests that the bound by Heath and Pemmaraju [12] is worst-case optimal. Hence, a linear extension has to be chosen carefully, if one seeks for a bound on the queue number of width-w posets that is strictly less than \(w^2\).

Theorem 1

For every \(w \ge 2\), there is a width-w poset and a linear extension of it that results in a rainbow of size \(w^2\) for the edges of its cover digraph.

Proof

For \(w \ge 2\), we construct a poset \(P_w\) of width w, and we demonstrate a linear extension of it, which results in a queue layout of \({G({P_w})}\) with \(w^2\) queues. We describe \(P_w\) in terms of its cover digraph \({G({P_w})}\), which contains w chains \({\mathcal {C}}_1,\ldots ,{\mathcal {C}}_w\) of length 2w that form paths in \({G({P_w})}\). We denote the j-th vertex of the i-th chain \({\mathcal {C}}_i\) by \(v_{i,j}\), where \(1 \le i \le w\) and \(1 \le j \le 2w\). Since each chain is a path in \({G({P_w})}\), \((v_{i,j}, v_{i,j+1})\) is an edge in \({G({P_w})}\) for every \(1 \le i \le w\) and \(1 \le j \le 2w-1\). The first and the last w vertices of each such path partition the vertex-set of \({G({P_w})}\) into two sets S and T, respectively, that is,

$$\begin{aligned} S=\cup _{i=1}^w\{v_{i,1},\ldots ,v_{i,w}\}\quad \text {and}\quad T=\cup _{i=1}^w\{v_{i,w+1},\ldots ,v_{i,2w}\}. \end{aligned}$$

Observe that each chain has exactly one edge, called the middle edge, connecting a vertex in S to a vertex in T. In the following, we describe the interchain edges of \({G({P_w})}\) and a specific linear extension of \(P_w\), in which all w middle edges of \({G({P_w})}\) (refer to the bold-drawn edges in Fig. 2) and all \(w(w-1)\) interchain edges of \({G({P_w})}\) (the colored edges in Fig. 2) form a \(w^2\)-rainbow. We give the description of the interchain edges of \({G({P_w})}\) in an iterative way. Assume that we have introduced the interchain edges that form the connections between the first \(i-1\) chains and let \({\mathcal {C}}_i\) be the next chain to consider. We proceed in two steps.

First, we introduce the outgoing interchain edges from the vertices of \({\mathcal {C}}_i\) as follows. For \(k=1,\ldots , i-1\), we connect the k-th vertex \(v_{i,k}\) of chain \({\mathcal {C}}_i\) to the \((2w-i+1)\)-th vertex \(v_{i-k,2w-i+1}\) of chain \({\mathcal {C}}_{i-k}\), that is, we introduce \((v_{i,k},v_{i-k,2w-i+1})\) in \({G({P_w})}\).

We next introduce the incoming interchain edges to vertices of \({\mathcal {C}}_i\) as follows. For \(k=1,\ldots , i-1\), we connect the \((w-i+k)\)-th vertex of k-th chain \({\mathcal {C}}_k\) to the \((2w-k+1)\)-th vertex of chain \({\mathcal {C}}_i\), that is, we introduce edge \((v_{k,w-i+k},v_{i,2w-k+1})\) in \({G({P_w})}\). This completes the construction of \({G({P_w})}\) and thus of poset \(P_w\).

Fig. 2
figure 2

Illustration for the proof of Theorem 1: The cover digraph \({G({P_w})}\) of a poset \(P_w\) with \(w=4\) and a linear extension (indicated with gray numbers) of it which yields a rainbow of size 16

By construction, the interchain edges of \({G({P_w})}\) connect only vertices from S to vertices in T, and, from each chain, there is only one (outgoing) interchain edge to every other chain. This implies that an interchain edge cannot be transitive in \({G({P_w})}\). On the other hand, an intrachain edge (uv) also cannot be transitive because its source u needs an outgoing interchain edge (which classifies u in S) and its target v an incoming interchain edge (which classifies v in T). This implies that (uv) is a middle edge. In this case, however, our construction ensures that there are interchain edges attached to neither u nor v. Thus, \({G({P_w})}\) is transitively reduced. Since \({G({P_w})}\) is by construction acyclic, we conclude that \(P_w\) is a poset. Since any two vertices in the same chain are comparable, the width of \(P_w\) equals to the number of sources (or sinks) of chains, which is w.

To complete the proof, we next describe a linear extension of \({G({P_w})}\) that contains a \(w^2\)-rainbow. For \(i=1,\ldots ,w\) and for \(j=1,\ldots ,w-1\), the j-th vertex \(v_{i,j}\) of chain \({\mathcal {C}}_i\) is the \(((i-1)(w-1)+j)\)-th vertex in the extension. For \(i=1,\ldots ,w\), the w-th vertex \(v_{i,w}\) of chain \({\mathcal {C}}_i\) is the \((w(w-1)+w-(i-1))\)-th vertex in the extension. For \(i=1,\ldots ,w\) and for \(j=1,\ldots ,w\), the \((w+j)\)-th vertex \(v_{i,w+j}\) of chain \({\mathcal {C}}_i\) is the \((w^2 + jw + (i-1))\)-th vertex in the extension. In this linear extension, all interchain edges (which are in total \(w(w-1)\)) and all middle edges (which are in total w) form a rainbow of size \(w^2\). \(\square \)

We conclude this section with the following remark.

Remark 1

Knauer et al. [16] claimed the existence of a width-w poset and its linear extension containing a \(w^2\)-rainbow. However, the poset that they claim to require \(w^2\) queues in some linear extension of it is defined on 2w elements. As a result, its cover digraph cannot have more than w independent edges. Thus, also the largest rainbow that can be formed by any linear extension is of size at most w, that is, w is an upper bound on the queue number of this poset.

3.2 General Lazy Linear Extensions

As mentioned in Sect. 3.1, a linear extension of a width-w poset has to be chosen carefully, if one seeks for a bound on the queue number of width-w posets that is strictly less than \(w^2\). In this section, we present and analyze such an extension, which we call lazy.

Assume that a width-w poset \(P = \langle X, < \rangle \) is given with a decomposition \({\mathcal {C}}\) into w chains. Intuitively, a lazy linear extension is constructed incrementally starting from a minimal element of the poset. In every iteration, the next element is chosen from the same chain, if possible. Formally, for \(i=1,\ldots ,n\), assume that we have computed a lazy linear extension L for \(i-1\) vertices of \({G(P)}\) and let \(v_{i-1}\) be last vertex in L (if any). To determine the next vertex \(v_{i}\) of L, we compute the following set consisting of all source-vertices of the subgraph of \({G(P)}\) induced by \(X\setminus L\):

$$\begin{aligned} S = \{v\in X\setminus L: \; \not \exists \text { edge } (u,v) \text { in } G(P) \text { with } u \in X \setminus L\}. \end{aligned}$$
(1)

If there is a vertex u in S with \({\mathcal {C}}(u) = {\mathcal {C}}(v_{i-1})\), we set \(v_{i} = u\); otherwise \(v_{i}\) is freely chosen from S; see Algorithm 1. Observe that the definition of a lazy linear extension for poset P depends on the chosen chain partition \(\mathcal {C}\). For the example of Fig. 1a, observe that \(v_1 \prec v_4 \prec v_2 \prec v_3 \prec v_6 \prec v_7 \prec v_5 \prec v_8\) is a lazy linear extension. It is easy to see that Algorithm 1 can be implemented in \({\mathcal {O}}(n+m)\) time, where n and m are the number of vertices and edges of G(P), respectively, assuming that a chain partition is given as a part of the input.

figure b

Lemma 1

If a lazy linear extension L of a poset \(P = \langle X, < \rangle \) contains the pattern \([r_1 \dots b \dots r_2]\), where \({\mathcal {C}}(r_1) = {\mathcal {C}}(r_2) \ne {\mathcal {C}}(b)\), then there exists some \(x \in X\) with \({\mathcal {C}}(x) \ne {\mathcal {C}}(r_1)\) between \(r_1\) and \(r_2\) in L, such that \(x < r_2\).

Proof

Since b appears between \(r_1\) and \(r_2\) in L (by the pattern \([r_1 \dots b \dots r_2]\)), the cover digraph \({G(P)}\) of P contains an edge from a vertex x with \({\mathcal {C}}(x) \ne {\mathcal {C}}(r_1)\) to a vertex \(y \in {\mathcal {C}}(r_1)\) that is between \(r_1\) and \(r_2\) in L (notice that x may or may not coincide with b). Since the edge belongs to \({G(P)}\), it follows that \(x < y \le r_2\). \(\square \)

Lemma 2

A lazy linear extension of a poset \(P = \langle X, < \rangle \) does not contain pattern

figure c

where \((u_1,r_1),\dots ,(u_{w-1},r_{w-1})\) form an incoming \({\mathcal {C}}(r)\)-rainbow of size \(w-1\), such that \({\mathcal {C}}(r) \ne {\mathcal {C}}(u_i)\) for all \(1 \le i \le w-1\) and \({\mathcal {C}}(r) \ne {\mathcal {C}}(b)\).

Proof

Assume, to the contrary, that there is a lazy linear extension L containing the pattern. Since \([r \dots b \dots r_{w-1}]\) holds in L, by Lemma 1, there is an element \(x \in X\) with \({\mathcal {C}}(x) \ne {\mathcal {C}}(r_{w-1})\) between r and \(r_{w-1}\) in L such that \(x < r_{w-1}\). Since \({\mathcal {C}}(x) \ne {\mathcal {C}}(r_{w-1})\), there is \(1 \le j \le w-1\) such that \({\mathcal {C}}(x) = {\mathcal {C}}(u_j)\), which implies \(u_j < x\). Thus:

figure d

Since \(u_j< x < r_{w-1} \le r_j\), there is a path from \(u_j\) to \(r_j\) in \({G(P)}\). It follows that the edge \((u_j, r_j)\) is transitive in G(P), which is a contradiction to the fact that G(P) is transitively reduced. \(\square \)

Theorem 2

The maximum size of a rainbow formed by the edges of \({G(P)}\) in a lazy linear extension of a poset P of width w is at most \(w^2-w\).

Proof

Assume, to the contrary, that there is a lazy linear extension L that contains a \((w^2-w+1)\)-rainbow T. By Proposition 2 and the pigeonhole principle, T contains at least one complete incoming rainbow of size w; denote it by \(T^*_{\mathcal {R}}\) and the corresponding chain by \({\mathcal {R}}\). By Proposition 1, the \({\mathcal {R}}\)-self edge of \(T^*_{\mathcal {R}}\) is innermost in \(T^*_{\mathcal {R}}\). Thus, if \((u_1,r_1),\dots ,(u_{w},r_{w})\) are the edges of \(T^*_{\mathcal {R}}\) and \(u_w \in {\mathcal {R}}\), then, without loss of generality, we may assume that the following holds in L:

figure e

We next show that \((u_{w},r_{w})\) is the innermost and \((u_{w-1}, r_{w-1})\) is the second innermost edge in T. Assume, to the contrary, that there exists an edge (xy) in T that does not belong to \(T^*_{\mathcal {R}}\) (that is, \({\mathcal {C}}(y) \ne {\mathcal {R}}\)) and that is nested by \((u_{w-1}, r_{w-1})\). Regardless of whether (xy) nests \((u_{w},r_{w})\) or not, we deduce the following:

figure f

Together with \(u_w \in {\mathcal {R}}\) and \(y \notin {\mathcal {R}}\), we apply Lemma 2, which yields a contradiction. Since \((u_{w},r_{w})\) and \((u_{w-1}, r_{w-1})\) are the two innermost edges of T, it follows that T does not contain another complete incoming rainbow of size w.

Hence, each of the remaining \(w-1\) incoming rainbows has size exactly \(w-1\). Consider vertex \(u_{w-1}\), and, let, without loss of generality, \({\mathcal {C}}(u_{w-1}) = {\mathcal {B}}\). By Proposition 1, \({\mathcal {B}}\ne {\mathcal {R}}\). We claim that the (inclusion-maximal) incoming \({\mathcal {B}}\)-rainbow \(T_{\mathcal {B}}\) does not contain the \({\mathcal {B}}\)-self edge. Assuming the contrary, this \({\mathcal {B}}\)-self edge nests \((u_{w-1},r_{w-1})\) because \((u_{w},r_{w})\) and \((u_{w-1}, r_{w-1})\) are the two innermost edges of T. Since \({\mathcal {C}}(u_{w-1}) = {\mathcal {B}}\), we obtain a contradiction by Proposition 1. Thus, \(T_{\mathcal {B}}\) is a \({\mathcal {B}}\)-rainbow of size \(w-1\) containing no \({\mathcal {B}}\)-self edge. All edges of \(T_{\mathcal {B}}\) nest \((u_{w-1}, r_{w-1})\), which yields the forbidden pattern of Lemma 2 formed by vertices of \(T_{\mathcal {B}}\), \(u_{w-1} \in {\mathcal {B}}\), and \(r_{w-1} \in {\mathcal {R}}\); a contradiction. \(\square \)

In the following theorem we show that our analysis is tight, that is, there are posets of width w and corresponding lazy linear extensions containing \((w^2-w)\)-rainbows.

Theorem 3

For every \(w \ge 2\), there exists a width-w poset, which has a lazy linear extension resulting in a rainbow of size \(w^2-w\) for the edges of its cover digraph.

Proof

For \(w \ge 2\), we construct a poset \({P_{w}}\) of width w, and we demonstrate a lazy linear extension \(L_w\) of it, which results in a queue layout of \({G(P_{w})}\) with \(w^2-w\) queues. We describe \({P_{w}}\) in terms of its cover digraph \({G(P_{w})}\). We define \({G(P_{w})}\) recursively based on the graph \({G(P_{w-1})}\) of width \(w-1\), for which we assume that it admits a lazy linear extension \(L_{w-1}\), such that the edges of \({G(P_{w-1})}\) form a rainbow of size exactly \((w-1)^2-(w-1)\) in \(L_{w-1}\). Since \({G(P_{w-1})}\) has width \(w-1\), its vertex-set can be partitioned into \(w-1\) chains \({\mathcal {C}}_1,\ldots ,{\mathcal {C}}_{w-1}\) [4]. As an invariant property in the recursive definition of \({G(P_{w})}\), we assume that the first and the last vertices in \(L_{w-1}\) belong to two different chains of the partition, say without loss of generality to \({\mathcal {C}}_1\) and \({\mathcal {C}}_{w-1}\), respectively.

In the base case \(w=2\), the cover digraph \({G(P_{2})}\) consists of five vertices \(v_1,\ldots ,v_5\) and four edges \((v_1,v_2)\), \((v_1,v_5)\), \((v_3,v_4)\), and \((v_4,v_5)\). It is not difficult to see that \({G(P_{2})}\) has width 2 and, for the chain partition \({\mathcal {C}}_1=\{v_1,v_2\}\), \({\mathcal {C}}_2=\{v_3,v_4,v_5\}\), the linear extension \(v_1 \prec \ldots \prec v_5\) is a lazy linear extension of it, which satisfies the invariant property and results in a 2-rainbow formed by \((v_1,v_5)\) and \((v_3,v_4)\).

Graph \({G(P_{w})}\) is obtained by augmenting \({G(P_{w-1})}\) with \(6w-4\) vertices. Hence, \({G(P_{w})}\) contains \(3w^2-w-5\) vertices in total. We further enrich the chain partition \({\mathcal {C}}_1,\ldots ,{\mathcal {C}}_{w-1}\) of \({G(P_{w-1})}\) by one additional chain \({\mathcal {C}}_w\) in \({G(P_{w})}\); see Fig. 3. In particular, chain \({\mathcal {C}}_w\) contains \(2(w-1)\) vertices \(v_{w,1}, \ldots , v_{w,2w-2}\) that form a path in this order in \({G(P_{w})}\). Chain \({\mathcal {C}}_1\) of \({G(P_{w-1})}\) is enriched with five additional vertices \(v_{1,1}\), \(v_{1,2}\), \({\overline{v}}_{1,2}\), \(v_{1,3}\), and \(v_{1,4}\) in \({G(P_{w})}\), such that \(v_{1,1}\) is connected to \(v_{1,2}\), \(v_{1,2}\) is connected \({\overline{v}}_{1,2}\) and \({\overline{v}}_{1,2}\) is connected to the first vertex of chain \({\mathcal {C}}_i\) in \(L_{w-1}\) for all \(1 \le i \le w-1\), the last vertex of \({\mathcal {C}}_1\) in \(L_{w-1}\) is connected to \(v_{1,3}\), and \(v_{1,3}\) is connected to \(v_{1,4}\). For \(i=2,\ldots ,w-2\), chain \({\mathcal {C}}_i\) of \({G(P_{w-1})}\) is enriched with four vertices \(v_{i,1}\), \(v_{i,2}\), \(v_{i,3}\), and \(v_{i,4}\) in \({G(P_{w})}\), such that \(v_{i,1}\) is connected to \(v_{i,2}\), \(v_{i,2}\) is connected to the first vertex of chain \({\mathcal {C}}_i\) in \(L_{w-1}\), the last vertex of chain \({\mathcal {C}}_i\) in \(L_{w-1}\) is connected to \(v_{i,3}\), and vertex \(v_{i,3}\) is connected to \(v_{i,4}\). Finally, chain \({\mathcal {C}}_{w-1}\) is enriched with five vertices \(v_{w-1,1}\), \(v_{w-1,2}\), \({\overline{v}}_{w-1,3}\), \(v_{w-1,3}\), and \(v_{w-1,4}\), such that vertex \(v_{w-1,1}\) is connected to \(v_{w-1,2}\), \(v_{w-1,2}\) is connected to the first vertex of \({\mathcal {C}}_{w-1}\) in \(L_{w-1}\), the last vertex of \({\mathcal {C}}_{w-1}\) in \(L_{w-1}\) is connected to \({\overline{v}}_{w-1,3}\), \({\overline{v}}_{w-1,3}\) is connected to \(v_{i,3}\) for all \(1 \le i \le w-1\) and \(v_{i,3}\) is connected to \(v_{w-1,4}\) for all \(1 \le i \le w\). We complete the construction of \({G(P_{w})}\) by adding the following edges (colored orange in Fig. 3): (i)\((v_{i,1},v_{w,w+i-1})\) for all \(1 \le i \le w-1\), (ii)\((v_{w,i},v_{w-i,4})\) for all \(1 \le i \le w-1\).

Fig. 3
figure 3

Illustration for Theorem 3; q denotes the number of vertices of \({G(P_{w-1})}\), that is, \(q=3(w-1)^2-(w-1)-5\)

The construction ensures that \({G(P_{w})}\) contains no transitive edges and that its width is w, since all the newly added vertices either are comparable to vertices of \({\mathcal {C}}_1,\ldots ,{\mathcal {C}}_{w-1}\) or belong to the newly introduced chain \({\mathcal {C}}_w\). Hence, \(P_w\) is a well-defined width-w poset. Now, consider the following linear extension \(L_w\) of \({G(P_{w})}\):

$$\begin{aligned}&v_{w,1}, \dots , v_{w,w-1},v_{w-1,1}, v_{w-1,2}, \dots v_{1,1}, v_{1,2}, {\overline{v}}_{1,2}, L_{w-1}, {\overline{v}}_{{w-1,3}}, v_{w-1,3}, \\&\quad v_{w,w}, \dots , v_{w,2w-2},v_{{w-2,3}}, v_{{w-2,4}}, \ldots , v_{1,3}, v_{1,4}, v_{w-1,4}&\end{aligned}$$

It can be easily checked that \(L_w\) is a lazy linear extension of \({G(P_{w})}\), under the invariant property that the first and the last vertices of \(L_{w-1}\) belong to two different chains in \(\{{\mathcal {C}}_1,\ldots ,{\mathcal {C}}_{w-1}\}\), which we assume to be \({\mathcal {C}}_1\) and \({\mathcal {C}}_{w-1}\), respectively. Note that, since the first vertex of \(L_w\) belongs to \({\mathcal {C}}_w\) while its last vertex to \({\mathcal {C}}_{w-1}\), the invariant property is maintained in the course of the recursion. We complete the proof by observing that the \(w-1\) edges stemming from the first \(w-1\) vertices of \({\mathcal {C}}_w\) towards the last vertices of the chains \({\mathcal {C}}_1,\ldots ,{\mathcal {C}}_{w-1}\) and the \(w-1\) edges stemming from the first \(w-1\) vertices of \({\mathcal {C}}_1,\ldots ,{\mathcal {C}}_{w-1}\) towards the last \(w-1\) vertices of chain \({\mathcal {C}}_{w}\) form a rainbow of size \(2w-2\) in \(L_w\) (see the orange edges in Fig. 3), which nests the rainbow of size \((w-1)^2-(w-1)\) of \(L_{w-1}\). Thus, we have identified a rainbow of total size \(w^2-w\) in \(L_w\), as desired. \(\square \)

3.3 A note for the upper bound of \(w^2 - 2 \lfloor w/2 \rfloor \) by Knauer et al.

In the following, we discuss an issue in the approach by Knauer et al. [16] to derive the upper bound of \(w^2 - 2 \lfloor w/2 \rfloor \) on the queue number of posets of width w. Knauer et al. used a simple form of the lazy linear extension to prove that the queue number of a poset of width 2 is at most 2. Using this result, they derived the bound of \(w^2 - 2 \lfloor w/2 \rfloor \) on the queue number of a poset P of width w by pairing up chains of the chain partition of P. The pairing yields \(\lfloor w/2 \rfloor \) pairs, each of which induces a poset of width 2, and thus admits a lazy linear extension in which the maximum rainbow is of size 2.

Fig. 4
figure 4

Illustration a poset of width 4 together with a chain partition \({\mathcal {C}}_1,\dots ,{\mathcal {C}}_4\)

The critical step is to combine the linear extensions of the pairs to a linear extension of the original poset by “respecting all these partial linear extensions”, as stated in [16]. The step is problematic even for \(w=4\). To see this, consider the poset illustrated in Fig. 4 through its cover digraph. This poset has width 4 and \({\mathcal {C}}_1, \ldots , {\mathcal {C}}_4\) is a chain partition. It is not difficult to see that the poset induced by \({\mathcal {C}}_1\) and \({\mathcal {C}}_2\) admits the following lazy linear extension:

$$\begin{aligned} L_1:\;v_2 \prec v_6 \prec v_1 \prec v_5. \end{aligned}$$

The poset induced by \({\mathcal {C}}_3\) and \({\mathcal {C}}_4\) admits the following lazy linear extension:

$$\begin{aligned} L_2:\;v_3 \prec v_4 \prec v_8 \prec v_7. \end{aligned}$$

According to [16], the two linear extensions, \(L_1\) and \(L_2\), are combined into a linear extension L of the original poset. In particular, the following holds in L:

  • \(v_1 \prec v_8\), due to edge \((v_1,v_8)\),

  • \(v_8 \prec v_7\), since this holds in \(L_2\),

  • \(v_7 \prec v_6\), due to edge \((v_7,v_6)\).

By transitivity, it follows that \(v_1 \prec v_6\) must hold in L. However, \(v_6 \prec v_1\) holds in \(L_1\), a contradiction. We conclude that a crucial argument is missing in [16]. It is not clear how to avoid such a problem for an approach in which two linear extensions are combined into a single one.

4 MRU Extensions

In this section, we define a special type of lazy linear extensions, which we call most recently used, or simply MRU. Let \(P = \langle X, < \rangle \) be a width-w poset and \({\mathcal {C}}\) a decomposition of it into w chains. For \(i=1,\ldots ,n\), assume that we have computed a linear extension L for \(i-1\) vertices of \({G(P)}\), which are denoted by \(v_1, \dots , v_{i-1}\). To determine the next vertex \(v_i\) of L, we compute set S of Eq. 1. Among all vertices in S, we select one from the most recently used chain (if any). Formally, we select a vertex \(u \in S\) such that \({\mathcal {C}}(u) = {\mathcal {C}}(v_j)\) for the largest \(1 \le j < i\). If such a vertex does not exist, we choose \(v_i\) arbitrarily from S; see Algorithm 2. For the example of Fig. 1a, observe that \(v_1 \prec v_4 \prec v_2 \prec v_3 \prec v_6 \prec v_5 \prec v_7 \prec v_8\) is an MRU extension. In particular, after vertex \(v_6\), a lazy linear extension may contain either \(v_5\) or \(v_7\), while an MRU linear extension contains vertex \(v_5\).

figure g

In what follows, we prove the main result of the section, providing a worst-case optimal upper bound on the size of a rainbow in an MRU linear extension of a poset. The proof of Theorem 4 is based on analyzing the largest incoming rainbows and bounding (from above) their sizes. To this end, we describe certain forbidden patterns in the order, namely Lemmas 5678, and 9. The analysis relies on two auxiliary claims (Proposition 3 and Lemma 4), which we discuss next.

For a linear extension L of poset \(P = \langle X, < \rangle \) and two elements x and y in X, let \({\mathcal {C}}[x, y]\) be the subset of chains whose elements appear between x and y (inclusively) in L, that is, \({\mathcal {C}}[x, y] = \{{\mathcal {C}}(z) : x \preceq z \preceq y\}\).

Lemma 3

Let L be an MRU extension of a width-w poset P containing pattern \([r_1 \dots r_2 \dots b]\), such that \({\mathcal {C}}(r_1) = {\mathcal {C}}(r_2) \ne {\mathcal {C}}(b)\) and there is no element in L between \(r_1\) and \(r_2\) from chain \({\mathcal {C}}(r_1)\). If \({\mathcal {C}}[r_1,r_2]={\mathcal {C}}[r_1,b]\), then \(r_2 < b\).

Proof

Assume, to the contrary, that there is some b for which \(r_2 < b\) does not hold. Without loss of generality, let b be the first (after \(r_2\)) of those elements in L. Since \({\mathcal {C}}[r_1,r_2]={\mathcal {C}}[r_1,b]\), there are elements between \(r_1\) and \(r_2\) in L from chain \({\mathcal {C}}(b)\). Let \(b_1\) be the last such element in L. Hence, \(r_1 \prec b_1 \prec r_2 \prec b\). Consider the incremental construction of L. Since there is no element between \(r_1\) and \(r_2\) in L from chain \({\mathcal {C}}(r_1)\), the chain of b was “more recent” than the one of \(r_2\), when \(r_2\) was chosen as the next element. Thus, there is an edge (xb) in \({G(P)}\) with \(r_2 \prec x\) in L, that is, when \(r_2\) was chosen as the next element, b was not part of set S of Eq. (1). Since b is the first element that is not comparable to \(r_2\), then \(r_2 < x\) holds. Hence, \(r_2 < b\); a contradiction to our assumption that \(r_2 < b\) does not hold. \(\square \)

Corollary 1

Let L be an MRU extension of a width-w poset P containing pattern \([r_1 \dots r_2]\), such that \({\mathcal {C}}(r_1) = {\mathcal {C}}(r_2)\) and there is no element in L between \(r_1\) and \(r_2\) from chain \({\mathcal {C}}(r_1)\). If \(|{\mathcal {C}}[r_1,r_2]|=w\), then \(r_2\) is comparable to all subsequent elements in L.

Lemma 4

An MRU extension L of a width-w poset P does not contain the following pattern, even if \(u_k = b_1\):

figure h

where

  • \({\mathcal {C}}(u_i) \ne {\mathcal {C}}(u_j)\) for \(1 \le i, j \le w\) with \(i \ne j\),

  • \((u_1,r_1),\dots ,(u_k,r_k)\) form an incoming \({\mathcal {R}}\)-rainbow of size k for some \(1 \le k \le w\),

  • between \(b_1\) and \(b_2\) in L, there is an element from \({\mathcal {R}}\) but no elements from \({\mathcal {B}}= {\mathcal {C}}(b_1) = {\mathcal {C}}(b_2)\).

Proof

Since there are no elements between \(b_1\) and \(b_2\) in L from \({\mathcal {B}}\) and since \({\mathcal {C}}(u_i) \ne {\mathcal {C}}(u_j)\) for \(1 \le i, j \le w\) with \(i \ne j\), one of \(u_1,\ldots , u_k\) belongs to \({\mathcal {B}}\). Let \(u_i\) be this element with \(1 \le i \le k\), that is, \({\mathcal {C}}(u_i)={\mathcal {B}}\). Since \((u_1,r_1),\dots ,(u_k,r_k)\) form an incoming \({\mathcal {R}}\)-rainbow, \((u_i,r_i)\) is an edge of \({G(P)}\). Notice that \([u_i \dots b_1 \dots b_2 \dots r_i]\) holds in L and that \(u_i=b_1\) may hold if \(i=k\).

Our proof is by induction on \(|{\mathcal {C}}| - |{\mathcal {C}}[b_1, b_2]|\), which ranges between 0 and \(w-2\). In the base case \(|{\mathcal {C}}| - |{\mathcal {C}}[b_1, b_2]| = 0\), that is, \(|{\mathcal {C}}[b_1, b_2]| = w\). By Corollary 1, \(b_2\) is comparable to all subsequent elements in L. In particular, \(b_2 < r_i\), which implies that \((u_i, r_i)\) is transitive in \({G(P)}\), since \(u_i \le b_1< b_2 < r_i\); a contradiction.

Assume \(|{\mathcal {C}}| - |{\mathcal {C}}[b_1, b_2]| > 0 \). Let \(r_0\) be the first vertex from \({\mathcal {R}}\) after \(b_2\) in L, that is, \(r_0 \preceq r_k\). If there are no elements between \(b_2\) and \(r_0\) from \({\mathcal {C}}\setminus {\mathcal {C}}[b_1,b_2]\) (that is, \({\mathcal {C}}[b_1,b_2] = {\mathcal {C}}[b_2,r_0]\)), then by Proposition 3 it follows that \(b_2 < r_0\), which implies \(u_i \le b_1< b_2 < r_0 \le r_i\). Thus, edge \((u_i, r_i)\) is transitive in \({G(P)}\); a contradiction. Therefore, we may assume that there are elements between \(b_2\) and \(r_0\) in L from \({\mathcal {C}}\setminus {\mathcal {C}}[b_1, b_2]\). Let \(g_1\) be the first such element; denote \({\mathcal {C}}(g_1) = {\mathcal {G}}\). Since between \(b_1\) and \(b_2\) in L there is an element from \({\mathcal {R}}\) (that is, \({\mathcal {R}}\in {\mathcal {C}}[b_1,b_2]\)), \({\mathcal {G}}\ne {\mathcal {R}}\) holds. Similarly, \({\mathcal {G}}\ne {\mathcal {B}}\). Let \((u_\ell ,r_\ell )\) be the edge of the incoming \({\mathcal {R}}\)-rainbow with \({\mathcal {C}}(u_\ell ) = {\mathcal {G}}\); notice that such an edge exists as \({\mathcal {G}}\in {\mathcal {C}}\setminus {\mathcal {C}}[b_1,b_2]\). Since \(r_0\) is the first element from \({\mathcal {R}}\) after \(b_2\) in L, \(r_0 \preceq r_\ell \). Thus, \([u_\ell \dots b_1 \dots b_2 \dots g_1 \dots r_0 \dots r_\ell ]\) holds in L such that \({\mathcal {C}}(u_\ell )={\mathcal {G}}\notin \{{\mathcal {R}}, {\mathcal {B}}\}\). Let \(g_2\) be the last element between \(u_\ell \) and \(b_1\) from \({\mathcal {G}}\), that is, \(u_\ell \preceq g_2 \prec b_1\) in L. Now, consider the pattern:

figure i

which satisfies the conditions of the lemma, since between \(g_2\) and \(g_1\) in L there is an element of \({\mathcal {R}}\) (namely, the one between \(b_1\) and \(b_2\) in L) and no elements of \({\mathcal {G}}\) (by the choice of \(g_1\) and \(g_2\)). Further, \(|{\mathcal {C}}| - |{\mathcal {C}}[g_2, g_1]| < |{\mathcal {C}}| - |{\mathcal {C}}[b_1, b_2]|\), since \(\{{\mathcal {G}}\} = {\mathcal {C}}[g_2, g_1] \setminus {\mathcal {C}}[b_1, b_2]\). By the inductive hypothesis, the aforementioned pattern is not contained in L. Thus, also the initial one is not contained in L. \(\square \)

In the next five lemmas, we study configurations that cannot appear in a rainbow formed by the edges of \({G(P)}\) in an MRU extension.

Lemma 5

Let \({\mathcal {R}}\) and \({\mathcal {B}}\) be different chains of a width-w poset. Then a rainbow in an MRU extension of the poset does not contain all edges from

$$\begin{aligned} T^*_{\mathcal {R}}~~\cup ~~ \{(b_1, b_2)\}, \end{aligned}$$

where \(b_1, b_2 \in {\mathcal {B}}\) and \(T^*_{\mathcal {R}}\) is a complete incoming \({\mathcal {R}}\)-rainbow.

Proof

Assume, to the contrary, that a rainbow T contains an incoming \({\mathcal {R}}\)-rainbow formed by edges \((u_1,r_1), \dots , (u_w,r_w)\) and an edge \((b_1,b_2)\) with \(b_1, b_2 \in {\mathcal {B}}\). As in the proof of Theorem 2, we can show that \((u_{w-1}, r_{w-1})\) and \((u_w, r_w)\) are the two innermost edges of T and \({\mathcal {C}}(u_w) = {\mathcal {R}}\). Assume, without loss of generality, that \(u_{k} \prec b_1 \prec u_{k+1}\) in L for some \(1\le k \le w-1\), which implies that \(r_{k+1} \prec b_2 \prec r_k\). Thus, the following holds in L:

figure j

By Proposition 1, there are no elements from \({\mathcal {B}}\) between \(b_1\) and \(b_2\). Hence, the conditions of Lemma 4 hold for the pattern; a contradiction. \(\square \)

Lemma 6

Let \({\mathcal {R}}\) and \({\mathcal {B}}\) be different chains of a width-w poset. Then a rainbow in an MRU extension of the poset does not contain all edges from

$$\begin{aligned} T^*_{\mathcal {R}}\setminus \{(r_1, r_2)\} ~~\cup ~~ T^*_{\mathcal {B}}\setminus \{(b_1, b_2)\}, \end{aligned}$$

where \(r_1, r_2 \in {\mathcal {R}}\), \(b_1, b_2 \in {\mathcal {B}}\), and \(T^*_{\mathcal {R}}, T^*_{\mathcal {B}}\) is a complete incoming \({\mathcal {R}}\)-rainbow and \({\mathcal {B}}\)-rainbow, respectively.

Proof

Let \(T_{\mathcal {R}}\) be an incoming \({\mathcal {R}}\)-rainbow of size \(w-1\) without the \({\mathcal {R}}\)-self edge; define \(T_{\mathcal {B}}\) symmetrically. Assume, to the contrary, that a rainbow T in an MRU extension L contains both \(T_{\mathcal {R}}\) and \(T_{\mathcal {B}}\). Let \((u_{w-1}, r_{w-1})\) and \((v_{w-1},b_{w-1})\) be the innermost edges of \(T_{\mathcal {R}}\) and \(T_{\mathcal {B}}\) in T, respectively. Without loss of generality, assume that \((v_{w-1},b_{w-1})\) nests \((u_{w-1}, r_{w-1})\). This implies the following in L:

figure k

By Lemma 2 applied to \(T_{\mathcal {B}}\), there are no elements from \({\mathcal {B}}\) between \(v_{w-1}\) and \(r_{w-1}\) in L. Consider edge \((u_i, r_i)\) of \(T_{\mathcal {R}}\) such that \(u_i \in {\mathcal {B}}\). Element \(u_i\) ensures that there are some elements preceding \(v_{w-1}\) in L that belong to \({\mathcal {B}}\). Let \(b_\ell \) be the last such element in L, that is, \(b_\ell \preceq v_{w-1}\). Symmetrically, let \(b_r\) be the first element from \({\mathcal {B}}\) following \(r_{w-1}\) in L, that is, \(r_{w-1} \prec b_r \preceq b_{w-1}\), and we have:

figure l

By the choice of \(b_\ell \) and \(b_r\), we further know that, between \(b_\ell \) and \(b_r\), there are no elements from \({\mathcal {B}}\), but there is an element from \({\mathcal {R}}\), namely \(r_{w-1}\). Let \((u_1,r_1),\ldots ,(u_k,r_k)\) be the edges of \(T_{\mathcal {R}}\) that nest both \(b_\ell \) and \(b_r\) in L, that is, \(u_1 \prec \ldots \prec u_k \prec b_\ell \prec b_r \prec r_k \prec \ldots \prec r_1\) holds in L. Assuming that \(u_w = r_{w-1}\), we conclude that the following holds in L:

figure m

Since, between \(b_\ell \) and \(b_r\) there are no elements from \({\mathcal {B}}\), but there is an element from \({\mathcal {R}}\), we have the forbidden pattern of Lemma 4; a contradiction. \(\square \)

Lemma 7

Let \({\mathcal {R}}, {\mathcal {B}}, {\mathcal {G}}\) be pairwise different chains of a width-w poset. Then a rainbow in an MRU extension of the poset does not contain all edges from

$$\begin{aligned} T^*_{\mathcal {R}}\setminus \{(g_1, r)\} ~~\cup ~~ T^*_{\mathcal {B}}\setminus \{(g_2, b)\}, \end{aligned}$$

where \(g_1, g_2 \in {\mathcal {G}}\), \(r \in {\mathcal {R}}\), \(b \in {\mathcal {B}}\), and \(T^*_{\mathcal {R}}, T^*_{\mathcal {B}}\) is a complete incoming \({\mathcal {R}}\)-rainbow and \({\mathcal {B}}\)-rainbow, respectively.

Proof

Assume, to the contrary, that a rainbow T contains both \(T_{\mathcal {R}}\) and \(T_{\mathcal {B}}\) as in the statement of the lemma. Let \((u_1,r_1),\dots ,(u_{w-1},r_{w-1})\) be the edges of \(T_{\mathcal {R}}\) and \((v_1,b_1), \dots , (v_{w-1},b_{w-1})\) be the edges of \(T_{\mathcal {B}}\), where \((u_{w-1}, r_{w-1})\) and \((v_{w-1},b_{w-1})\) is \({\mathcal {R}}\)- and \({\mathcal {B}}\)-self edge, respectively. By Proposition 1, \((u_{w-1}, r_{w-1})\) and \((v_{w-1}, b_{w-1})\) are innermost edges in \(T_{\mathcal {R}}\) and \(T_{\mathcal {B}}\). Without loss of generality, assume that \((v_{w-1},b_{w-1})\) nests \((u_{w-1}, r_{w-1})\), and that \(v_{w-1}\) appears between vertices \(u_{k}\) and \(u_{k+1}\) of \(T_{\mathcal {R}}\), which implies that \(r_{k+1} \prec b_{w-1} \prec r_k\). Hence, the following holds in L:

figure n

By Proposition 1, there is no vertex of \({\mathcal {B}}\) between \(v_{w-1}\) and \(b_{w-1}\) in L. If there is a vertex from \({\mathcal {G}}\) between \(v_{w-1}\) and \(b_{w-1}\) in L, then we have the forbidden pattern of Lemma 4, since \({\mathcal {C}}(u_i) \ne {\mathcal {G}}\) for all \(1 \le i \le w-1\).

figure o

Otherwise, by Lemma 1, there is some \(x \notin {\mathcal {B}}\) between \(v_{w-1}\) and \(b_{w-1}\) in L, such that \(x < b_{w-1}\). As mentioned above, \(x \notin {\mathcal {G}}\) either. Thus, the incoming \({\mathcal {B}}\)-rainbow contains edge \((v_i, b_i)\), which nests \((v_{w-1}, b_{w-1})\), such that \({\mathcal {C}}(v_i)={\mathcal {C}}(x)\). Since \(v_i< x< b_{w-1} < b_i\), the edge \((v_i,b_i)\) is transitive; a contradiction. \(\square \)

Lemma 8

Let \({\mathcal {R}}, {\mathcal {B}}, {\mathcal {G}}\) be pairwise different chains of a width-w poset \(P=\langle X,< \rangle \). Then a rainbow in an MRU extension of G(P) does not contain all edges from

$$\begin{aligned} T^*_{\mathcal {B}}\setminus \{(b_1, b_2)\} ~~\cup ~~ T^*_{\mathcal {R}}\setminus \{(m_r, r)\} ~~\cup ~~ T^*_{\mathcal {G}}\setminus \{(m_g, g)\}, \end{aligned}$$

where \(b_1, b_2 \in {\mathcal {B}}\), \(m_r \in X \setminus {\mathcal {R}}\), \(r \in {\mathcal {R}}\), \(m_g \in X \setminus {\mathcal {G}}\), \(g \in {\mathcal {G}}\), and \(T^*_{\mathcal {B}}, T^*_{\mathcal {R}}, T^*_{\mathcal {G}}\) is a complete incoming \({\mathcal {B}}\)-rainbow, \({\mathcal {R}}\)-rainbow \({\mathcal {G}}\)-rainbow, respectively.

Proof

Assume, to the contrary, that a rainbow T contains three incoming rainbows, \(T_{\mathcal {B}}\), \(T_{\mathcal {R}}\), and \(T_{\mathcal {G}}\), as in the statement of the lemma. Without loss of generality, assume that the \({\mathcal {G}}\)-self edge \((g_1, g_2)\) is nested by the \({\mathcal {R}}\)-self edge, \((r_1, r_2)\); that is, \(r_1 \prec g_1 \prec g_2 \prec r_2\).

Denote the edges of \(T_{\mathcal {B}}\) by \((u_i, b_{u_i})\), for \(1 \le i \le w-1\), and assume that the following holds in L for some \(k \le w-1\):

figure p

Suppose there exists a vertex \(x \in {\mathcal {B}}\), such that \(r_1 \prec x \prec r_2\); then \(r_1\) and \(r_2\) together with x and edges of \(T_{\mathcal {B}}\) form the forbidden pattern of Lemma 4. Thus, there are no vertices from \({\mathcal {B}}\) between \(r_1\) and \(r_2\) in L, and \((u_k, b_{u_k})\) is the innermost edge of \(T_{\mathcal {B}}\) in T. Therefore, we can find two consecutive vertices in chain \({\mathcal {B}}\), \(b'\) and \(b''\), such that \(b' \prec r_1 \prec r_2 \prec b'' \preceq b_{u_k}\). Here \(b'\) exists because, by Lemma 7, at least one of the two edges, (br), (bg), is in T as part of \(T_{\mathcal {R}}\), \(T_{\mathcal {G}}\), respectively. Further, by Lemma 2, the interval between \(u_k\) and \(b_{u_k}\) does not contain pattern \([u_k \dots b \dots x \dots b_{u_k}]\), where \(b \in {\mathcal {B}}, x \notin {\mathcal {B}}\). Thus, \(b' \prec u_k\) and the interval of L between \(b''\) and \(b_{u_k}\) contains vertices only from \({\mathcal {B}}\) (\(b'' = b_{u_k}\) is possible):

figure q

Now, if there exists a vertex from \({\mathcal {C}}(m_r)\) between \(b'\) and \(b''\), then \([b' \dots r_1 \dots b'']\) together with the edges of \(T_{\mathcal {R}}\) form the forbidden pattern of Lemma 4. Thus, there are no vertices from \({\mathcal {C}}(m_r)\) between \(b'\) and \(b''\).

Finally, consider vertices \(r_1\) and \(r_2\) that are consecutive in \({\mathcal {R}}\). By Lemma 1 and the fact that \(r_1 \prec g_1 \prec r_2\), there is \(x \notin {\mathcal {C}}(m_r)\) between \(r_1\) and \(r_2\) such that \(x < r_2\). Since \(x \notin {\mathcal {C}}(m_r)\), rainbow \(T_{\mathcal {R}}\) contains edge \((y, r_y)\) for some \(r_y \in {\mathcal {R}}\) such that \({\mathcal {C}}(y) = {\mathcal {C}}(x)\). Edge \((y, r_y)\) is transitive, as \(y< x< r_2 < r_y\); a contradiction. \(\square \)

Lemma 9

Let \({\mathcal {R}}, {\mathcal {B}}, {\mathcal {G}}\) be pairwise different chains of a width-w poset \(P=\langle X,< \rangle \). Then a rainbow in an MRU extension of G(P) does not contain all edges from

$$\begin{aligned} T^*_{\mathcal {B}}\setminus \{(m_b, b)\} ~~\cup ~~ T^*_{\mathcal {R}}\setminus \{(m_r, r)\} ~~\cup ~~ T^*_{\mathcal {G}}\setminus \{(m_g, g)\}, \end{aligned}$$

where \(m_b \in X \setminus {\mathcal {B}}\), \(b \in {\mathcal {B}}\), \(m_r \in X \setminus {\mathcal {R}}\), \(r \in {\mathcal {R}}\), \(m_g \in X \setminus {\mathcal {G}}\), \(g \in {\mathcal {G}}\), and \(T^*_{\mathcal {B}}, T^*_{\mathcal {R}}, T^*_{\mathcal {G}}\) is a complete incoming \({\mathcal {B}}\)-rainbow, \({\mathcal {R}}\)-rainbow \({\mathcal {G}}\)-rainbow, respectively.

Proof

Assume, to the contrary, that a rainbow T contains three incoming rainbows \(T_{\mathcal {B}}\), \(T_{\mathcal {R}}\), and \(T_{\mathcal {G}}\), as in the statement of the lemma for some MRU extension L of the poset. By Lemma 7, \({\mathcal {C}}(m_b)\), \({\mathcal {C}}(m_r)\), and \({\mathcal {C}}(m_g)\) are pairwise distinct chains.

Without loss of generality, assume that the \({\mathcal {R}}\)-self edge, \((r_1, r_2)\), nests the \({\mathcal {B}}\)-self edge, \((b_1, b_2)\), which in turn nests the \({\mathcal {G}}\)-self edge, \((g_1, g_2)\). Namely, \(r_1 \prec b_1 \prec g_1 \prec g_2 \prec b_2 \prec r_2\). Denote the edges of \(T_{\mathcal {B}}\) by \((u_i, b_{u_i})\) for \(1 \le i \le w-1\), and assume that

figure r

holds in L for some \(k \le w-1\). If there is a vertex from \({\mathcal {C}}(m_b)\) between \(r_1\) and \(r_2\) in L, then the forbidden pattern of Lemma 4 is formed by \([r_1 \dots b_1 \dots r_2]\) and edges of \(T_{\mathcal {B}}\). Otherwise, by Lemma 1, there is some \(x \notin {\mathcal {C}}({m_b})\) between \(b_1\) and \(b_2\) such that \(x < b_2\). Since \(|T_{\mathcal {B}}|=w-1\), \(T_{\mathcal {B}}\) contains edge \((y, b_y)\) for some \(b_y \in {\mathcal {B}}\) such that \({\mathcal {C}}(y)= {\mathcal {C}}(x)\). Since \(y<x<b_2<b_y\), \((y, b_y)\) is transitive; a contradiction. \(\square \)

We are now ready to state the main result of this section.

Theorem 4

The maximum size of a rainbow formed by the edges of \({G(P)}\) in an MRU extension of a poset P of width w is at most \((w-1)^2+1\).

Proof

When \(w=2\), the theorem holds for any lazy linear extension by Theorem 2 and thus for MRU. Hence, we focus on the case \(w \ge 3\). Assume, to the contrary, that an MRU extension contains a rainbow T of size greater than \((w-1)^2+1\). Let \(T_{\mathcal {B}}\), \(T_{\mathcal {R}}\), \(T_{\mathcal {G}}\) be the largest incoming rainbows in T corresponding to chains \({\mathcal {B}}\), \({\mathcal {R}}\), and \({\mathcal {G}}\), respectively. Assume, without loss of generality, that \(|T_{\mathcal {B}}| \ge |T_{\mathcal {R}}| \ge |T_{\mathcal {G}}|\). By the pigeonhole principle, we have \(|T_{\mathcal {B}}| \ge |T_{\mathcal {R}}| \ge w-1\). We claim that \(|T_{\mathcal {B}}| = w-1\). Indeed, if \(|T_{\mathcal {B}}| = w\), then by Lemma 5, \(T_{\mathcal {R}}\) does not contain the \({\mathcal {R}}\)-self edge. Thus, T contains \(T^*_{\mathcal {B}}\) and \(T^*_{\mathcal {R}}\setminus \{(r_1, r_2)\}\) with \(r_1, r_2 \in {\mathcal {R}}\); a contradiction by Lemma 6.

Thus, \(|T_{\mathcal {B}}| = |T_{\mathcal {R}}| = |T_{\mathcal {G}}| = w-1\) follows, and we distinguish cases based on the number of self edges in \(T_{\mathcal {B}}\), \(T_{\mathcal {R}}\), and \(T_{\mathcal {G}}\). If each of them contain its self edge, then we have the forbidden configuration of Lemma 9. If two of \(T_{\mathcal {B}}\), \(T_{\mathcal {R}}\), and \(T_{\mathcal {G}}\) contain a self edge, then we have the forbidden configuration of Lemma 8. Finally, if at most one of \(T_{\mathcal {B}}\), \(T_{\mathcal {R}}\), and \(T_{\mathcal {G}}\) contains a self edge, say \(T_{\mathcal {B}}\), then \(T_{\mathcal {R}}\) and \(T_{\mathcal {G}}\) form the forbidden configuration of Lemma 6. This concludes the proof. \(\square \)

Now we discuss the time complexity of Algorithm 2, that is, the time needed to compute an MRU linear extension of a width-w poset P. We assume a chain partition is given. In order to build an MRU extension L, we maintain the active elements (having no incoming edges) in a priority queue Q; notice that at every step of the algorithm there are at most w active elements, as they are all mutually incomparable. The elements are ordered by the largest index in L of an element from the same chain. At every iteration of the algorithm, we select the top element u from Q, remove its outgoing edges from the poset, and add new active elements to Q. It is easy to see that at each iteration processing of element u takes \(\log w + \text {outdeg}(u)\) time, where \(\text {outdeg}\) denotes the out-degree of the element. Summing over all steps, we get \({\mathcal {O}}(n \log w + m)\), where n and m are the number of vertices and edges in G(P), respectively.

We conclude this section by showing that our analysis is tight, that is, there are posets of width w and corresponding MRU extensions of them containing \(((w-1)^2+1)\)-rainbows.

Theorem 5

For every \(w \ge 2\), there exists a width-w poset that has an MRU extension resulting in a rainbow of size \((w-1)^2+1\) for the edges of its cover digraph.

Proof

As in the proof of Theorem 3, we describe poset \({P_{w}}\) in terms of its cover digraph \({G(P_{w})}\). Similar to the proof of Theorem 3, \({G(P_{w})}\) is defined recursively based on graph \({G(P_{w-1})}\), which is of width \(w-1\), and thus its vertex-set admits a partition into \(w-1\) chains \({\mathcal {C}}_1,\ldots ,{\mathcal {C}}_{w-1}\). As an invariant property in the recursive definition of \({G(P_{w})}\), we now assume that \({G(P_{w-1})}\) admits an MRU extension \(L_{w-1}\) resulting in a rainbow of size \((w-1)^2+1\) for the edges of \({G(P_{w-1})}\), in which for every \(1 \le i < w\) the first vertex of \({\mathcal {C}}_i\) appears before the first vertex of \({\mathcal {C}}_{i+1}\) in \(L_{w-1}\), while the last vertex of \({\mathcal {C}}_i\) appears after the last vertex of \({\mathcal {C}}_{i+1}\) in \(L_{w-1}\). Note that this property is stronger than the corresponding one we imposed in the recursive definition of the poset supporting Theorem 3. The base graph \({G(P_{2})}\) is exactly the same as the one in the proof of Theorem 3, and it is not difficult to see that \(v_1 \prec \cdots \prec v_5\) is an MRU extension of it satisfying also the stronger invariant property.

Fig. 5
figure 5

Illustration for Theorem 5; q denotes the number of vertices of \({G(P_{w-1})}\), that is, \(q=3(w-1)^2-7\)

The first step in the construction of graph \({G(P_{w})}\) based on \({G(P_{w-1})}\) is exactly the same as in the proof of Theorem 3 but without the edge \((v_{1,1}, v_{w,w})\), which is now replaced by \(({\overline{v}}_{1,2}, v_{w,w})\); see Fig. 5. In a second step, we introduce a vertex \(v_{w,0}\) being the first vertex in the path formed by the vertices of chain \({\mathcal {C}}_w\). This vertex is also connected to \(v_{i,2}\), for all \(1 \le i \le w-1\). Finally, we add the following edges to \({G(P_{w})}\), namely, for all \(1 \le i < j \le w-1\), we connect \(v_{i,3}\) to \(v_{j,4}\). Note that \({G(P_{w})}\) is acyclic and transitively reduced as desired, while its width is w. We construct an appropriate linear extension \(L_w\) of it as follows:

$$\begin{aligned}{}[v_{1,1}, \dots , v_{w-1,1}, v_{w,0}, v_{w,1}, \dots , v_{w,w-1}, v_{w-1,2}, v_{w-2,2}, \dots v_{1,2}, {\bar{v}}_{1,2}, L_{w-1}, \\ {\bar{v}}_{w-1,3}, v_{w-1,3}, v_{w-2,3}, \dots , v_{1,3}, v_{1,4}, \dots v_{w-1,4}, v_{w,w+1}, v_{w,2w-2}] \end{aligned}$$

It can be easily checked that \(L_w\) is an MRU extension of \({G(P_{w})}\), under the strong invariant property. In particular, at vertex \({\overline{v}}_{1,2}\) of the aforementioned extension chains, \({\mathcal {C}}_1,\ldots ,{\mathcal {C}}_w\) are in this order from the most recent to the least recent one. By the invariant property, at vertex \({\overline{v}}_{w-1,3}\), chains \({\mathcal {C}}_1,\ldots ,{\mathcal {C}}_w\) are in the reverse order, that is, from the least recent to the most recent one. Since, for the first vertices of every chain in \(L_w\), it holds \(v_{1,1} \prec \cdots \prec v_{w-1,1} \prec v_{w,0}\), while for the corresponding last vertices it holds \(v_{1,4} \prec \cdots \prec v_{w-1,4} \prec v_{w,2w-2}\), the strong invariant property is maintained in \(L_w\).

We complete the proof by observing that the \(w-1\) edges stemming from the first \(w-1\) vertices of \({\mathcal {C}}_w\) towards the last vertices of the chains \({\mathcal {C}}_1,\ldots ,{\mathcal {C}}_{w-1}\) and the \(w-2\) edges stemming from the first \(w-2\) vertices of \({\mathcal {C}}_2,\ldots ,{\mathcal {C}}_{w-1}\) towards the last \(w-2\) vertices of chain \({\mathcal {C}}_{w}\) form a rainbow of size \(2w-3\) in \(L_w\) (refer to the orange edges in Fig. 5), which nests the rainbow of size \((w-2)^2+1\) of \(L_{w-1}\). Hence, we identified a rainbow of total size \((w-1)^2+1\) in \(L_w\), as desired.

\(\square \)

5 A Counterexample to Conjecture 1

In this section, we describe our approach to disprove Conjecture 1. Central to our counterexample is the following poset, which we describe in terms of its cover digraph G(pq); see Fig. 6a. For \(p \ge q-3\), graph G(pq) consists of \(2p+q\) vertices \(a_1, \dots , a_p\), \(b_1, \dots , b_q\), and \(c_1, \dots , c_p\) that form three chains of lengths p, q, and p, respectively. For all \(1 \le i \le p\) and for all \(1 \le j \le q\), the edges \((a_i, a_{i+1})\), \((b_j, b_{j+1})\) and \((c_i, c_{i+1})\) form the intrachain edges of G(pq). Graph G(pq) also contains the following interchain edges: (i) \((a_i, c_{i+3})\) and \((c_i, a_{i+3})\) for all \(1 \le i \le p-3\), and (ii) \((a_i, b_i)\) and \((c_i, b_i)\) for all \(1 \le i \le q\).

We denote by \({\widetilde{G}}(p,q)\) the graph obtained by adding \((b_1, a_p)\) and \((b_1, c_p)\) to G(pq). It is easy to verify that both G(pq) and \({\widetilde{G}}(p,q)\) are transitively reduced, acyclic, and of width 3.

For \(i=1,\ldots ,q-3\), we denote by \(T_a(i)\) the subgraph of G(pq) induced by the vertices \(a_i,\ldots ,a_{i+6}\) and the vertex \(c_{i+3}\). Accordingly, \(T_c(i)\) is the subgraph of G(pq) induced by the vertices \(c_i,\ldots ,c_{i+6}\) and the vertex \(a_{i+3}\); see Fig. 6b. We further denote by \(X_a(i)\) the subgraph of G(pq) induced by the vertices \(a_{i+1}, \dots , a_{i+4}, c_{i}, \dots , c_{i+5}\) and symmetrically by \(X_c(i)\) the subgraph of G(pq) induced by the vertices \(a_{i}, \dots , a_{i+5}, c_{i+1}, \dots , c_{i+4}\); see Fig. 6c.

Fig. 6
figure 6

Illustration of graph \({\widetilde{G}}(p,q)\) and its subgraphs \(T_a(i)\) and \(X_a(i)\)

The following lemma guarantees the existence of a 3-rainbow, when there exists an edge, say (uv), that “nests” \(T_a(i)\) in a linear extension of G(pq), that is, when \(u \prec a_i \prec \dots \prec a_{i+6} \prec v\). We denote this configuration by \([u, T_a(i), v]\).

Lemma 10

In every linear extension of G(pq), each of \(T_a(i)\) and \(T_c(i)\) requires 2 queues for all \(i=1,\ldots ,q-3\).

Proof

We give a proof only for \(T_a(i)\), as the case with \(T_c(i)\) is symmetric.

Let L be a linear extension of G(pq). Since \((a_i,c_{L.})\) and \((c_{i+3},a_{i+6})\) are edges of G(pq), \(a_i \prec c_{i+3} \prec a_{i+6}\) holds in L.

If \(a_{i+3} \prec c_{i+3}\), then \([a_{i} \dots a_{i+2} \dots a_{i+3} \dots c_{i+3}]\) holds in L and thus \((a_{i},c_{i+3})\) and \((a_{i+2},a_{i+3})\) form a 2-rainbow.

Otherwise, \([c_{i+3} \dots a_{i+3} \dots a_{i+4} \dots a_{i+6}]\) holds and thus \((c_{i+3},a_{i+6})\) and \((a_{i+3},a_{i+4})\) form a 2-rainbow. \(\square \)

The next lemma establishes some properties of \(X_a(i)\).

Lemma 11

In every linear extension of G(pq), in which one of the following five statements holds \(X_a(i)\) requires 3 queues:

  1. (i)

    \(a_{i+1} \prec c_{i+1} \prec a_{i+2} \prec c_{i+2}\),

  2. (ii)

    \(c_{i+1} \prec a_{i+1} \prec c_{i+2} \prec a_{i+2}\),

  3. (iii)

    \(a_{i+3} \prec c_{i+3} \prec a_{i+4} \prec c_{i+4}\),

  4. (iv)

    \(c_{i+3} \prec a_{i+3} \prec c_{i+4} \prec a_{i+4}\),

  5. (v)

    \(c_{i} \prec a_{i+1} \prec c_{i+2} \prec a_{i+3} \prec c_{i+4}\).

Proof

Let L be a linear extension of G(pq) satisfying one of (i)(v). We consider each of the cases of the lemma separately in the following.

  1. (i)

    Assume \(a_{i+1} \prec c_{i+1} \prec a_{i+2} \prec c_{i+2}\). Since \(c_{i+2} \prec c_{l} \prec c_{i+4}\), if \(c_{i+3} \prec a_{i+3}\), then the edges \((c_{i+1},a_{i+4})\), \((a_{i+2},a_{i+3})\) and \((c_{i+2}, c_{i+3})\) form a 3-rainbow, since \([c_{i+1} \dots a_{i+2} \dots c_{i+2} \dots c_{i+3} \dots a_{i+3} \dots a_{i+4}]\) holds in L. Hence, we may assume that \(a_{i+3} \prec c_{i+3}\) holds in L. We distinguish two cases depending on whether \(a_{i+3} \prec c_{i+2}\) or \( c_{i+2} \prec a_{i+3}\). In the former case, the edges \((a_{i+1},c_{i+4})\), \((c_{i+1},c_{i+2})\) and \((a_{i+2}, a_{i+3})\) form a 3-rainbow, since \([a_{i+1} \dots c_{i+1} \dots a_{i+2} \dots a_{i+3} \dots c_{i+2} \dots c_{i+4}]\) holds in L. In the latter case, in which \(c_{i+2} \prec a_{i+3}\), the relative order in L is \([a_{i+1} \dots c_{i+1} \dots a_{i+2} \dots c_{i+2} \dots a_{i+3} \dots c_{i+3}]\). Since \(c_{i+3} \prec c_{i+4} \prec c_{i+5}\), we distinguish possible positions for \(a_{i+4}\).

    • If \(a_{i+3} \prec a_{i+4} \prec c_{i+3}\), then \((a_{i+2},c_{i+5})\), \((c_{i+2},c_{i+3})\) and \((a_{i+3}, a_{i+4})\) form a 3-rainbow, since \([a_{i+2} \dots c_{i+2} \dots a_{i+3} \dots a_{i+4} \dots c_{i+3} \dots c_{i+5}]\) holds in L.

    • If \(c_{i+3} \prec a_{i+4} \prec c_{i+4}\), then \((a_{i+1},c_{i+4})\), \((c_{i+1},a_{i+4})\) and \((c_{i+2}, c_{i+3})\) form a 3-rainbow, since \([a_{i+1} \dots c_{i+1} \dots c_{i+2} \dots c_{i+3} \dots a_{i+4} \dots c_{i+4}]\) holds in L.

    • If \(c_{i+4} \prec a_{i+4} \prec c_{i+5}\), then \((a_{i+2},c_{i+5})\), \((a_{i+3},a_{i+4})\) and \((c_{i+3}, c_{i+4})\) form a 3-rainbow, since \([a_{i+2} \dots a_{i+3} \dots c_{i+3} \dots c_{i+4} \dots a_{i+4} \dots c_{i+5}]\) holds in L.

    • If \(c_{i+5} \prec a_{i+4}\), then \((c_{i+1},a_{i+4})\), \((a_{i+2},c_{i+5})\) and \((c_{i+2}, c_{i+3})\) form a 3-rainbow, since \([c_{i+1} \dots a_{i+2} \dots c_{i+2} \dots c_{i+3} \dots c_{i+5} \dots a_{i+4}]\) holds in L.

  2. (ii)

    Assume \(c_{i+1} \prec a_{i+1} \prec c_{i+2} \prec a_{i+2}\). If \(a_{i+3} \prec c_{i+3}\), then \((a_{i+1},c_{i+4})\), \((c_{i+2},c_{i+3})\) and \((a_{i+2}, a_{i+3})\) form a 3-rainbow, since \([a_{i+1} \dots c_{i+2} \dots a_{i+2} \dots a_{i+3} \dots c_{i+3} \dots c_{i+4}]\) holds in L. Hence, we may assume \(c_{i+3} \prec a_{i+3}\). On the other hand, if \(a_{i+4} \prec c_{i+4}\), then \((a_{i+2},c_{i+5})\), \((c_{i+3},c_{i+4})\) and \((a_{i+3}, a_{i+4})\) form a 3-rainbow, since \([a_{i+2} \dots c_{i+3} \dots a_{i+3} \dots a_{i+4} \dots c_{i+4} \dots c_{i+5}]\) holds in L. Hence, we may further assume \(c_{i+4} \prec a_{i+4}\), which together with our previous assumption implies that the underlying order in L is \([c_{i+1} \dots a_{i+1} \dots c_{i+2} \dots c_{i+3} \dots c_{i+4} \dots a_{i+4}]\). The case is then concluded by the observation that \((c_{i+1},a_{i+4})\), \((a_{i+1},c_{i+4})\) and \((c_{i+2}, c_{i+3})\) form a 3-rainbow, as desired.

  3. (iii)

    It can be proved symmetrically to (i).

  4. (iv)

    It can be proved symmetrically to (ii).

  5. (v)

    Assume \(c_{i} \prec a_{i+1} \prec c_{i+1}\). By part (i) of Proposition 11, \(a_{i+2} \prec c_{i+1}\) or \(a_{i+2} \succ c_{i+2}\). In the former case, edges \((a_{i+1},c_{i+4})\), \((a_{i+2},a_{i+3})\), and \((c_{i+1}, c_{i+2})\) form a 3-rainbow, since \([a_{i+1} \dots a_{i+2} \dots c_{i+1} \dots c_{i+2} \dots a_{i+3} \dots c_{i+4}]\) holds in L (recall \(a_{i+3} \prec c_{i+4}\)). In the latter case, a 3-rainbow is formed by the edges \((c_{i},a_{i+3})\), \((c_{i+1}, c_{i+2})\), and \((a_{i+1},a_{i+2})\), since \([c_{i} \dots a_{i+1} \dots c_{i+1}\dots c_{i+2}\dots a_{i+2} \dots a_{i+3}]\) holds in L. Thus, we have \(c_{i+1} \prec a_{i+1} \prec c_{i+2}\). Again by part (ii) of Proposition 11, \(a_{i+2} \prec c_{i+2}\), which yields a 3-rainbow formed by the edges \((c_{i},a_{i+3}])\), \((a_{i+1}, a_{i+2})\) and \((c_{i+1}, c_{i+2})\), since \([c_{i},c_{i+1},a_{i+1},a_{i+2},c_{i+2}, a_{i+3}]\) holds in L.

The above case analysis completes the proof. \(\square \)

In the following, we prove that for sufficiently large values of p and q, graph \({\widetilde{G}}(p,q)\) does not admit a 3-queue layout. For a contradiction, assume that \({\widetilde{G}}(p,q)\) admits a 3-queue layout and let L be its linear extension. Intuitively, we distinguish two cases depending on the length of edge \((b_1, c_p)\) in L. If the edge is “short” (that is, \(b_1\) is close to \(c_p\) in L), then we use Lemma 12 to show the existence of a 4-rainbow. In the opposite case, the edge \((b_1, c_p)\) nests a large subgraph of \({\widetilde{G}}(p,q)\). By Proposition 11, the subgraph that is nested requires 3 queues, which together with the long edge \((b_1, c_p)\) yields a 4-rainbow. Both cases contradict the assumption that \({\widetilde{G}}(p,q)\) admits a 3-queue layout.

Fig. 7
figure 7

Illustrations for the proofs of Lemma 12 and Theorem 6

Lemma 12

G(14, 6) requires 4 queues in every linear extension with \(c_{14} \prec b_1\).

Proof

Let L be a linear extension of G(14, 6) with \(c_{14} \prec b_1\); see Fig. 7. Since \(c_{14} \prec b_1\), \([c_1 \dots c_{14} \dots b_1 \dots b_{6}]\) holds in L. Consider vertex \(a_3\). Since \((a_3,c_6)\) belongs to G(14, 6), \(a_3 \prec c_6\). If \(a_3 \prec c_2\), then configuration \([a_3, c_2, T_c(3), b_2, b_3]\) follows; see Fig. 7a. In other words, \(T_c(3)\) induced by the vertices \(c_3,\dots , c_9\) and \(a_6\) is nested by two independent edges, which yields a 4-rainbow by Proposition 10. Similarly, if \(c_4 \prec a_3 \prec c_6\), then we have a 4-rainbow by the configuration \([c_4, a_3, T_c(6), b_3, b_4]\); see Fig. 7b. Hence, only the case \(c_2 \prec a_3 \prec c_4\) is left to be considered.

Now, consider vertex \(a_5\). Since \((c_2,a_5)\) and \((a_5,c_8)\) belong to G(14, 6), \(c_2 \prec a_5 \prec c_8\). If \(c_2 \prec a_5 \prec c_4\), then we have \([a_5, c_4, T_c(5), b_4, b_5]\); see Fig. 7c. If \(c_6 \prec a_5 \prec c_8\), then we have \([c_6, a_5, T_c(8), b_5, b_6]\); see Fig. 7d. In both cases, a 4-rainbow is implied. Hence, only the case \(c_4 \prec a_5 \prec c_6\) is left to be considered. This case together with the leftover case \(c_2 \prec a_3 \prec c_4\) from above implies that Condition (v) of Proposition 11 is fulfilled for \(X_a(2)\); see Fig. 7e. But in this case configuration \([c_1,X_a(2),b_1]\) yields a 4-rainbow, as desired. \(\square \)

Similarly, we prove the following property of G(6, 2).

Lemma 13

G(6, 2) requires 3 queues in every linear extension.

Proof

Let L be an arbitrary linear extension of G(6, 2). We will prove that L contains a 3-rainbow. We distinguish the cases based on the relative order of \(a_2\) with respect to \(c_1,\ldots ,c_6\). Since the roles of a’s and c’s in G(6, 2) are interchangeable, we can assume without loss of generality that \(c_2 \prec a_2\); hence, \(c_2 \prec a_2 \prec c_5\).

  1. (i)

    Consider first the case in which \(c_2 \prec a_2 \prec c_3\). It follows from Proposition 11.(ii) that \(a_3 \prec c_3\). Hence, \(c_2 \prec a_1\), as otherwise the edges \((a_1,c_4)\), \((c_2,c_3)\), and \((a_2, a_3)\) form a 3-rainbow, since \([a_1 \dots c_2 \dots a_2 \dots a_3 \dots c_3 \dots c_4]\) holds in L. Similarly, if \(b_2 \prec a_4\), then the edges \((c_1, a_4)\), \((c_2,b_2)\), and \((a_1, a_2)\) form a 3-rainbow, since \([c_1 \dots c_2 \dots a_1 \dots a_2 \dots b_2 \dots a_4]\) holds in L. Thus, \(a_4 \prec b_2\). Now, if \(b_2 \prec c_4\), then the edges \((a_1,c_4)\), \((a_2,b_2)\), and \((a_3, a_4)\) form a 3-rainbow, since \([a_1 \dots a_2 \dots a_3 \dots a_4 \dots b_2 \dots c_4]\) holds in L; otherwise, \([c_2 \dots a_1 \dots a_2 \dots a_3 \dots c_4 \dots b_2]\) holds in L, which implies that the edges \((c_2, b_2)\), \((a_1, c_4)\), and \((a_2,a_3)\) from a 3-rainbow .

  2. (ii)

    Consider now the case in which \(c_3 \prec a_2 \prec c_4\). In particular, consider the placement of \(b_2\):

    1. (a)

      if \(a_2 \prec b_2 \prec a_4\) then \(b_2 \prec c_4\) (otherwise \([c_1 \dots c_2 \dots c_3 \dots c_4 \dots b_2 \dots a_4]\) yields a 3-rainbow) and \(a_4 \prec c_4\) (otherwise \([c_1 \dots c_3 \dots a_2 \dots b_2 \dots c_4 \dots a_4]\) also yields a 3-rainbow). Hence, the relative order is \([c_1 \dots c_2 \dots c_3 \dots a_2 \dots b_2 \dots a_4 \dots c_4]\). Consider the placement of \(a_1\) in this relative order. If \(a_1 \prec c_1\), then the edges \((a_1,c_4)\), \((c_1,a_4)\), and \((c_2,b_2)\) form a 3-rainbow, since \([a_1 \dots c_1 \dots c_2 \dots b_2 \dots a_4 \dots c_4]\) holds in L; if \(c_1 \prec a_1 \prec c_2\), then the edges \((c_1,a_4)\), \((a_1,a_2)\), and \((c_2, c_3)\) form a 3-rainbow, since \([c_1 \dots a_1 \dots c_2 \dots c_3 \dots a_2 \dots a_4]\) holds in L; finally, if \(c_2 \prec a_1\), then the edges \((c_1,a_4)\), \((c_2,b_2)\), and \((a_1,a_2)\) form a 3-rainbow, since \([c_1 \dots c_2 \dots a_1 \dots a_2 \dots b_2 \dots a_4]\) holds in L.

    2. (b)

      if \(a_4 \prec b_2 \prec a_6\), then the edges \((c_3,a_6)\), \((a_2,b_2)\), \((a_3,a_4)\) form a 3-rainbow, since \([c_3 \dots a_2 \dots a_3 \dots a_4 \dots b_2 \dots a_6]\) holds in L;

    3. (c)

      if \(a_6 \prec b_2\), then the edges \((c_2,b_2)\), \((c_3,a_6)\), \((a_3,a_4)\) form a 3-rainbow, since \([c_2 \dots c_3 \dots a_3 \dots a_4 \dots a_6 \dots b_2]\) holds in L.

  3. (iii)

    Finally, consider the case in which \(c_4 \prec a_2 \prec c_5\). As above, consider the placement of \(b_2\):

    1. (a)

      if \(a_2 \prec b_2 \prec a_4\), then the edges \((c_1,a_4)\), \((c_2,b_2)\), and \((c_3,c_4)\) form a 3-rainbow, since \([c_1 \dots c_2 \dots c_3 \dots c_4 \dots b_2 \dots a_4]\) holds in L;

    2. (b)

      if \(a_4 \prec b_2 \prec a_6\), then the edges \((c_3,a_6)\), \((a_2,b_2)\), and \((a_3,_4)\) form a 3-rainbow, since \([c_3 \dots a_2 \dots a_3 \dots a_4 \dots b_2 \dots a_6]\) holds in L;

    3. (c)

      if \(a_6 \prec b_2\), then the edges \((c_2,b_2)\), \((c_3,a_6)\), and \((a_2,a_3)\) form a 3-rainbow, since \([c_2 \dots c_3 \dots a_2 \dots a_3 \dots a_6 \dots b_2]\) holds in L.

By the cases above, we obtain that G(6, 2) does not admit a queue layout with at most 2 queues. \(\square \)

Fig. 8
figure 8

Illustration of graph G(6, 2) of Lemma 13

We are now ready to show that \({\widetilde{G}}(p,q)\), with \(p=31\) and \(q=22\), is a counterexample to Conjecture 1 when \(w=3\).

Theorem 6

\({\widetilde{G}}(31,22)\) requires 4 queues in every linear extension.

Proof

Assume for a contradiction that \({\widetilde{G}}(31,22)\) admits a 3-queue layout and let L be its linear extension. If \(c_{14} \prec b_1\) in L, then the subgraph of \({\widetilde{G}}(31,22)\) induced by vertices \(a_1, \dots , a_{14}\), \(c_1, \dots , c_{14}\), \(b_1, \dots , b_6\) is isomorphic to G(14, 6) and, by Lemma 12, requires 4 queues; a contradiction. Hence, \(b_1 \prec c_{14}\) holds in L.

Symmetric as above, if \(c_{31} \prec b_{18}\), the subgraph of \({\widetilde{G}}(31,22)\) induced by vertices \(a_{17}, \dots , a_{30}\), \(c_{17}, \dots , c_{30}\), \(b_{17}, \dots , b_{22}\) is isomorphic to G(14, 6) and by Lemma 12 requires 4 queues; a contradiction. Hence, \(b_{18} \prec c_{31}\) holds in L.

Consider the subgraph of \({\widetilde{G}}(31,22)\) induced by vertices \(a_{17}, \dots , a_{22}\), \(c_{17}, \dots ,c_{22}\), \(b_{17}, b_{18}\), which is isomorphic to G(6, 2); see Fig. 7f. We show that \(b_1\) precedes all the vertices of this subgraph, while all the vertices of this subgraph precede \(c_{31}\). Since \((b_1,c_{31})\) is an edge of \({\widetilde{G}}(31,22)\), by Lemma 13, we derive a contradiction. In particular, \(b_1 \prec a_{17}\) (since \(b_1 \prec c_{14}\) and \((c_{14},a_{17})\) is an edge of \({\widetilde{G}}(31,22)\)), \(b_1 \prec c_{17}\) (since \(b_1 \prec c_{14}\)), and clearly \(b_1 \prec b_{17}\). Similarly, \(a_{22} \prec c_{31}\) (since \((a_{22}, c_{25})\) is an edge of \({\widetilde{G}}(31,22)\) and \(c_{25} \prec c_{31}\)), \(c_{22} \prec c_{31}\), \(b_{18} \prec c_{31}\). \(\square \)

To prove that Conjecture 1 does not hold for \(w>3\), we need an auxiliary lemma, which is implicitly used in [16].

Lemma 14

Let \(P_w\) be a width-w poset with queue number at least k. Then, there exists a poset \(P_{w+1}\) of width \(w+1\) whose queue number is at least \(k+1\).

Proof

Let \({G(P_{w})}\) be the cover digraph of \(P_w\). We define the poset \(P_{w+1}\) by defining its cover digraph \(G(P_{w+1})\) as follows. Digraph \(G(P_{w+1})\) is constructed from two copies of \({G(P_{w})}\) and three new vertices, s, t, and v. In particular, let \(H_1\) and \(H_2\) be two copies of \({G(P_{w})}\). We first add directed edges from the sinks of \(H_1\) to the sources of \(H_2\), which ensures that in any linear extension of \(G(P_{w+1})\), all vertices of \(H_1\) precede those of \(H_2\). Afterwards, we connect vertex s to all sources, and vertex t to all sinks. Observe that the former belong to \(H_1\), while the latter belong to \(H_2\). Finally, we add two directed edges (sv) and (vt). By construction, s is a global source, and t is a global sink in \(G(P_{w+1})\). It is not difficult to see that \(G(P_{w+1})\) is a poset. Since v is incomparable to all vertices defining the width of \({G(P_{w})}\) in both \(H_1\) and \(H_2\), the width of poset \(P_{w+1}\) is at least \(w+1\). However, since all sinks of \(H_1\) are connected to the sources of \(H_2\), the width of \(P_{w+1}\) is exactly \(w+1\). As already observed, in any linear extension of \({G({P_{w+1}})}\), all vertices of \(H_1\) must precede all vertices of \(H_2\). This implies that either edge (sv) nests all edges of \(H_1\) or edge (vt) nests all edges of \(H_2\). Thus, the queue number of \(P_{w+1}\) is at least \(k+1\). \(\square \)

Theorem 6 and Lemma 14 imply the following:

Theorem 7

For every \(w \ge 3\), there is a width-w poset with queue number at least \(w+1\).

6 Conclusions

In this paper, we explored the relationship between the queue number and the width of posets. We disproved Conjecture 1, and we focused on two natural types of linear extensions, lazy and MRU. That led to an improvement of the upper bound on the queue number of posets. We deem important to note that in a follow-up of our work, Felsner, Ueckerdt, and Wille [9] further improved the lower bound of \(w+1\) on the queue number of width-w posets to \(w^2/8\) for \(w \ge 4\) (which is an improvement only for \(w \ge 9\)). Their result improves the recursive step of our construction, Lemma 14, and it can be combined with the graph supporting Theorem 6 as the base case. In view of the aforementioned result, a natural future direction is to further reduce the gap between the lower bound of \(w^2/8\), and the upper bound of \((w-1)^2 + 1\) on the queue number of posets of width \(w > 2\). In particular, it is unknown whether the queue number of width-3 posets is four or five. It is also intriguing to ask whether Conjecture 1 holds for planar width-w posets, whose best-known upper bound is currently \(3w-2\) [16]. We believe that this question can be answered in the positive, as we conjecture below.

Conjecture 2

The queue number of a planar width-w poset is at most w.

Another related open problem is on the stack number of directed acyclic graphs (DAGs). The stack number is defined analogously to the queue number except that no two edges in a single stack cross. Heath et al. [13, 14] asked whether the stack number of upward planar DAGs is bounded by a constant. While the question has been settled for some subclasses of planar digraphs [10], the general problem remains unsolved. This is in contrast with the stack number of undirected planar graphs, which has been shown recently to be exactly four [2, 20].