Exact and Approximate Bandwidth

Marek Cygan and Marcin Pilipczuk

Dept. of Mathematics, Computer Science and Mechanics, University of Warsaw, Poland {cygan,malcin}@mimuw.edu.pl

Abstract. In this paper we gather several improvements in the field of exact and approximate exponential-time algorithms for the BANDWIDTH problem. For graphs with t we present a O(nO(t)2n) exact algorithm. Moreover for the same class of graphs we introduce a subexponential constant-approximation scheme Ð for anyα>0 there exists a (1 + α)-approximation algorithm running in O(exp(c(t + n/α)logn)) time where c is a universal constant. These re- sults seem interesting since Unger has proved that BANDWIDTH does not belong to AP X even when the input graph is a (assuming P = NP). So some- what surprisingly, despite Unger’s result it turns out that not only a subexponen- tial constant approximation is possible but also a subexponential approximation scheme exists. Furthermore, for any positive integer r,wepresenta(4r − 1)- approximation algorithm that solves BANDWIDTH for an arbitrary input graph ∗ n in O (2 r ) time and polynomial space.1 Finally we improve the currently best known exact algorithm for arbitrary graphs with a O(4.473n ) time and space algorithm. In the algorithms for the small treewidth we develop a technique based on the Fast Fourier Transform, parallel to the Fast Subset Convolution techniques introduced by Bj¬orklund et al. This technique can be also used as a simple method of finding a chromatic number of all subgraphs of a given graph in O∗(2n) time and space, what matches the best known results.

1 Introduction

Notation. In this paper we focus on exponential-time exact and approximation algo- rithms for the BANDWIDTH problem. Let G =(V,E) be an undirected graph with n = |V |. For a given one-to-one function π : V →{1, 2 ...,n} (called an ordering) its bandwidth is the maximum difference between positions of adjacent vertices, i.e. maxuv∈E |π(u) − π(v)|.Thebandwidth of the graph, denoted by bw(G), is the mini- mum bandwidth over all orderings. The BANDWIDTH problem asks to find an ordering with bandwidth bw(G). W.l.o.g. we can assume that G is connected, otherwise we can consider all connected components of G independently.

Motivation. The BANDWIDTH problem seems to be hard from many perspectives. It is NP-hard even on some subfamilies of trees [10,12], does not belong to APX even when G is a caterpillar [15] and is hard for any fixed level of the W hierarchy [3]. The best known 3 √ polynomial-time approximation, due to Feige [7], has a O(log n log n log log n) ap- proximation guarantee. At WG’08 we presented an exact algorithm for arbitrary graphs

1 By O∗ we denote standard big O notation but omitting polynomial factors.

