1 Introduction

The area of exact algorithms for NP-hard problems is an old area in the field of design and analysis of algorithms, but also one with many important new developments. A recent overview of the area can be found in the book by Fomin and Kratsch [14]. In this paper, we consider exact algorithms for the problem called Intervalizing Coloured Graphs. This problem is defined in the following way. Given a graph G = (V, E) together with a proper vertex colouring c : V → {1,…,k} of G (a colouring c is proper if for all edges {v, w}∈E: c(v) ≠ c(w)), one must decide if G is subgraph of a properly coloured interval graph, i.e., can we add edges, such that each edge is between vertices of different colors and the result is an interval graph? The problem has its original motivation in DNA physical mapping [13].

This problem is NP-complete [13] (see also [18]), even when the number of colors equals four [5, 6], and in addition, inputs are restricted to caterpillar trees [1]. We denote the version of the problem where the number k of colors is fixed by Intervalizing k-Coloured Graphs, and the version with a potentially unbounded number of colors by Intervalizing Coloured Graphs.

If the number of colors equals two, the problem is trivially solvable in linear time. For three colors, the problem is solvable in quadratic time with a complicated algorithm [7]; the case for three colors and biconnected graphs is described in [6].

In this paper, we give two algorithms: one for the case that the number of colors is bounded by a constant, and one for the case that the number of colors is unbounded. The former result is relevant if the number of colors is a constant that is at least four, and forms a somewhat curious exception to a general pattern that can be observed in most exact algorithms for graph problems. Namely, the algorithm uses slightly less than exponential time. Most NP-hard problems that have subexponential algorithms deal with planar graphs and generalizations of planar graphs, see e.g., [12, 16, 23]. Typically, the running time of such algorithms is of the form \(2^{\mathcal {O}(\sqrt {n})}\). Our result is unlike most results in two ways: first, our inputs are general graphs (but a positive answer implies bounded pathwidth of the input; see Proposition 3 and its discussion), and secondly, the running time is ‘just subexponential’: it is bounded by \(2^{\mathcal {O}(n / \log n)}\).

Our algorithm for Intervalizing k-Coloured Graphs for fixed k can be viewed as a dynamic programming algorithm in Held-Karp style [21], resembling algorithms for some graph layout problems given e.g., in [8], but with one additional improvement: an isomorphism test on certain parts of the graph during the dynamic programming. Important concepts that facilitate the presentation of our results are the notions of path decomposition and nice path decomposition.

Our second result is an algorithm for Intervalizing Coloured Graphs (with no bound on the number of colors); this algorithm runs in \(\mathcal {O}^{\ast }(2^{n})\). It is a rather simple dynamic programming algorithm, also in Held-Karp style, and is the first exact algorithm for the problem.

This paper is organized as follows. In Section 2, preliminary definitions and results are given. In Section 3, the notion of partial path decomposition and some related notions are introduced, and a few structural results on these notions are derived. In Section 4, we give the algorithm for Intervalizing k-Coloured Graphs, and analyse its running time. In Section 5, the algorithm for Intervalizing Coloured Graphs is given. Some final remarks are made in Section 6.

2 Preliminaries

In this section, we introduce some standard notations, and give a few preliminary results on path decompositions.

The graphs in this paper are considered to be undirected and simple. We make a distinction between labelled and unlabelled graphs. In a labelled graph, each vertex has a unique label, and two isomorphic graphs with different labels are considered to be different. In contrast, two isomorphic unlabelled graphs are considered to be the same object. We also consider graphs given with a vertex colouring. A vertex colouring of a graph G = (V, E) is a function c : VC, for some finite set C. |C| is the number of colours. A vertex colouring c is proper, if for all edges {v, w} ∈ E, we have that c(v) ≠ c(w).

Throughout the paper, we assume that the input graph G is connected; if not, we can run the algorithm separately on each connected component of G.

For a graph G = (V, E) and a set of vertices WV, we denote G[W] as the subgraph induced by W: G[W]=(W,{{v, w} ∈ E | v, wW}).

A graph G = (V, E) is an interval graph, if we can associate to each vertex vV an interval on the real line I v =[ v , r v ], such that for all v, wV, vw: {v, w} ∈ E, if and only if I v I w .

