On the Classes of Interval Graphs of Limited Nesting and Count of Lengths

In 1969, Roberts introduced proper and unit interval graphs and proved that these classes are equal. Natural generalizations of unit interval graphs called $k$-length interval graphs were considered in which the number of different lengths of intervals is limited by $k$. Even after decades of research, no insight into their structure is known and the complexity of recognition is open even for $k=2$. We propose generalizations of proper interval graphs called $k$-nested interval graphs in which there are no chains of $k+1$ intervals nested in each other. It is easy to see that $k$-nested interval graphs are a superclass of $k$-length interval graphs. We give a linear-time recognition algorithm for $k$-nested interval graphs. This algorithm adds a missing piece to Gajarsk\'y et al. [FOCS 2015] to show that testing FO properties on interval graphs is FPT with respect to the nesting $k$ and the length of the formula, while the problem is W2-hard when parameterized just by the length of the formula. We show that a generalization of recognition called partial representation extension is NP-hard for $k$-length interval graphs, even when $k=2$, while Klav\'ik et al. show that it is polynomial-time solvable for $k$-nested interval graphs.


Introduction
For a graph G, we denote by V (G) its vertices and E(G) its edges. An interval representation R of a graph G is a collection u : u ∈ V (G) of intervals of the real line such that uv ∈ E(G) if and only if u ∩ v = ∅. A graph is an interval graph if it has an interval representation, and we denote the class of interval graphs by INT.
An interval representation is called proper if u ⊆ v implies u = v , and unit if the length of all intervals u is one. The classes of proper and unit interval graphs (denoted PROPER INT and UNIT INT) consist of all interval graphs which have proper and unit interval representations, respectively. Roberts [28] proved that PROPER INT = UNIT INT. The Studied Classes. In this paper, we consider two hierarchies of subclasses of interval graphs which generalize proper and unit interval graphs. The class k-NestedINT consists of all interval graphs which have representations with no k + 1 intervals u 0 , . . . , u k such that u 0 u 1 · · · u k ; see Fig. 1a. The disjoint union of two components with the minimum nesting two requiring three different lengths of intervals. On the left, the shorter intervals are shorter than 1 4 of the longer ones. On the right, they are longer than 1 3 .
The class k-LengthINT consists of all interval graphs which have representations having at most k different lengths of intervals; see Fig. 1b. We know by [28] that 1-NestedINT = PROPER INT = UNIT INT = 1-LengthINT.
For an interval graph G, we denote the minimum nesting over all interval representations by ν(G), and the minimum number of interval lengths by λ(G). Since nested intervals have different lengths, we know that ν(G) ≤ λ(G) and this inequality may be strict (as in Fig. 1b). For each k ≥ 2, (k − 1)-LengthINT k-LengthINT k-NestedINT (k + 1)-NestedINT.
Fishburn [9,Theorem 5,p. 177] shows that graphs G in 2-NestedINT have unbounded λ(G). Therefore, 2-NestedINT ⊆ k-LengthINT for each k. Recognition. For a subclass C of interval graphs, the following classical computational problem is studied: Input: A graph G. Question: Is there a C-interval representation of G?
Partial Representation Extension. These problems generalizing recognition were introduced by Klavík et al. [20]. A partial representation R of G is an interval representation x : x ∈ V (G ) of an induced subgraph G of G. The vertices of G and the intervals of R are called pre-drawn. A representation R of G extends R if and only if it assigns the same intervals to the vertices of G : x = x for every x ∈ V (G ).