S. Albers et al. (Eds.): ICALP 2009, Part I, LNCS 5555, pp. 304Ð315, 2009. c Springer-Verlag Berlin Heidelberg 2009 Exact and Approximate Bandwidth 305 that runs in O∗(5n) time and O∗(2n) space [5]; we were able to enhance this algorithm to run in O(4.83n) time at the cost of O∗(4n) space complexity [4]. However, the fastest ex- act algorithm that runs in a polynomial space needs O∗(10n) time[8].Wearenotawareof any published faster algorithms for trees or graphs with bounded treewidth, but we were informed [9] that very recently, Amini, Fomin and Saurabh independently developed a O(nO(t)2n) algorithm for graphs with treewidth t, using completely different approach than ours. Since a polynomial time constant approximation for the BANDWIDTH problem is probably not possible, it seems reasonable to search for approximation algorithms that are faster than the exact ones, but still give us a constant approximation guarantee at the cost of a superpolynomial time complexity. This area was considered recently by Bourgeois et al. [13]. Our results. We present several results in the field of exponential solutions to the BANDWIDTH problem, both approximate and exact. First, we define a DISJOINT SET SUM problem and show how to solve it using the Fast Fourier Transform in a similar time complexity as the Fast Subset Convolution [2]. This problem appears to be a crucial part in some NP-hard problems like CHROMATIC NUMBER. We solve these problems in time matching the best known results. ∗ n Then we use DISJOINT SET SUM to develop a simple O (2 ) time and space ex- act algorithm for the BANDWIDTH problem for trees. We enhance this algorithm to work in O(nO(t)2n) time and space for graphs with treewidth t (for more about the treewidth see [6]). Later, we exploit the idea from the exact algorithm to obtain a subexponential approximation scheme for trees and graphs with bounded treewidth. Precisely, for a parameter α>0,wegeta(1 + α)-approximation algorithm that works in O(exp(c(t + n/α)logn)) time and space. As far as we know this is the first ex- ample of a problem that is not approximable with a constant factor in a polynomial time and admits a subexponential approximation scheme. Further we switch to arbitrary graphs and develop, for a fixed integer r ≥ 1,an exponential approximation algorithm with a (4r − 1)Ðapproximation guarantee that works in O∗(2n/r) time and polynomial space. Finally, we present a O∗(20n/2)= O(4.473n) time and space exact algorithm for arbitrary graphs, improving the previous O(4.83n) bound from [4]. Organization. In Section 2 we present a definition and solution using the Fast Fourier Transform for DISJOINT SET SUM and discuss usage of the Fast Subset Convolution. In Section 3 we use DISJOINT SET SUM to develop an exact algorithm for graphs with bounded treewidth and in Section 4 we describe an approximation scheme for the same class of graphs. Sections 5 and 6 contain approximate and exact algorithms for arbitrary graphs respectively.

2 DISJOINT SET SUM and Its Solutions

In this section we focus on the DISJOINT SET SUM problem, defined as follows. Con- sider a set N = {1,...,n} and two sets A, B containing subsets of N as its elements (A, B ⊆ 2N ). Our goal is to compute A⊕B = {A∪B : A ∈ A,B ∈ B,A∩B = ∅} — 306 M. Cygan and M. Pilipczuk explaining in words we would like to find all subsets of N which can be represented as a disjoint sum of two sets, where one of them is contained in A and one in B. Moreover for each set in A ⊕ B we would like to know in how many ways one can obtain it as such a disjoint sum. LetusfirstsolvetheDISJOINT SET SUM naively. Taking each pair of sets from A and B would take us O∗(4n) time, but we easily improve this result by considering all subsets of N and for each such set X ⊆ N iterate through all its subsets A ⊆ X and check whether A ∈ A and X \ A ∈ B (which can be decided in polynomial of ∗ n n time using any balanced search tree). This improvement leads to O (3 ) time, since n n i n n i=0 i 2 =(2+1) =3 . However, this can be done much better. Theorem 1. Let A, B ⊆ 2N , we can compute A ⊕ B in O∗(2n) time and space. More- over for each element in A ⊕ B we obtain the number of ways it can be composed as a disjoint sum. Note that Theorem 1 is a quite straightforward corollary from the Fast Subset Con- volution algorithm by Bj¬orklund et al. [2]. The SUBSET CONVOLUTION problem can be defined as follows: given functions f and g defined on the lattice of subsets of an n-element setN, compute their subset convolution f ∗ g defined for all S ⊆ N by (f ∗ g)(S)= T ⊆S f(T )g(S \ T ).Bj¬orklund et al. [2] developed a very clever algo- ∗ n rithm that computes SUBSET CONVOLUTION in O (2 ) time. By taking f =1A and ∗ n g =1B this algorithm solves DISJOINT SET SUM in O (2 ) time. Here we present a different approach to the DISJOINT SET SUM problem. In Section 2.1 we show how to solve it using the Fast Fourier Transform. The FFT solution has a few advantages over FSC. As to our best knowledge it is new, gives the same time complexity as FSC (up to a polynomial factor), FFT is probably more widely known in the computer science community than FSC and, most important, although the methods are somehow similar, FFT allows some extensions that seems hard for FSC approach; since we use in Section 4 the extension defined in Section 2.2, we prefer the FFT solu- tion. On the other hand, note that the FSC solution allows a smaller polynomial factor hidden in the O∗() notation.