A graph H = (V, F) is an interval completion of a graph G = (V, E), if G and H have the same vertex set, EF, and H is an interval graph. More background can be found in [17]; see also [20].

A path decomposition of a graph G = (V, E) is a sequence of subsets of V called bags, (X 1, X 2,…,X r ) such that:

  • \(\bigcup _{1\leq i\leq r} X_{i} = V\);

  • for all {v, w} ∈ E, there is an i, v, wX i ;

  • for all i 0, i 1, i 2: if 1 ≤ i 0i 1i 2r, then \(X_{i_{0}} \cap X_{i_{2}} \subseteq X_{i_{1}}\).

The width of a path decomposition (X 1, X 2,…,X r ) is max1 ≤ ir|X i |−1. The pathwidth of a graph G is the minimum width of a path decomposition of G.

A path decomposition (X 1, X 2,…,X r ) is nice, if for all i, 1 ≤ i < r, exactly one of the following two cases holds:

  • There is a vertex vV with X i + 1 = X i ∪{v}. We call X i + 1 an introduce node.

  • There is a vertex vV with X i + 1 = X i −{v}. We call X i + 1 a forget node.

If |X 1|=1, we also call X 1 an introduce node. The following proposition is well known. We give the proof for later reference.

Proposition 1 (Folklore)

Each graph G=(V,E) with pathwidth k has a nice path decomposition of width k with 2n bags, with |X 1 |=1, and X r =∅.

Proof

Suppose we have a path decomposition (X 1, X 2,…,X r ). We can turn it in a nice path decomposition as follows. First, remove all bags that are empty. If for some i, 1 ≤ i < r, i + 1 is not an introduce or forget bag, then we insert some new bags between i and i + 1: first forget nodes, one for each vertex in X i X i + 1, and then we have one introduce node for each vertex in X i + 1X i . Similarly, we add introduce nodes before X 1 when |X 1|≠1, and add forget nodes at the end of the procedure till X r = . We have one introduce and one forget node per vertex, so we have 2n bags. □

Proposition 2

There are at most (k + 2k + 1)2n − 1 unlabelled graphs with pathwidth at most k that are pairwise non isomorphic.

Proof

Consider a nice path decomposition of a graph with n vertices, with |X 1| = 1, and with 2n bags. For each of the bags X i , i > 1, there are at most k + 2k+1 possibilities: we can have a forget node, where we have the choice which of the at most k + 1 vertices in X i we forget, or we can have an introduce node, where we have the choice to which of the at most k vertices in X i the introduced vertex has an edge, i.e., at most 2k choices for an introduce node. If we have two graphs with two path decompositions that we can construct while always making the same choices, then these graphs are isomorphic. □

Proposition 3

Let G = (V, E) be a graph with proper vertex colouring c : V → {1, 2,…, k}. The following are equivalent.

  1. 1.

    G has a properly coloured interval completion, using colouring c.

  2. 2.

    G has a path decomposition (X 1, X 2,…,X r ), such that for all v, w ∈ V: if v ≠ w and there is an i with v, w ∈ X i , then c(v) ≠ c(w).

  3. 3.

    G has a nice path decomposition (X 1, X 2,…, X 2|V|) of width at most k−1, such that for all v, w ∈ V: if v ≠ w and there is an i with v, w ∈ X i , then c(v) ≠ c(w).

This proposition is well known. We sketch some of the proofs, as they provide some intuition for several of our later notions and results. Suppose H = (V, F) is a properly coloured interval completion of G. Consider the interval model of H. We can assume that all endpoints of intervals are different in this model. Use a scanline that moves in this model from left to right. While moving the scanline, we build a nice path decomposition with the required property. We start with an empty bag. Each time the scanline meets a left or right endpoint, we add a new node to the path decomposition. If we meet a right endpoint of an interval representing a vertex v, we have a forget node, where we forget v. If we meet a left endpoint of an interval representing a vertex v, we have an introduce node, where we introduce the vertex v. In this way, the vertices in a bag are exactly the vertices represented by the intervals that intersect the scanline. One easily verifies that we have obtained a nice path decomposition of H, and, as G is a subgraph of H, this is also a nice path decomposition of G. As H is properly coloured, vertices in the same bag are differently coloured.