Problem: Partial Representation Extension -RepExt(C)
Input: A graph G and a partial representation R of an induced subgraph G . Question: Is there a C-interval representation of G extending R ?
An O(n 2 )-time algorithm for RepExt(INT) was given in [20]. There are two different linear-time algorithms [1,19] for this problem. Minimal obstructions making partial representations non-extendible are described in [23]. A linear-time algorithm for proper interval graphs [17] and a quadratic-time algorithm for unit interval graphs [31] are known.
The partial representation extension problems were considered for other graph classes. Polynomial-time algorithms are known for circle graphs [5], and permutation and function graphs [16]. The problems are NP-hard for chordal graphs [18] and contact representations of planar graphs [4]. The complexity is open for circular-arc and trapezoid graphs. 1 ℓ 3 ℓ 2 ℓ 1 r 1 ℓ 1 ℓ 1 ℓ 1 r 1 r 1 r 1 ℓ 2 r 3 r 1 r   [12] FO logic model checking Previous Results and Motivation. The classes k-LengthINT were introduced by Graham as a natural hierarchy between unit interval graphs and interval graphs; see Fig. 2a. Unfortunately, even after decades, the only results known are curiosities that illustrate the incredibly complex structure of k-LengthINT, very different from the case of unit interval graphs. For instance, k-LengthINT is not closed under disjoint unions; see Fig. 1b. Timeline of results is depicted in Fig. 3.
Leibowitz et al. [25] show that the class 2-LengthINT contains caterpillars, threshold graphs, and unit interval graphs with one additional vertex. Further, interval graphs G with λ(G) > 2 such that λ(G \ x) ≤ λ(G) − 2 for some x ∈ V (G) are constructed in [25]. Fishburn [8] shows that there are infinitely many forbidden induced subgraphs for 2-LengthINT, while 1-LengthINT are interval graphs just without K 1,3 [28]. It is also known [7] that there are interval graphs in 2-LengthINT such that, when the shorter length is fixed to 1, the longer one can be one of the real numbers belonging to arbitrary many distinct intervals of the real line, arbitrary far from each other.
Not much is known about the computational complexity of problems involving k-LengthINT, even recognition is open for k = 2. In [3], a polynomial-time algorithm is given for computing λ(G) for interval graphs G which are extended bull-free or almost threshold (which highly restricts them). Skrien [30] characterized 2-LengthINT which can be realized by lengths zero (points) and one (unit intervals), leading to a linear-time recognition algorithm. As most of the efficient algorithms for intersection graph classes require representations, very little is known how to algorithmically use that a given interval graph can be represented by k lengths. In this paper, we show that partial representation extension is NP-hard already for 2-LengthINT.
All these difficulties lead us to introduce another hierarchy of k-NestedINT which generalizes proper interval graphs; see Fig. 2. We illustrate the nice structure of k-NestedINT by describing a relatively simple linear-time recognition algorithm based on MPQ-trees. To the best of our knowledge, the only reference is Fishburn's book [9] in which the parameter ν(G) called depth is considered and linked to k-LengthINT. There are some different generalizations of proper interval graphs [27], which are less rich and not linked to k-LengthINT.
Since k-NestedINT seem to share many properties with proper interval graphs, several future directions of research are immediately offered. Using our results, it is possible to describe minimal forbidden induced subgraphs [14]. For the computational problems which are tractable for proper interval graphs and hard for interval graphs, the complexity of the intermediate problems for k-NestedINT can be studied. (One such problem is FO property checking, discussed below.) In Lemma 3.2, we show that k-NestedINT can be efficiently encoded, similarly to proper interval graphs.
Our Results. In [15], a polynomial-time algorithm is given for recognizing 2-LengthINT when intervals are partitioned into two subsets A and B, each of one length, and both G[A] and G[B] are connected. This approach might be generalized for partial representation extension, but we show that removing the connectedness condition makes it hard: Theorem 1.1. The problem RepExt(2-LengthINT) is NP-hard when every pre-drawn interval is of one length a. It remains NP-hard even when (i) the input prescribes two lengths a = 1 and b, and (ii) for every interval, the input assigns one of the lengths a or b. Also, it is W[1]-hard when parameterized by the number of pre-drawn intervals.
We describe a dynamic programming algorithm for recognizing k-NestedINT, based on a data structure called an MPQ-tree. We show that we can optimize nesting greedily from the bottom to the top. We compute a so-called minimal representation for each subtree and we show how to combine them. This result has the following application in the computational complexity of deciding logic formulas over graphs. Let ϕ be the length of a first-order logic formula for graphs. By the locality, this formula can be decided in G in time n O(ϕ) . Since it is W[2]-hard to decide it for general graphs when parameterized by ϕ, it is natural to ask for which graph classes there exists an FPT algorithm running in time O(n c · f (ϕ)) for some computable function f .
In [12], it is shown that the problem above is W[2]-hard even for interval graphs. On the other hand, if an interval graph is given together with a k-length interval representation, [12] gives an FPT algorithm with respect to the parameters ϕ and the particular lengths of the intervals. It was not clear whether such an algorithm is inherently geometrical. Recently, Gajarský et al. [11] give a different FPT algorithm for FO property testing for interval graphs parameterized by ϕ and the nesting k, assuming that a k-nested interval representation is given by the input. By our result, this assumption can be removed since we can compute an interval representation of the optimal nesting in linear time.
The problem RepExt(k-NestedINT) is more involved since a straightforward greedy optimization from the bottom to the top does not work. The described recognition algorithm can be generalized to solve RepExt(k-NestedINT) in polynomial time [22]. It contrasts with Theorem 1.1. The partial representation extension problems for k-NestedINT and k-LengthINT are problems for which the geometrical version (at most k lengths) is much harder than the corresponding topological problem (the left-to-right ordering of endpoints of intervals).