2.1 Solution Using the Fast Fourier Transform The Fast Fourier Transform is an efficient algorithm which computes the discrete Fourier transform and its inverse. Due to its efficiency it has several applications, in- cluding digital signal processing and big integer or polynomial multiplication. However surprisingly enough, FFT happened to be a handy tool in DISJOINT SET SUM. We can group subsets of N belonging to A and B according to their cardinality, thus it is sufficient to solve the reduced problem, where sets in A and B have fixed sizes, 2 denote them by kA and kB. This grouping gives us only n overhead which is omitted in the O∗ notation. To use FFT we need to look at our problem from a different angle, we treat subset A ⊂ N as a monomial xbin(A),wherebin(A) ∈ [0, 2n −1] is the binary representation of a subset A. Grouping sets according to their size allows us to use the following observation: Lemma 2. Let A, B be subsets of {1,...,n}.ThenA ∩ B = ∅ iff the number of ones in the binary representation of their sum bin(A)+bin(B) is equal to |A| + |B|. Exact and Approximate Bandwidth 307

Now we represent A and B as polynomials (where each element from A and B is a monomial) and multiply those polynomials using FFT in O∗(2n) time. We iterate over all subsets I ⊆ N having exactly kA + kB elements and check what coefficient stands in front of xbin(I) in the resulting polynomial. This coefficient is clearly the number of ways in which I can be composed as a disjoint sum. We perform n2 polynomial multiplications using FFT. Each multiplication needs O(2n log(2n)) arithmetic operations, which consume a polynomial time, thus we get a O∗(2n) time and space algorithm.

2.2 FFT and DISJOINT SET SUM Extension

We can extend the FFT solution to DISJOINT SET SUM to the following problem. Fix an integer r ≥ 1. Instead of having A, B ⊆ 2N we can have A, B ⊆{0, 1,...,r}N , i.e., A and B are sets of n-tuples of integers from the set {0, 1,...,r}. In this setting, for every n-tuple X ∈{0, 1,...,r}N we ask for the number of partitions of X into a sum A + B,whereA ∈ A, B ∈ B and the addition is defined pointwise, i.e., X(i)= A(i)+B(i) for i ∈ N.Inotherwords,A ⊕ B = {(A1 + B1,...,An + Bn):(Ai) ∈ A ∧ (Bi) ∈ B}. Note that classical DISJOINT SET SUM is the extended problem with r =1. ∗ n Using FFT, we can solve the extended DISJOINT SET SUM in O ((r +1) ), assum- ing r = O(nγ ) for some constant γ (in our applications r ≤ n). We simply apply the previous solution, but treat tuple X ∈{0, 1,...,r}n as a number written in the base r +1. As before, we split summands in respect of their sum of digits.

2.3 Applications We can use the disjoint sets merging in all kinds of partition problems which fit into the following framework. Consider an n-element set U and a family S ⊆ 2U of its subsets.

Definition 3. For a positive integer k ≤ n and subset X ⊆ U let pk(X) be the number of ordered k-partitions of X into subsets being elements of S, i.e., pk(X) is the number of ways to choose S1,...,Sk ∈ S, which are pairwise disjoint and Si = X.

Using tools introduced in the previous subsection we calculate a series of sets Pi,where P1 = S and Pi+1 = Pi ⊕ S (for i =2,...,n). With each element of Pi we store the number of ways it can be represented as a disjoint sum of elements from S (which are extracted easily from the presented polynomials). Clearly pk(X) is the coefficient stored in Pk related to X (or pk(X)=0if X ∈ Pk).

∗ n Theorem 4. For each k and X we can compute all values pk(X) at once in O (2 ) time and space.