For the reverse direction, suppose that we have a (nice) path decomposition (X 1, X 2,…,X r ) from Proposition 3 (ii) or (iii), one obtains the corresponding interval graph by making each X i a clique. The corresponding interval graph model is obtained by taking for a vertex v the interval \([\min _{v\in X_{i}} i, \max _{v\in X_{i}} i]\). As all colors in a bag X i are different, the width of the path decompositions is bounded by k − 1.

Note that it follows directly from Proposition 3, that a graph with a proper vertex colouring with k colors has pathwidth at most k − 1.

Proposition 3 motivates the definition of a properly coloured path decomposition: (X 1,…,X r ) is a properly coloured path decomposition of G, if and only if it is a path decomposition of G, and for all v, wV, if vw and there is an i with v, wX i , then c(v) ≠ c(w).

3 Partial Path Decompositions

In this section, we introduce a number of notions that will be used for our dynamic programming algorithm in the next section.

A partial path decomposition of a graph G = (V, E) is a sequence of subsets of V (X 1, X 2,…,X s ) such that:

  • (X 1, X 2,…,X s ) is a path decomposition of \(G[\bigcup _{1\leq i\leq s}, and X_{i}]\)

  • For each connected component of G[VX s ] with vertex set W, either \(W \subseteq \bigcup _{1\leq i\leq s-1} X_{i}\) or \(W \cap \left (\bigcup _{1\leq i\leq s-1} X_{i}\right ) = \emptyset \).

The following proposition follows from well known facts about path and tree decompositions. For completeness we give the proof.

Proposition 4

Let (X 1, X 2,…,X r ) be a path decomposition of G. Then, for each s, 1 ≤ s ≤ r, (X 1, X 2,…, X s ) is a partial path decomposition of G.

Proof

Suppose (X 1,…,X s ) is not a partial path decomposition. Write \(A= \bigcup _{1\leq i\leq s-1} X_{i}\) and \(B=\bigcup _{s+1\leq i\leq r} X_{i}\). There is a connected component of G[VX s ] with vertex set W, such that there is a vWA and a wWB. There is a path from v to w with all vertices in W, i.e., it avoids X s . This path contains two neighbouring vertices xA and yB. There is a bag X i with {x, y}⊆X i . If is, then yX s by the definition of path decomposition; if i > s, then xX s by definition of path decomposition. In both cases we have a contradiction. □

Consider a partial path decomposition (X 1, X 2,…,X r ) and a vertex set X. Later, X will typically be the set X r for some partial path decomposition (X 1, X 2,…,X r ). A component of X is a vertex set that forms a connected component of the graph G[VX]. We say that two components Y and Z of X are isomorphic components of X, if there is a graph isomorphism f of G[YX] to G[ZX] that preserves colors and is the identity when restricted to X, i.e., f is a bijective function, such that the following conditions hold:

  1. 1.

    For all v, wYX: {v, w} ∈ E ⇔ {f(v), f(w)} ∈ E.

  2. 2.

    For all vYX: c(v) = c(f(v)).

  3. 3.

    For all vX: f(v) = v.

A component W of X r is said to be a left component of the partial path decomposition (X 1,…,X r ), if \(W\subseteq \bigcup _{1\leq i\leq r-1} X_{i}\), and a right component of (X 1,…,X r ), if \(W \cap \left (\bigcup _{1\leq i\leq r-1} X_{i} \right ) = \emptyset \).

The following proposition follows directly from the definition of partial path decomposition, see also Proposition 4.

Proposition 5

Let (X 1 ,X 2 ,…,X r ) be a partial path decomposition of G. Each component of X r is either a left or a right component of (X 1 ,X 2 ,…,X r ).

We say that a partial path decomposition (X 1, X 2,…,X s ) of G = (V, E) is properly coloured, if for all v, wV, if vw and there exists an i with v, wX i , then c(v) ≠ c(w). We say that a (partial) path decomposition (Y 1, Y 2,…,Y s ) is an extension of a partial path decomposition (X 1, X 2,…,X r ) if rs and for all i, 1 ≤ ir, Y i = X i , i.e., (X 1,…,X r , Y r + 1,…,Y s ) extends (X 1,…X r ).