Extending Partial Representations with Two Lengths
The complexity of recognizing k-LengthINT is a long-standing open problem, even for k = 2. In this section, we show that RepExt(k-LengthINT) is NP-hard even when k = 2. We adapt the reduction from 3-Partition used in [18,17] which is the following computational problem: This problem is strongly NP-complete [13], which means that it is NP-complete even when the input is coded in unary, i.e., all integers are of polynomial sizes.
Proof (Theorem 1.1). Assume (i) and (ii). For an instance of 3-Partition, the reduction constructs an interval graph G and a partial representation R as depicted in Fig. 4. We claim that R can be extended using two lengths of intervals if and only if the instance of 3-Partition is solvable. We set a = 1 and b = s·(M +2)−1. The partial representation R consists of s+1 disjoint pre-drawn intervals v 0 , . . . , v s of length a such that v i = [i · (M + 2), i · (M + 2) + 1]. So they split the real line into s equal gaps of size M + 1 and two infinite regions. Aside v 0 , . . . , v s , the graph G contains a vertex w represented by an interval of length b, adjacent to every vertex in G. Further, for each A i , the graph G \ w contains P 2Ai (a path with 2A i vertices) as one component, with each vertex represented by an interval of length a.
The described reduction clearly runs in polynomial time. It remains to show that R is extendible if and only if the instance of 3-Partition is solvable. The length of b implies that every extending representation has w = [1, s · (M + 2)] to intersect both v 0 and v s . Therefore, each of the paths P 2Ai has to be placed in exactly one of the s gaps. In every representation of P 2Ai , it requires the space at least A i + ε for some ε > 0. Three paths can be packed into the same gap if and only if their three integers sum to at most M . Therefore, an extending representation R gives a solution to 3-Partition, and vice versa. A similar reduction from BinPacking implies W[1]-hardness when parameterized by the number of predrawn intervals; see [18] for details.
This reduction can be easily modified when (i) and (ii) are avoided. We add two extra vertices: w 0 adjacent to v 0 and w s adjacent to v s , both non-adjacent to w. It forces the length of w to be in [s · (M + 2) − 1, s · (M + 2) + 1), so the length b does not have to be prescribed. Also, this reduction works even when non-predrawn intervals do not have lengths assigned.

Preliminaries and Basic Properties of k-Nested Interval Graphs
In this section, we describe basic definitions and properties about nesting in interval representations and about k-NestedINT.
Definitions. For an interval representation R, the nesting defines a partial ordering of intervals. Intervals u 1 , . . . , u k form a chain of nested intervals of length k if u 1 u 2 · · · u k . By ν(u), we denote the length of a longest chain of nested intervals ending with u . We denote ν(R) the length of a longest chain of nested intervals in R, i.e., and Proof. Let R be an interval representation partitioned into proper interval representations R 1 , . . . , R k . No chain of nested intervals contains two intervals from some R i , so the nesting is at most k. On the other hand, let R be a k-nested interval representation. We label each interval u by ν(u); see Fig. 2b. Notice that the intervals of each label i ∈ {1, . . . , k} form a proper interval representation R i .
Efficient encoding. An interval graph can be encoded by 2n log n bits by labeling the vertices 1, . . . , n and listing the left-to-right ordering of labels of the endpoints. Proper interval graphs can be encoded more efficiently using only 2n bits: the sequence of endpoints ( for left one, r for right one), as they appear from left to right. We generalize it for k-NestedINT.
Lemma 3.2. A graph in k-NestedINT can be encoded by 2n log k + 1 bits where n is the number of vertices.
Proof. See Fig. 2b for an example. Let R 1 , . . . , R k be the labeling from the proof of Lemma 3.1. From left to right, we output or r for each endpoint together with its labels. This encoding takes log k + 1 bits per endpoint.
Minimal Forbidden Induced Subgraphs. Interval graphs and the subclasses k-NestedINT and k-LengthINT are closed under induced subgraphs, so they can be characterized by minimal forbidden induced subgraphs. Lekkerkerker and Boland [26] describe them for interval graphs, and Roberts [28] proved that 1-NestedINT = 1-LengthINT are claw-free interval graphs. On the other hand, 2-LengthINT have infinitely many minimal forbidden induced subgraphs [8] which are interval graphs. In [14], our results in Section 5 are used to describe minimal forbidden induced subgraphs for k-NestedINT.