Despite simplicity, our tool can be used to solve the CHROMATIC NUMBER problem in O∗(2n) time, which was a major open problem in the exact algorithms field, solved in 2006 independently by Bj¬orklund and Husfeldt in [1] and by Koivisto in [11] via the inclusion-exclusion principle. To achieve it we simply take all independent sets of the given graph as a family S. Another problems that fit into the partition problems category 308 M. Cygan and M. Pilipczuk are DOMATIC NUMBER,BOUNDED COMPONENT SPANNING FOREST,PARTITION INTO HAMILTONIAN SUBGRAPHS and BIN PACKING (all of those were mentioned in [1]). For all those problems we get O∗(2n) time and space algorithms, which are the same as the best known results. Moreover this framework also counts the number of solutions for those problems and calculates the number of partitions not only for the whole set, but also for all its subsets.

3 Exact Algorithm for Trees

In this section let us assume that the input graph for the BANDWIDTH problem is a tree T . We are given an integer 1 ≤ b

Definition 5. Let v be a vertex of the given tree and posv be a positive integer (1 ≤ posv ≤ n). By assignments(v, posv) we denote a set of all such subsets mask ⊆ {1,...,n} for which there exists a surjective function f : T (v) → mask satisfying:

Ð ∀w∈T (v)\{v}|f(w) − f(parent(w))|≤b. Ð f(v)=posv.

Less formally assignments(v, posv) is corresponding to the set of all legal (with band- width not greater than b) assignments of vertices T (v) with the vertex v having a fixed position posv, where from each assignment we remember only the set of used positions (since relative order of vertices from T (v) does not matter outside this subtree). To find assignments(v, posv) for the vertex v and every posv firstly we set assignments(v, posv) to contain only the set {posv}, which is the position used by v. Now we have to join assignments(v, posv) with assignments for each child, one by one. We can join assignments of v with assignments for a child u iff u and v are not too far away from each other (which is easy to control using positions of those vertices) and sets of used positions are disjoint, and this is the place where we can use disjoint sets merging via FFT or FSC (see Pseudocode 1 for details). To check whether there exists an ordering of T with bandwidth not greater than b we run the GENERATEASSIGNMENTS(r) procedure and check whether there exists i such that assignments(r, i) is not empty, since the only element that can be in this set is the set of all positions {1,...,n}.

Theorem 6. Algorithm 1 solves the Bandwidth problem for trees in O∗(2n) time and 2 space. For each edge of our tree we solve O(n ) DISJOINT SET SUM instances. Exact and Approximate Bandwidth 309

Algorithm 1. Exact algorithm for trees 1: procedure GENERATEASSIGNMENTS(v) 2: for posv ← 1 to n do 3: assignments(v,posv) ←{{posv }} 4: for each child u of v do 5: GENERATEASSIGNMENTS(u) 6: for posv ← 1 to n do 7: temp assignments ←∅ 8: for posu ← max(1,posv − b) to min(n, posv + b) do 9: temp assignments ← temp assignments∪ 10: (assignments(v,posv) ⊕ assignments(u, posu)) 11: assignments(v,posv) ← temp assignments

12: procedure BANDWIDTH(T ,b) 13: GENERATEASSIGNMENTS(r)  We start from the root. 14: for i ← 1 to n do 15: if assignments(r, i) = ∅ then 16: return true 17: return false

In case of a positive answer, we could also be interested in finding an ordering with bandwidth not greater than b. This is not hard, but due to the space limitations we omit details here. At the end, let us note that the aforementioned algorithm, at the cost of a polynomial factor in the complexity, can count the number of orderings with bandwidth at most b. As mentioned in Section 2, in the DISJOINT SET SUM problem we can count the number of possible partitions, thus in the end obtaining the number of orderings. Note that in this approach the coefficients in FFT (FSC) are of size O(n!), thus they have O(n log n) bits and still all arithmetic operations can be done in polynomial time. It is not hard to guess that our algorithm can be modified to handle not only trees, but also graphs with a fixed treewidth. If a graph has treewidth at most t this leads to a O(nO(t)2n) algorithm. Since this modification does not introduce more understanding for the bandwidth problem and can be easily performed by anyone familiar with the treewidth we omit details here.

4 Approximation Scheme for Trees