We define an equivalence relation on partial path decompositions as follows. We say that the partial path decomposition (X 1, X 2,…,X r ) is equivalent to the partial path decomposition (Y 1, Y 2,…,Y s ), if the following two conditions hold:

  1. 1.

    X r = Y s .

  2. 2.

    Suppose W 1, W 2,…,W q are the components of X r , i.e., the connected components of G[VX r ]. There is a bijective function g : {1, …,q} → {1, …,q}, such that for all i, 1 ≤ iq:

    • W i is a left component of (X 1, X 2,…,X r ), if and only if W g(i) is a left component of (Y 1, Y 2,…,Y s ) and

    • W i and W g(i) are isomorphic components of X r .

The main insight behind our dynamic programming algorithm is the following result.

Proposition 6

If (X 1 ,X 2 ,…, X r ) and (Y 1 ,Y 2 ,…,Y s ) are equivalent coloured partial path decompositions, then (X 1 ,X 2 ,…,X r ) has an extension that is a properly coloured path decomposition of G, if and only if (Y 1 ,Y 2 ,…,Y s ) has an extension that is a properly coloured path decomposition of G.

Proof

Suppose \((X_{1},X_{2},\ldots , X_{r}, Z_{1},Z_{2}, \ldots , Z_{r^{\prime }})\) is a properly coloured path decomposition of G that is an extension of (X 1, X 2,…,X r ). Suppose that W 1,…,W q are the components of X r . Let g be the bijective function as in the definition of equivalence. Let f i be a color preserving graph isomorphism from G[X r W i ] to G[X r W g(i)] that is the identity on X r , as implied by the definition of equivalence.

Let f : VV be the function defined in the following way.

  • for vW i , 1 ≤ ir: f(v) = f i (v);

  • for vX r , f(v) = v.

Claim 7

f is a color preserving automorphism of G.

Proof

f is a color preserving bijection: if vX r , then v does not belong to a component W i , so f −1(v)={v}. Otherwise, suppose vX g(i). If f(w) = v, then wW i and f i (w) = v; as f i is an isomorphism, there is only one such w; and as f i is color preserving, the color of w equals the color of v.

Consider an edge {v, w} ∈ E. There must be an i, with v, wW i X r . Now, f(v) = f i (v), and f(w) = f i (w). As f i is an isomorphism, {f(v), f(w)}={f i (v), f i (w)} ∈ E. Similarly, a pair of non-adjacent vertices is mapped to a pair of non-adjacent vertices. □

Define for \(i, ~1\leq i\leq r^{\prime }, ~Z^{\prime }_{i} = \{f(v)~|~v\in Z_{i}\}\).

Claim 8

\((Y_{1}, Y_{2}, \ldots , Y_{s}, Z^{\prime }_{1}, Z^{\prime }_{2}, \ldots , Z^{\prime }_{r^{\prime }})\) is a properly coloured path decomposition.

Proof

We first prove that \((Y_{1}, Y_{2}, \ldots , Y_{s}, Z^{\prime }_{1}, Z^{\prime }_{2}, \ldots , Z^{\prime }_{r^{\prime }})\) is a path decomposition.

First, we show that every edge {v, w} ∈ E is contained in some bag of \((Y_{1}, Y_{2}, \ldots , Y_{s}, Z^{\prime }_{1}, Z^{\prime }_{2}, \ldots , Z^{\prime }_{r^{\prime }})\). If v, wY s , then we can take the bag Y s ; so w.l.o.g., let vY s . If v belongs to a left component W i of (Y 1,…,Y s ), then there must be a bag Y j , 1 ≤ js − 1 that contains v and w as (Y 1, Y 2,…,Y s ) is a partial path decomposition. Now suppose that v belongs to a right component W i of (Y 1,…,Y s ). We have that W g −1(i) is a right component of (X 1,…,X r ). As {f −1(v), f −1(w)} ∈ E, there is a bag in \((X_{1}, X_{2}, \ldots , X_{r}, Z_{1}, Z_{2}, \ldots , Z_{r^{\prime }})\) that contains both f −1(v) and f −1(w). As W g −1(i) is a right component, this bag must be one of the Z j , 1 ≤ jr , and thus \(v,w\in Z^{\prime }_{j}\).

Second, it now directly follows that \(\left (\bigcup _{1 \leq i \leq s} Y_{i} \right ) \cup \left (\bigcup _{1 \leq i \leq r^{\prime }} Z^{\prime }_{i} \right ) = V\): as G is connected, each vertex is endpoint of an edge.