Maximal Cliques and MPQ-trees
In this section, we review well-known properties of interval graphs. First, we describe their characterization in terms of orderings of maximal cliques. Then we introduce a data structure called an MPQ-tree which stores all feasible orderings. Consecutive Orderings. Fulkerson and Gross [10] proved the following characterization of interval graphs; see An ordering of the maximal cliques satisfying the statement of Lemma 4.1 is called a consecutive ordering. Each interval graph has O(n) maximal cliques of total size O(n + m) which can be found in linear time [29]. Cleaned Representations. For a given consecutive ordering of maximal cliques, it is easy to construct a representation the number of all nestings called a cleaned representation. Proof. We place maximal cliques on the real line according to <. For each v ∈ V (G), we place v on top of the maximal cliques containing v. Let v ← be the left-most clique containing v and v → be the right-most clique containing v. We place v on the left of v ← and on the right of v → .
For a maximal clique C, let u 1 , . . . , u be all vertices having u ← i = C, i.e., all intervals u i start at C. Since there are no twins, we have u → i = u → j for all i = j. We order the left endpoints of u 1 , . . . , u exactly as the maximal cliques u → 1 , . . . , u → are ordered in <. Similarly, let v 1 , . . . , v be all vertices having v → i = C. We order the right endpoins of v 1 , . . . , v exactly as the maximal cliques v ← 1 , . . . , v ← are ordered in <.
The constructed interval representation avoids all unnecessary nesting. We get that u v if and only if v ← < u ← ≤ u → < v → in which case the nesting is clearly forced by the consecutive ordering <. The construction clearly runs in time O(n + m).

PQ-trees.
A PQ-tree T is a rooted tree, introduced by Booth and Lueker [2]. Its leaves are in one-to-one correspondence with the maximal cliques. Its inner nodes are of two types: P-nodes and Q-nodes. Each P-node has at least two children, each Q-node at least three. The orderings of the children of inner nodes are given. The PQ-tree T represents one consecutive ordering < T called the frontier of T which is the ordering of the leaves from left to right. The PQ-tree T represents all consecutive orderings of G as frontiers of equivalent PQ-trees which can be constructed from T by sequences of equivalent transformations of two types: (i) an arbitrary reordering of the children of a P-node, and (ii) a reversal of the order of the children of a Q-node; see Fig. 6.
A subtree T of the PQ-tree T consists of a node and all its descendants. For a node N , we denote the subtree having N as the root by T [N ] and its subtrees are the subtrees which have the children of N as the roots. MPQ-trees. An MPQ-tree [24] is an augmentation of a PQ-tree T in which the nodes of T have assigned subsets of V (G) called sections. To a leaf representing a clique C, we assign one section s(C). Similarly, to each P-node P , we assign one section s(P ). For a Q-node Q with subtrees T 1 , . . . , T q , we have q sections s 1 (Q), . . . , s q (Q) ordered from left to right, each corresponding to one subtree, and let s(Q) = s 1 (Q) ∪ · · · ∪ s q (Q). Examples of sections are depicted in Fig. 6.
The section s(C) has all vertices contained in the maximal clique C and no other maximal clique. The section s(P ) of a P-node P has all vertices that are contained in all maximal cliques of the subtree rooted at P and in no other maximal clique. Let Q be a Q-node with subtrees T 1 , . . . , T q . Let x be a vertex contained only in maximal cliques of the subtree rooted at Q, contained in maximal cliques of at least two subtrees. Then x is contained in every section s i (Q) such that some maximal clique of T i contains x.
Every vertex x is in sections of exactly one node of T . In the case of a Q-node, it is placed in consecutive sections of this node. For a Q-node Q, if x is placed in a section s i (Q), then x is contained in all cliques of T i . Every section of a Q-node is non-empty, and two consecutive sections have a non-empty intersection. After pruning twins, no two vertices belong to the exactly same sections of the MPQ-tree.
Let Proof. If u F v, then every consecutive ordering contains at least one maximal clique containing v on the left of all maximal cliques containing u and at least one on the right, so necessarily u v . Suppose that there exists a cleaned representation with u v . Therefore, every maximal clique contaning u also contains v, so u and v appear in sections of a path from a leaf to the root of the MPQtree, and v appears at least as high as u. Suppose that u F v. Both u and v do not belong to a same Q-node, otherwise they could not be nested in a cleaned representation. There is no Q-node on the path between u and v, above u; possibly u belongs to all sections of one Q-node. Therefore, we can reorder all these P-nodes to place the subtrees containing u on the side, and the obtained cleaned representation has u v .