Now we modify the algorithm presented in the previous section to construct an ap- proximation scheme, still assuming that the input graph is a tree. The bottleneck of the exact algorithm for trees is the number of elements in assignments set, which is 2n, because we assign vertices to specific positions. We can, however, loose this constraint and instead of an ordering construct a coarse ordering. Definition 7. A coarse ordering is a function A : V → 2Z, assigning to every vertex v ∈ V an interval A(v)=[av,bv] ⊂ Z.Anorderingπ is consistent with the coarse ordering A if for all v ∈ V we have π(v) ∈ A(v). Assume we want to have a (1 + α)-approximation algorithm for a constant α>0. 310 M. Cygan and M. Pilipczuk

Let us recall that the exact algorithm introduced by Saxe (see [14]) performs well for a small bandwidth of the given graph. Saxe’s algorithm checks whether graph has bandwidth at most b, and if so constructs an ordering, in O∗((4n)b) time and space. Our algorithm, given an integer 1 ≤ b k . We use coarse orderings where values of A can be intervals of length k (except pos- sibly the last interval which has size n mod k). The i-th interval contains positions {(i−1)k+1,...,min((i+1)k, n)}. Like in the previous section assignments(v, posv) corresponds to the set of all legal orderings of T (v) (trying to have bandwidth not greater than b), but this time from each assignment we remember only to which interval vertex v was assigned and the number of vertices assigned to each interval. n The following algorithm, given an integer k

Definition 8. Lev v be a vertex of the given tree and posv be a positive integer (1 ≤ n posv ≤k ). By assignments(v, posv) we denote a set of all tuples (a1,...,a n ), n k where 0 ≤ ai ≤ k, such that there exists a function f : T (v) →{1, ...,  k } satisfying:

Ð ∀w∈T (v)\{v}(|f(w) − f(parent(w))|−1) · k

max A(v) − min A(u)=(fA(v) − fA(u)) · k + k − 1 ≤ 2k + b − 1. Since segments — values of the coarse ordering — are disjoint, one can easily find any ordering consistent with the given coarse ordering. This ordering has bandwidth at most 2k + b − 1. Note that if b ≥ bw(G), the algorithm does not fail to find a coarse ordering. Indeed, if π is an ordering with bw(π) ≤ b, the algorithm may generate an assignment fA(v)=  π(v)  k .  √ n  ≥ Note that k

Theorem 9. For arbitrary b at least one algorithm, Saxe’s or ours, runs in O(exp(c n/α log n)) time.

Note that, similarly as the algorithm described in Section 3, this algorithm extends to the class of graphs with treewidth not greater than t at the cost of a O(nO(t)) time and O(t)  n  space overhead. In this case the presented algorithm works in O(n (k +1) k ) time and space, whereas the Saxe’s algorithm does not use any treewidth assumption, thus the approximation scheme is still subexponential.

5 Approximation Algorithm for General Graphs

In this section we describe an approximation algorithm that, for a fixed integer r ≥ 1, computes, given an undirected connected graph G =(V,E),anorderingπ satisfy- ing bw(G) ≤ bw(π) ≤ (4r − 1)bw(G). The algorithm works in O∗(2n/r) time and polynomial space and uses coarse orderings (see Definition 7). Note that, given a coarse ordering A, checking if there exists any ordering consis- tent with A can be done in O(n log n) time. We use a simple greedy algorithm that assigns vertices to successive positions 1, 2,...,n. For any position i, it chooses still unassigned vertex v such that i ∈ A(v) and for any other unassigned vertex w with i ∈ A(w), max A(v) ≤ max A(w).

Lemma 10. Let A be a coarse ordering for an input graph G =(V,E).Lets be the size of the largest interval in A, i.e., s =maxv∈V |A(v)|. If there exists an ordering π∗ of bandwidth at most b consistent with A, then one can find in a polynomial time an ordering π that is consistent with A and has bandwidth at most s + b.

Proof. For every edge uv replace A(u) by A(u) ∩ [min A(v) − b, max A(v)+b] and similarly for A(v). This operation maintains the invariant that π∗ is consistent with A. Then find any ordering consistent with the new coarse ordering.