Third, we show that every vV only occurs in a series of consecutive bags. For a vertex vY s = X r , we note that there are 1 ≤ αs, 0 ≤ βr , such that v belongs to bags Y α , Y α + 1,…,Y s , and v belongs to bags Z 1, Z 2,…,Z β , and no other bags. As f(v) = v, v also belongs to bags \(Z^{\prime }_{1}, Z^{\prime }_{2}, \ldots , Z^{\prime }_{\beta }\), and no later bags. So, for a vertex vY s = X r , we are done.

If vW g(i) where W g(i) is a left component of (Y 1, Y 2,…,Y s ). Then, f −1(v) ∈ W i with W i a left component of (X 1, X 2,…,X r ). Thus, f −1(v) belongs to one or more consecutive bags in (X 1, X 2,…,X r − 1), and, as f −1(v) does not belong to X r , f −1(v) does not belong to \(Z_{1}, Z_{2}, \ldots , Z_{r^{\prime }}\) because otherwise \((X_{1},X_{2}, \ldots , X_{r}, Z_{1}, Z_{2},\ldots , Z_{r^{\prime }})\) is not a path decomposition. So, v belongs to one or more consecutive bags in (Y 1, Y 2,…,Y s − 1) and no others. And, if vW g(i) where W g(i) is a right component of (Y 1, Y 2,…,Y s ), then the required result follows from a similar analysis.

Finally, by assumption all vertices in a bag Y i have a different color, and, as f is color preserving, as all vertices in a bag Z i have a different color, also all vertices in a bag \(Z^{\prime }_{i}\) have a different color. We thus have shown Claim 8. □

So, (Y 1, Y 2,…,Y s ) has an extension that is a properly coloured path decomposition of G. This shows one direction of implication of the proposition; the proof of the other direction is identical. Thus, Proposition 6 holds. □

We assume some ordering on the vertices. The characteristic of a partial path decomposition (X 1, X 2,…,X r ) is the following pair:

$$(X_{r}, \bigcup_{1\leq i\leq r-1} X_{i} - X_{r}), $$

where we assume that both vertex sets are given as an ordered list of vertices.

Two properly coloured partial path decompositions with the same characteristic are trivially equivalent, using the identity for g. The algorithm in Section 5 basically tabulates all different characteristics of properly coloured partial path decompositions, and thus gives an \(\mathcal {O}(2^{n})\) algorithm for Intervaling Coloured Graphs; this is somewhat similar to the Held-Karp algorithm for TSP [21]. In case the number of colors is bounded, we can obtain a faster algorithm by applying an isomorphism check for components; this is the main ingredient of the faster algorithm described in the next section.

4 An Exact Algorithm for Intervalizing k-Coloured Graphs

In this section, we give the algorithm for Intervalizing k-Coloured Graphs, building upon the notions and preliminary results of the previous sections.

First, we note that a positive instance has a path decomposition in which each bag has size at most k (all vertices in a bag have a different color and there are k colors). Thus, as a first step we use the linear time algorithm (for fixed k), that tests if the pathwidth of the input graph is at most k − 1 from [4, 10]. If not, we are done, and can decide negatively. Thus, we can assume that G has pathwidth at most k in the remainder. We consider k to be a constant.

We introduce some further notions.

We define the progress of a partial path decomposition (X 1, X 2,…,X r ) to be \(2 \cdot | \bigcup _{1\leq i\leq r} X_{i}| - |X_{r}|\). Note that when we extend a nice partial path decomposition with one additional introduce or one additional forget node, then the progress always increases by exactly one. As the characteristic of (X 1,…,X r ) is \((X_{r}, \bigcup _{1\leq i < r} X_{i} - X_{r})\), it follows that if a partial path decomposition has characteristic (X, Z), its progress equals 2|Z|−|X|.

The canonical characteristic of a properly coloured partial path decomposition is the lexicographically minimal characteristic over all characteristics of equivalent properly coloured partial path decompositions.

Proposition 9

Given a characteristic of a properly coloured partial path decomposition, we can compute in polynomial time its canonical characteristic.

Proof

The Graph Isomorphism problem is polynomial time solvable on graphs of bounded treewidth, and thus also on graphs of bounded pathwidth [3, 15]. It is straightforward to modify the algorithms of [3] or [15] such that it also works on coloured graphs while using the same running time. (More precisely, the very recent result of Fomin et al. [15] shows that Graph Isomorphism is fixed parameter tractable, with the treewidth as parameter; this improvement is however suppressed by other factors in the running time of our algorithm.)