Recognizing k-nested Interval Graphs
In this section, we describe a linear-time algorithm for computing minimal nesting of interval graphs. By  Therefore, the dynamic programming computes three values for each subtree T , denoted as a triple (α, β, γ), which we define formally in the next subsection. We have α = ν(G[T ]). The value β is the increase in the nesting when T is placed on the side, as in (i); so either β = α, or β = α − 1. The value γ is the increase in the nesting of one side, subject to the other side being optimized according to β, as in (ii). So always β ≤ γ and either γ = α or γ = α − 1.

Triples (α, β, γ)
For an interval graph G, we define the triple (α, β, γ) as follows. Let G α , G β and G γ be the graphs constructed from G as in Fig. 8. Let Similarly, for a subtree T of the MPQ-tree, we define its triple as the triple of G[T ]. The dynamic algorithm computes triples of all subtrees from the leaves to the root, and outputs a of the root as ν(G). T R Fig. 9. Three interval graphs G with ν(G) = 2, together with MPQ-trees T and representations R minimizing the nesting.
Proof. We prove equivalently that ν( The definition of G α implies that ν(G α ) = ν(G) + 1, since in every interval representation of G α , both endpoints of u α are covered by attached paths, and therefore a representation R of G is nested in u α . Since G is an induced subgraph of G β , we have ν(G) ≤ ν(G β ), so the inequality ν(G α ) − 1 ≤ ν(G β ) follows. For an alternative proof, consider a representation of G β minimizing nesting. We modify it to a representation of G α by stretching u β into u α , which increases nesting by at most one, and by adding the second path attached to u α . So ν(G α ) ≤ ν(G β ) + 1.
It remains to show the last inequality that ν(G γ ) ≤ ν(G α ). Consider a representation of G α with minimal nesting, we have G strictly contained inside u α . By shifting r(u α ) to the left, we get u γ . By adding v γ , we do not increase the nesting and we get a representation of G γ . So ν(G γ ) ≤ ν(G α ). Therefore, the triples classify interval graphs into three types; see Fig. 9 for examples. Corollary 5.2. Interval graphs G with ν(G) = k have triples of three types: (k, k − 1, k − 1), (k, k − 1, k) and (k, k, k).
Interpreting Triples. Let (α, β, γ) be the triple for G. We want to argue how the formal definition relates to the description in the last paragraph of Intuition. We can interpret the triple of G as increase in the nesting, depending how G is represented with respect to the rest of the graph. Since α = ν(G), it is easy to understand. Next, we describe an interpretation for the value β. Lemma 5.3. For every representation of G β , we have ν(u β ) ≥ β + 1.
Proof. We assume that a representation R β of G β is cleaned; it only decreases nesting. By the definition of β, there exists a maximal chain of nested intervals of length at least β + 1. Suppose that its length is at least two. Let R = R β [G], and we assume that u β covers R from the left. If this chain does not end with u β , it ends with an interval of R placed in the right-most maximal clique. Since every other interval of the chain is nested in u β , we replace this end with u β , and obtain a chain of nested intervals of length at least β + 1 ending with u β .
In other words, in every representation of G, there exists a chain of length at least β which is nested in any interval in the rest of the graph which plays the role of u β . In Lemma 5.5, we show that there exists a representation for which the length of a longest such chain is exactly β. This links the value β to Fig. 7i.
Last, we describe an interpretation for the value γ.
Lemma 5.4. For every representation of G γ , we have Proof. We prove this similar as in Lemma 5.3. Consider a cleaned representation R γ of G γ . It contains a maximal chain of length at least γ + 1 ending with x . If x = u γ and x = v γ , we can replace x with both u γ and v γ , so both ν(u γ ) ≥ γ + 1 and ν(v γ ) ≥ γ + 1. Otherwise, suppose that, say, x = v γ . Then ν(v γ ) ≥ γ + 1 and by removing v γ and the added intervals, we obtain a representation of R β with u β = u γ . By Lemma 5.3, ν(u β ) ≥ β + 1.
Therefore, in every representation of G, there exists a chain of length at least γ which is nested in any interval in the rest of the graph which plays the role of either u γ or v γ , while there is a chain of length at least β which in nested in any interval playing the role of the other one. In Lemma 5.5, we show that there exists a representation for which the lengths of longest such chains are exactly β and γ, respectively. This links the value γ to Fig. 7ii. Minimal Representations. Let (α, β, γ) be a triple of an interval graph G and let R be a cleaned representation of G with C ← and C → being the leftmost and the rightmost maximal cliques in its consecutive ordering of maximal cliques. We define: The representation R of G is minimal if ν(R) = α, ν → (R) = β and ν ← (R) = γ. So a minimal representation R can be used simultaneously in representations of G α , G β and G γ to get nestings α + 1, β + 1 and γ + 1, respectively. For instance, all representations in Fig. 9 are minimal.
Lemma 5.5. For every interval graph G, there exists a minimal representation R.
Proof. We argue according to the type of the triple of G.
The triple (k, k − 1, k). Let R β be a cleaned representation of G β minimizing the nesting such that Similarly as in the proof of Lemma 5.3, we get ν → (R) = k − 1. If u γ = u β and we add v γ with the attached path, we obtain a representation of G γ with nesting at least k + 1. Therefore, ν ← (R) = k and R is minimal.
The triple (k, k, k). Let R be a cleaned representation of G minimizing the nesting, so ν(R) = k. If ν → (R) < k or ν ← (R) < k, we can add u b and the attached intervals to obtain a representation of G b of nesting k, so b = k − 1; a contradiction. So ν → (R) = ν ← (R) = k and R is minimal.
Lemma 5.6. For every interval graph G, there exists a cleaned representation R of G minimizing the nesting such that for every subtree T of its MPQ-tree, R[T ] is minimal or R ↔ [T ] is minimal.
Proof. Let R be a cleaned representation of G minimizing the nesting, and consider a maximal subtree T for which R[T ] is not minimal. By Lemma 5.5, there exists a minimal representation appears consecutively in R, we replace it by R * T , and construct a modified cleaned representationR of G. It remains to argue that for every subtree T containing T , the representationR[T ] remains minimal; the lemmas then follows by induction.
We know that R[T ] is minimal. The modification only changed chains which start in R * T . By Lemmas 5.4, 5.5, we get that ν( ). Therefore, every chain above R[T ] extends only chains with lengths equal or shorter, soR[T ] remains minimal.
Triples for Leaves. Recall that we have no twins. For a leaf L of the MPQ-tree, we have either G[L] having no vertices (when s(L) = ∅), or G[L] ∼ = K 1 (when s(L) = {w}). In the former case, the triple of L is equal (0, 0, 0). In the latter case, it is equal (1, 0, 0).

Triples for P-nodes
Let T 1 , . . . , T p be the children of a P-node P , with p ≥ 2, with the computed triple (α i , β i , γ i ) for each subtree T i . We compute the triple (α, β, γ) of the subtree T = T [P ] using the following formulas; see  Proof. This proof also explains how these formulas are formed.
First, we argue that G[T ] has a representation R of nesting α from the formula. Intervals of all subtrees except for the leftmost subtree T s and the rightmost one T t are completely nested inside w ; and we minimize over all possible choices of s = t. Let R i be a minimal representation for G[T i ] from Lemma 5.5, and we use R ↔ s for G[T s ]. For every i = s, t, we get that ν(R i ) = α i is increased by one with w . For R s and R t , only ν ← (R ↔ s ) = β s and ν → (R t ) = β t are increased by one with w . We get On the other hand, consider a representation R of G[T ]. There is no chain of nested intervals containing intervals from two different subtrees T i and T j . Let R i = R[T i ] and let R s and R t be the leftmost and the rightmost of these representations, respectively. For every i = s, j, the representation R i has the nesting at least α i , so ν(R) ≥ α i + 1. By Lemma 5.4, we know that ν ← (R s ) ≥ β s and ν → (R t ) ≥ β t and these chains are nested in w , so ν(R) ≥ max{β s + 1, β t + 1}. So ν(R) ≥ α from the formula.
The value β is computed correctly. First, we construct a representation R β of G β with nesting β + 1. If s(P ) = {w}, in every cleaned representation, w u β , so that every other interval is either nested in both, or in neither. So we can assume that s(P ) = ∅.
When the added intervals are placed on the right of u β , intervals of all subtrees except for a left-most one T s are completely nested inside u β ; and we again minimize over all possible choices of s. Let R i be a minimal representation of G[T i ], we use R ↔ s for G[T s ]. For every i = s, we get that the nesting ν(R i ) = α i is increased by one by u β . For T s , the nesting ν ← (R ↔ s ) = β s is increased by one with u β . We get ν(R β ) = ν(u β ) = min s max{β s + 1, α i + 1 : i = s} = β + 1.
For the other implication, consider a cleaned representation of G β . Similarly, as above, we get that the nesting is at least β + 1.
The value γ is computed correctly. We just sketch the argument, it is similar as above. Let R i be a minimal representation of G[T i ]. We may choose T s and T t , and use R ↔ s for T s . Then only the nesting ν ← (R ↔ s ) = β s is increased by one with v γ and only the nesting ν → (R t ) = β t is increased by one with u γ . But since R ↔ s is nested inside u γ and R t is nested inside v γ , it does not matter and the nestings ν(R ↔ s ) and ν(R t ) are both increased by one anyway. Therefore, this choice of T s and T t is useless and a constructed representation of G γ has the nesting max{α 1 , . . . , α p } + 1. The other implication is proved similarly as before.
Lemma 5.8. For a P-node with p children, the triple (α, β, γ) can be computed in O(p).
Proof. By Lemma 5.1, we always have either β i = α i − 1, or β i = α i . Only in the former case, we may improve the nesting by choosing s = i or t = i. We call subtrees T i with β i = α i − 1 as savable.
For γ and for α with s(P ) = ∅, we just find the maximum α i which can be done in time O(p). For α with s(P ) = ∅ and β, we first locate all T i which maximize α i . If at least one of them is not savable, say T j , then α = α j + 1 and β = α j . Otherwise if all are savable, then the values α and β depend on the number of these subtrees. If there are at most two, then α = α i , otherwise α = α i + 1. If there is exactly one, then β = β i , otherwise β = β i + 1.
x 1 (1, 1, 1) x 1 x 3 x 2 x 5 x 4 x 6 D Fig. 11. On the left, a Q-node Q with eight subtrees. On the right, the DAG D of forced nestings in s(Q).

Triples for Q-nodes
The situation is more complex and the values γ are also required. Let Q be a Q-node with subtrees T 1 , . . . , T q , where q ≥ 3, each with a triple (α i , β i , γ i ). We want to compute the triple (α, β, γ) of the subtree T = T [Q]. Since lengths of chains are not changed by flipping Q, we can fix the left-to-right order of its subtrees as T 1 , . . . , T q . See Fig. 11 for an example.
For each T i , we choose either By combining these chosen representations R * i for all subtree T i , we get one of 2 q possible representations R[T ]. For each of them, we compute ν(x) for all x ∈ s(Q) using the following formulas: where Pred D (x) denotes the set of all direct predecessors of x in D. These values can be computed according to a topological sort of D.
Formulas for Triples. The triple (α, β, γ) is determined by minimal nestings of G α , G β , and G γ . We study how chains in s(Q) are extended by the added intervals u α , u β , u γ and v γ . Further, we consider two copies u β ← and u β → of u β . Recall that the left-to-right ordering of the subtrees of Q is fixed. Therefore, u β can intersect R either from left (represented by u β → ), or from right (represented by u β ← ). Similarly, we assume that u γ intersects R from left while v γ from right.
In other words, u α extends every chain in s(Q), but u β ← and v γ extend only those not ending with an interval in s 1 (Q), and u β → and u γ only those not ending with an interval in s q (Q). We compute (α, β, γ) of T [Q] using the following formulas: Lemma 5.9. The formulas compute the triple (α, β, γ) of T [Q] correctly.
Proof. We assume that the left-to-right order of subtrees of Q is fixed, it does not change nesting.
Recall that in a cleaned representation R of G[T ], the nesting ν(R) is determined by representations The value α is computed correctly. First, we construct a representation R α of G α with ν(R α ) = ν(u α ) = α + 1 for α given by the above formula. We construct 2 q representations for all choices of R * i using (1), and we use a representation minimizing the nesting, corresponding to the minimum min ∀R * i in the formula. The choices R * i determine a cleaned representation R α of G α . Nesting of the intervals of s(Q) is computed using (2)  The value β is computed correctly. Concerning β, in every cleaned representation R β of G β , either intervals of s q (Q) are not nested in u β (represented by u β ← ), or intervals of s 1 (Q) are not nested in u β (represented by u β → ). We compute both possibilities in β ← and β → , and use the minimum. The rest of the arguments is similar as above.
The value γ is computed correctly. Again, the arguments are similar as for α above, the only difference is that u α is replaced by both u γ and v γ .
Unfortunately, formulas do not directly lead to a polynomial-time algorithm since they minimize over 2 q possible choices of R * i . Next, we prove that these choices can be done greedily.
Lemma 5.10. For each of α, β ← , β → and γ, we can locally choose R * i minimizing the value.
Proof. Notice that the choices of R * i are independent of each other since each R * i influences only lenghts of chains starting in R[T i ]. We give a description for α, and it works similarly for the others.
For each x ∈ s(Q), we compute the length (x) of a longest chain in s(Q) ∪ {u α } starting with x . Let On the left, a proper interval graph G, i.e., ν(G) = 1. In the middle, an example of an extending representation R with ν(R) = 2, and its nesting is optimal since x u . Further, in every extending representation, x y or y u . On the right, the corresponding MPQ-tree T .
Proof. Since G[s(Q)] is connected, it contains at most m Q vertices. For every x ∈ s(Q), we know s ← x (Q) and s → x (Q) which we use to compute the DAG D. This can be done by considering all m Q edges, and testing for each whether the pair is nested. Then, we construct the extended DAG D .
For each x ∈ V (D ) and each y ∈ {u α , u ← β , u → β , u γ , v γ }, we compute the length of a longest path from x to y. This can be done in linear time for all vertices x by processing D from the top to the bottom. For each T i , we choose greedily R * i as described in the proof of Lemma 5.10. We compute the triple (α, β, γ) using the above formulas. The total running time is O(q + m Q ).

Construction of Linear-time Algorithm
We use the above results to prove that ν(G) can be computed in linear time: Proof (Theorem 1.2). For an interval graph G, we compute its MPQ-tree in time O(n + m) [24]. Then we process the tree from the leaves to the root and compute triples (α, β, γ) for every node, as described above. We output α of the root which is the minimal nesting number ν(G). By Lemmas 5.7 and 5.9, this value is computed correctly. By Lemmas 5.8 and 5.11, the running time of the algorithm is O(n + m).

Conclusions
In this paper, we have introduced k-nested interval graphs which is a new hierarchy of graph classes between proper interval graphs and interval graphs. The presented understanding is already much greater than understanding of k-length interval graphs reached after more than 35 years of their research. We have presented a relatively simple recognition algorithm based on dynamic programming and minimal representations. Other research directions immediately open. In [14], our results are used to derive minimal forbidden induced subgraphs of k-NestedINT. Problem 6.1. Which structural properties and characterizations of proper interval graphs generalize to k-nested interval graphs? Problem 6.2. Which computational problems solvable efficiencly for proper interval graphs can be solved efficiently for k-nested interval graphs as well?
The second problem is interesting for computational problems which are harder for general interval graphs. One example is deciding first-order logic properties which is W[2]-hard for interval graphs [12], but can be solved in FPTfor k-nested interval graphs [11].
In [22], our results are used to attack the problem RepExt(k-NestedINT). A polynomial-time algorithm for finding an extending interval representation of minimal nesting in derived, by a much more involved dynamic programming than in the recognition algorithm of Section 5. A partial representation R poses three restrictions: (i) Some pre-drawn intervals can be nested in each other which increases the nesting.
(ii) The consecutive ordering has to extend which restricts the possible shuffling of subtrees. (iii) Some subtrees can be optimized differently depending on the side they are attached.
The problem is difficult since we have to deal with them simultaneously. For an example, see Fig. 12.