Let us now describe our algorithm. For a fixed positive integer r we obtain a (4r − 1)- approximation algorithm. Let T be any fixed spanning tree of G and take any vertex of G as a root of T . For any vertex v different from the root, by parent of v we denote the parent of v in the rooted tree T . The algorithm, given an integer 1 ≤ b

Algorithm 2. Generating assignments in the (4r − 1)-approximation algorithm 1: procedure GENERATEASSIGNMENTS(A) 2: if all nodes in T are assigned then 3: Cut all intervals in A to make them contained in {1,...,n}. 4: Use Lemma 10 to find ordering consistent with A. 5: else 6: v ← a node in T such that v’s parent w is assigned; let Ij,2i = A(w). 7: if i +1≤ 2r − 1 then 8: GENERATEASSIGNMENTS(A ∪{(v, Ij−1,2(i+1)}) 9: else 10: GENERATEASSIGNMENTS(A ∪{(v, Ij−1,2r}) 11: GENERATEASSIGNMENTS(A ∪{(v, Ij−1+2r,2r })

12: procedure MAIN(i0) 13: for j ← 0 to n/b −1 do

14: GENERATEASSIGNMENTS ({(r, Ij,2i0 )})  Generate all assignments with root in

Ij,2i0

Let i0 ∈{r,...,2r − 1} be a parameter that we determine later. The algorithm assigns the root of T to all possible intervals of size 2i0b that overlap with {1,...,n} and extends each of these partial assignments recursively. To extend a given assignment, the algorithm chooses a node v of T such that the parent w of v has been already assigned an interval, say Ij,2i. Consider the interval Ij−1,2(i+1) which is obtained from Ij,2i by “extending” it by b positions both at the left and right side. Note that in any ordering consistent with the current assignment, v is put in a position from Ij−1,2(i+1). Hence, if Ij−1,2(i+1) is not too big, i.e. i +1≤ 2r − 1, the algorithm simply assigns Ij−1,2(i+1) to v and proceeds with no branching (just one recursive call). Otherwise, if i +1=2r, the interval Ij−1,2(i+1) is split into two intervals of size 2r, namely Ij−1,2r and Ij−1+2r,2r and two recursive calls follow: with v assigned to Ij−1,2r and Ij−1+2r,2r respectively. For every generated assignment (after cutting the intervals to make them contained in {1,...,n}) the algorithm applies Lemma 10 to verify whether it is consistent with an ordering of bandwidth [2(2r − 1) + 1]b =(4r − 1)b. It is clear that the produced ordering has bandwidth at most (4r − 1)b. The following lemma finishes the proof of correctness of the Algorithm 2. Lemma 11. If there exists an ordering π with bw(π) ≤ b, then Algorithm 2 produces at least one coarse ordering consistent with π. Proof. To produce such a coarse ordering, just simulate Algorithm 2 and at each step, whenever the algorithm has a choice for a vertex v between Ij−1,2r and Ij−1+2r,2r, choose the interval containing π(v).Sincebw(π) ≤ b, the produced coarse ordering is consistent with π. Exact and Approximate Bandwidth 313

We conclude with the time complexity analysis. Observe that the nodes at tree distance d from the root are assigned intervals of size 2[(i0 + d)modr + r]. It follows that branching appears only when i0 + d ≡ 0(modr).Letnˆ(i0) denote the number of nodes at tree distance d satisfying this condition. It is clear that the above algorithm ∗ nˆ(i0) works in time O (2 ).Since i∈{r,...,2r−1} nˆ(i)=n,forsomei ∈{r,...,2r−1}, ∗ n/r nˆ(i) ≤ n/r. By choosing this value as i0,wegettheO (2 ) time bound.

Theorem 12. For any positive integer r,thereisa(4r − 1)-approximation algorithm ∗ n/r for BANDWIDTH running in O (2 ) time and polynomial space. 

6 Exact Algorithm for General Graphs

In this section we focus on the exact algorithm for the BANDWIDTH problem on general graphs. This algorithm works in O∗(20n/2) ≤ O(4.473n) time, improving previous results [4] [5]. As an input, the algorithm takes a connected undirected graph G = (V,E),where|V | = n, and a number b, 1 ≤ b

6.1 Segments and Colors First, let us recall some important observations made in [5]. An ordering π is called a b- ordering if bw(π) ≤ b.LetPos = {1, 2,...,n} be the set of possible positions and for i every position i ∈ Pos we define the segment it belongs to by segment(i)= b+1  and n the color of it by color(i)=(i − 1) mod (b +1)+1.BySeg = {1, 2,..., b+1 } we denote the set of possible segments, and by Col = {1, 2,...,b +1} the set of possible colors. The pair (color(i), segment(i)) defines the position i uniquely. We order positions lexicographically by pairs (color(i), segment(i)), i.e., the color has higher order that the segment number, and call this order the color order of positions. By Posi we denote the set of the first i positions in the color order. Given some (maybe partial) ordering π,andv ∈ V for which π(v) is defined, by color(v) and segment(v) we understand color(π(v)) and segment(π(v)) respectively. Let us recall the crucial observation made in [5]. Lemma 13 ([5], Lemma 8). Let π be an ordering. It is a b-ordering iff, for every uv ∈ E, |segment(u) − segment(v)|≤1 and if segment(u)+1 = segment(v) then color(u) > color(v) (equivalently, π(u) is later in color order than π(v)).

6.2 The Algorithm In the algorithm, the state and extension are defined as follows. 314 M. Cygan and M. Pilipczuk

Definition 14. A pair (A, f) where A ⊂ V and f : A → Seg is called a state iff the following condition holds:

1. The multiset {f(v):v ∈ A} is equal to the multiset {segment(i):i ∈ Pos|A|}. 2. If uv ∈ E and u, v ∈ A,then|f(u) − f(v)|≤1. 3. There exists f¯ : V → Seg with f ⊂ f¯ such that for every edge uv ∈ E, we have |f¯(u) − f¯(v)|≤1 and if u ∈ A, v/∈ A then f¯(u) ≥ f¯(v).

Definition 15. A state (A ∪{v},f) is an extension of a state (A, f) with a vertex   v/∈ A iff f = f |A and for all uv ∈ E with u ∈ A we have f(u) ≥ f (v).

The following equivalence holds (compare to [5], Lemma 11).

Lemma 16. Let π be a b-ordering. For 0 ≤ k ≤ n let Ak = {v ∈ V : π(v) ∈ Posk} | ≤ and fk = segment Ak . Then every (Ak,fk) is a state and for every 0 k

Lemma 17. Assume we have states (Ak,fk) for 0 ≤ k ≤ n and for all 0 ≤ k

Theorem 18. There are at most O∗(20n/2) states.

Due to the space limit, we omit details of the proof of Theorem 18, but we quickly sketch it. First, note that if we remove some edges of G, the number of states does not decrease, so we can assume that G is a tree and we root it at some vertex vr.LetB be the set of vertices that have at least two children in G.Wedefineprestate (A, f) as a state, but with the function f defined on A ∪ B instead of A. The number of prestates is not smaller that the number of states and the number of prestates can be bounded inductively for every subtree of G. Note that checking if a pair (A, f) is a state can be done in a polynomial time. Points 1 and 2 are trivial to check. For Point 3 we can iteratively calculate for every v ∈ V \ A function p(v) ⊂ Seg, intuitively the set of possible values for f¯(v), by the following algorithm.

Algorithm 3. Check if (A, f) satisfies Point 3 of the state definition 1: Set p(v):=Seg for all v ∈ V \ A. 2: repeat 3: for all v ∈ V \ A do   4: p(v):=p(v) ∩ u∈N(v)∩A{f(u) − 1,f(u)}∩ u∈N(v)\A i∈p(u){i − 1,i,i+1} 5: until some p(v) is empty or we do not made any change of any p(v) in the inner loop 6: return True iff all p(v) remain nonempty.

This algorithm performs at most |Seg|n ≤ n2 runs of the outer loop, since reevalu- ated p(v) can only be a subset of the previous value. The proof of correctness of Algo- rithm 3 is quite straightforward, but due to the space limit we omit it here. It is easy to Exact and Approximate Bandwidth 315 see that checking if (A,f) is an extension of (A, f) and generating all extensions of the given state (A, f) can be done in polynomial time, too. The algorithm is quite simple now. We do the depth-first search over states, starting from the state (∅, ∅).Fromastate(A, f) we can move to any of its extension and we seek for any state (A, f) with A = V . We remember (in some balanced search tree) all visited states and do not go into into the same state twice. By Lemmas 16 and 17, we reach such state iff there exists a b-ordering in G. Therefore Theorem 18 implies that:

Theorem 19. The Bandwidth problem can be solved in O∗(20n/2) time and space.

Acknowledgments. We would like to deeply thank Lukasz Kowalik for supervising our work in the BANDWIDTH problem area and giving us a lot of valuable comments and remarks.

References

1. Bj¬orklund, A., Husfeldt, T.: InclusionÐexclusion algorithms for counting set partitions. In: Proc. FOCS 2006, pp. 575Ð582 (2006) 2. Bj¬orklund, A., Husfeldt, T., Kaski, P., Koivisto, M.: Fourier meets m¬obius: fast subset convo- lution. In: STOC 2007: Proceedings of the thirty-ninth annual ACM symposium on Theory of computing, pp. 67Ð74. ACM Press, New York (2007) 3. Bodlaender, H.L., Fellows, M.R., Hallett, M.T.: Beyond NP-completeness for problems of bounded width: Hardness for the W hierarchy (extended abstract). In: ACM Symposium on Theory of Computing, pp. 449Ð458 (1994) 4. Cygan, M., Pilipczuk, M.: Even faster exact bandwidth, arxiv:0902.1661v1 (unpublished, 2008), http://arxiv.org/abs/0902.1661v1 5. Cygan, M., Pilipczuk, M.: Faster exact bandwidth. In: Broersma, H., Erlebach, T., Friedet- zky, T., Paulusma, D. (eds.) WG 2008. LNCS, vol. 5344, pp. 101Ð109. Springer, Heidelberg (2008) 6. Diestel, R.: . Springer, Heidelberg (2005) 7. Feige, U.: Approximating the bandwidth via volume respecting embeddings. J. Comput. Syst. Sci. 60(3), 510Ð539 (2000) 8. Feige, U.: Coping with the NP-hardness of the graph bandwidth problem. In: Halld«orsson, M.M. (ed.) SWAT 2000. LNCS, vol. 1851, pp. 10Ð19. Springer, Heidelberg (2000) 9. Fomin, F.: Private communication (2009) 10. Garey, M., Graham, R., Johnson, D., Knuth, D.: Complexity results for bandwidth minimiza- tion. SIAM J. Appl. Math. 34, 477Ð495 (1978) 11. Koivisto, M.: An O∗(2n) algorithm for and other partitioning problems via inclusionÐexclusion. In: Proc. FOCS 2006, pp. 583Ð590 (2006) 12. Monien, B.: The bandwidth-minimization problem for caterpillars with hairlength 3 is np- complete. SIAM J. Algebraic Discrete Methods 7, 505Ð512 (1986) 13. Escoffier, B., Bourgeois, N., Paschos, V.T.: Efficient approximation by “low-complexity” exponential algorithms. Cahier du LAMSADE 271, LAMSADE, Universite Paris-Dauphine (2007) 14. Saxe, J.: Dynamic programming algorithms for recognizing small-bandwidth graphs in poly- nomial time. SIAM Journal on Algebraic Methods 1, 363Ð369 (1980) 15. Unger, W.: The complexity of the approximation of the bandwidth problem. In: Proc. FOCS 1998, pp. 82Ð91 (1998)