Given a characteristic (X r , Z), we first compute (with depth first search) the connected components of G[VX r ], say W 1, W 2,…,W q . For each pair W i , W j , we can check in polynomial time if they are isomorphic: use the isomorphism algorithm on coloured graphs of bounded pathwidth discussed above, and take a new, different color for each vertex in X r . (Note the definition of isomorphism for components, as given in Section 3).

Thus, we can partition the components in equivalence classes dictated by isomorphism. We can sort each component lexicographically, and then each class lexicographically. Then, for each class, we determine how many components from the class are a subset of Z (i.e., left components). In the canonical characteristic, we take the same number of left components from the class, but now take this number of lexicographically smallest elements. A simple last sorting step gives the desired result. □

We can now describe our algorithm.

  • Check if the pathwidth of G is at most k − 1. If not, answer no and terminate.

  • Otherwise, for α = 1⋯2n, compute a table T α of all canonical characteristics of partial path decompositions of progress α.

  • If T 2n is empty, then answer no; otherwise, answer yes.

The output of the algorithm clearly is correct as a partial path decomposition is a path decomposition, if and only if, its progress equals 2n.

We now describe how the tables T i are computed. Computing T 1 is simple: for all vV, we have an entry in T 1 of the form ({v},). Given a table T α , 1 ≤ α<2n, we compute table T α + 1 as follows. Initialize T α + 1 as empty set. For each entry (X, Z) from T α , do the following:

  • Compute the new characteristics that result when the next node in the partial path decomposition is an introduce node: for each vVZX such that there is no xX with c(v) = c(x), compute the canonical characteristic of (X∪{v},Z) and put it in T α + 1.

  • Compute the new characteristics that result when the next node in the partial path decomposition is a forget node: for each xX such that there is no vZVX with {v, x} ∈ E, compute the canonical characteristic of (X − {v},Z∪{v}).

Proposition 10

The procedure correctly computes table T α+1 .

Proof

Note that the characteristic of a partial path decomposition remains the same when we apply the procedure of Proposition 1. So, we may assume that we compute the canonical characteristics of the properly coloured nice partial path decompositions (X 1, X 2,…,X r ) with progress α + 1. Of these, we consider two cases: the last node X r can be an introduce node or a forget node.

If X r is an introduce node with X r = X r − 1∪{v}, then (X 1, X 2,…,X r − 1) is a properly coloured partial path decomposition of progress α. If (X 1, X 2,…,X r − 1) has characteristic (X r − 1, Z), then (X 1, X 2,…,X r ) has characteristic (X r − 1∪{v},Z). v must have a color different from the colors of vertices in X r − 1.

If X r is a forget node with X r = X r − 1−{v}, then again (X 1, X 2,…,X r − 1) is a properly coloured partial path decomposition of progress α. As v is forgotten, it cannot belong to bags right of X r , and thus all neighbours of v must belong to \(\bigcup _{1\leq i\leq r} X_{i}\). If (X 1, X 2,…,X r − 1) has characteristic (X r − 1, Z), then the characteristic of (X 1, X 2,…,X r ) is (X r − 1−{v},Z∪{v}). □

This completes the description of the algorithm. From our discussion, we see that the algorithm indeed correctly decides if G has a properly coloured interval completion.

We now will analyse the running time of the algorithm. We remark that our algorithm uses polynomial time per entry in a table T i . Thus, the running time of the algorithm equals the product of a polynomial in n and the number of canonical characteristics of properly coloured partial path decompositions. So, we need to establish an upper bound on this number of canonical characteristics. First, we obtain an upper bound on the number of non-isomorphic components of a set X.

Proposition 11

Let (X 1 ,X 2 ,…,X r ) be a properly coloured partial path decomposition of G. There are at most (k⋅2 3k ) equivalence classes of the isomorphism relation on components of G[V−X r ] that contain components with ℓ vertices.

Proof

Each equivalence class can be identified by an uncoloured unlabelled graph on vertices of pathwidth at most k − 1, a colouring with at most k colors of the vertices of the graph, and the incidence relation between the vertices in the graph and the vertices in X r . This gives at most the following number of equivalence classes:

$$(k-1+2^{k-1}+1)^{2\ell-1} \cdot k^{\ell} \cdot 2^{k\ell} \leq k^{\ell} \cdot 2^{3k\ell} = (k \cdot 2^{3k})^{\ell} $$

because the first gives at most (k − 1+2k − 1+1)2 − 1 possibilities by Proposition 2, the second at most k possibilities, and the last at most 2k possibilities. □

To show that the size of a table T i is bounded by \(2^{\mathcal {O}(n /\log n)}\), we consider three cases for the components of G[VX r ]; for each we count the number of possibilities they give in the table T i .

Let \(c_{k} = \frac {1}{2 \log k \cdot 3k}\).

  • A component is large, if it has at least c k ⋅ logn vertices. For each, we have the possibility to be a left or a right component. As there are \(\mathcal {O}(n / \log n)\) large components, this gives \(2^{\mathcal {O}(n / \log n)}\) possibilities for the large components.

  • A component is frequent-small, if it is not large and it has at least \(\sqrt {n}\) isomorphic components of G[VX r ]. Note that there are at most \(\sqrt {n}\) equivalence classes of the isomorphism relation that contain frequent-small components. As there are less than n components, this gives at most \(n^{\sqrt {n}} = 2^{(\log n) \sqrt {n}} = 2^{O(n / \log n)}\) possibilities.

  • A component is infrequent-small, if it is not large and it has less than \(\sqrt {n}\) isomorphic components of G[VX r ]. There are less than

    $$(k \cdot 2^{3k})^{c_{k} \log n} = 2^{\log k \cdot 3k \cdot c_{k} \cdot \log n} = 2^{(\log n)/2}=\sqrt{n} $$

    equivalence classes of the isomorphism relation that contain small components, by Proposition 11. For each class with infrequent-small components, we have less than \(\sqrt {n}\) components in the class, and thus at most \(\sqrt {n}\) possibilities regarding the number of left components in the class. This gives a total of at most \(\sqrt {n}^{\sqrt {n}} = 2^{O(n / \log n)}\) possibilities for infrequent-small components.

For a fixed set X, the number of characteristics of the form (X, Z) is obtained by multiplying the number of possibilities for large, frequent-small, and infrequent-small components. As each case is bounded by \(2^{\mathcal {O}(n / \log n)}\), we obtain a bound of \(2^{\mathcal {O}(n / \log n)}\). To obtain an upper bound on the total size of a table, we note that X is a subset of at most k vertices, and as \((n+1)^{k} = 2^{\mathcal {O}(n / \log n)}\), we have that each table T i has a size bounded by \(2^{\mathcal {O}(n / \log n)}\). As the running time of the algorithm is bounded by a polynomial times the size of these tables, we obtain our main result.

Theorem 12

For every fixed k ≥ 4, there is an algorithm for Intervalizing k-Coloured Graphs that runs in time \(2^{\mathcal {O}(n / \log n)}\).

We remark that there are inputs on which the algorithm uses Ω(2n/ logn) time: suppose G has a vertex v that is a separator such that G[V − {v}] has Ω(n/logn) non-isomorphic components each of size ⌊logn⌋.

5 An Algorithm for Intervalizing Coloured Graphs with an Arbitrary Number of Coors

In this section, we consider the case that the number of colors is not fixed. We give a simple Held-Karp style dynamic programming algorithm for this problem.

Suppose we are given a properly coloured graph G = (V, E). For a given set of vertices WV, the border of W is the set of vertices in W with at least one neighbour in VW, i.e., we denote

$$B(W) = \{v\in W~|~ \exists w\in V-W: \{v,w\}\in E\} $$

A set of vertices WV is said to be fine, if there exists a properly coloured path decomposition (X 1, X 2,…,X s ) of G[W], such that B[W]⊆X s , i.e., the last bag contains all vertices in the border of W.

Lemma 13

For all W⊆V, W≠∅, W is fine, if and only if, there exists a v∈W, such that W−{v} is fine and all vertices in B(W−{v})∪{v} have a different color.

Proof

Suppose W is fine. Suppose (X 1, X 2,…,X s ) is a properly coloured path decomposition of G[W] with B(W)⊆X s . If s = 1, the result follows directly (any vertex in X 1 can play the role of v). Suppose s > 1. If X s X s − 1, then (X 1,…,X s − 1) is also a properly coloured path decomposition of G[W] with B(W)⊆X s , and we look at this path decomposition instead. Repeat the step till X s ⫅̸X s − 1 or s = 1. So, we may suppose that X s ⫅̸X s − 1.

Take a vertex vX s X s − 1. X s must contain each vertex wB(W − {v}), as for each such w, either wB(W) or {v, w} ∈ E. So all vertices in B(W − {v})∪{v}⊆X s have a different color. W − {v} is fine, as (X 1, X 2,…,X s − 1, X s −{v}) fulfils the stated condition.

For the other direction, suppose that W − {v} is fine, and all vertices in B(W − {v})∪{v} have a different color. Let (Y 1, Y 2,…,Y r ) be a properly coloured path decomposition with B(W − {v})⊆Y r . A simple case analysis shows that (Y 1, Y 2,…,Y r , B(W − {v}{v}) is a properly coloured path decomposition of G[W] with B(W)⊆B(W − {v})∪{v}. E.g., each neighbour in v that belongs to W − {v} belongs to B(W − {v}), and thus to the last bag. □

Lemma 13 directly implies the existence of a dynamic programming algorithm that uses \(\mathcal {O}^{\ast }(2^{n})\) time. For i = 0, 1, …, n, we compute the collection of fine sets W with |W|=i; call this collection F(i). For i = 0, we note that the empty set is fine, i.e., F(0)={}. If i > 0, initialize F(i) as an empty collection. Then, perform the following step for each fine set YF(i − 1):

  • Compute the border of Y, B[Y]. This can be done in linear time using depth first search.

  • If B[Y] contains two vertices of the same color, we do not further process Y, otherwise continue with the next step.

  • For all vertices vVY,

    • Check if B[Y] contains a vertex with the same color as v.

    • If not, then Y∪{v} is a fine set of size i. If F(i) does not yet contain Y∪{v}, then add Y∪{v} as a new element to F(i).

It is easy to see that the amount of work per fine set of vertices is polynomial. Finally, G has a properly coloured interval completion, if and only if F(n) ≠ . Thus, we have

Theorem 14

The Intervalizing Coloured Graphs problem can be solved in \(\mathcal {O}^{\ast }(2^{n})\) time.

6 Conclusions

In this paper, we gave a dynamic programming algorithm for the Intervalizing k-Coloured Graphs problem for a fixed number of colors k. It uses subexponential time of a somewhat unusual form, and thus, the result forms a somewhat curious exception to the types of results that are usually obtained in the field. The result is merely of theoretical interest, as values of n for which the algorithm can be run in practice can be expected to be rather small, say below 100. Experiments with a somewhat similar Held-Karp style algorithm for Treewidth [9] suggest that our algorithm can also be practical for small values of n. In particular, it would be interesting to test a variant of the algorithm where the isomorphism test is applied heuristically, i.e., only on components that are very small, and with components, and with a usual graph isomorphism heuristic instead of the (complicated and probably only theoretically interesting) algorithms from [3, 15].

The result with an arbitrary number of colors from Section 5 follows more standard arguments; the algorithm is similar to Held-Karp style algorithms for several layout problems, see [8].

A minor generalization of the result can be obtained when we consider a small (o(logn)) number of colors; in such cases the algorithm also uses subexponential time.

A generalization of the Intervalizing k-Coloured Graphs problem is the Interval Graph Sandwich problem, in which we are given two graphs with G and H with the same vertex set, and ask whether there exists an interval graph G that is a subgraph of H and contains G as a subgraph. A well studied variant has the additional condition that G has maximum clique size k. See e.g., [19, 22]. The ideas of our paper seem not to give results better than an algorithm that uses Θ(2n) time for this problem however, still assuming that k is fixed.

Other related problems are the version where we ask to find a properly coloured proper interval graph, which is polynomial for a fixed number of colors k [2], and the problem to find a properly coloured chordal graph, which is also polynomial for a fixed number of colors [24].

Very recently, Bodlaender and Nederlof [11] obtained a lowerbound for the problem: assuming the Exponential Time Hypothesis, an algorithm for Intervalizing k-Coloured Graphs uses at least 2Ω(n/ logn) time, for each fixed number of colours at least six.