On the complexity of the Maximum Cut problem Hans L. Bodlaender  Klaus Jansen y Abstract The complexity of the simple maxcut problem is investigated for several special classes of graphs. It is shown that this problem is NP-complete when restricted to one of the following classes: chordal graphs, undirected path graphs, split graphs, tripartite graphs, and graphs that are the complement of a bipartite graph. The problem can be solved in polynomial time, when restricted to graphs with bounded treewidth, or cographs. We also give large classes of graphs that can be seen as generalizations of classes of graphs with bounded treewidth and of the class of the cographs, and allow polynomial time algorithms for the simple max cut problem. 1 Introduction One of the best known combinatorial graph problems is the max cut problem. In this problem, we have a weighted, undirected graph G = (V;E) and we look for a partition of the vertices of G into two disjoint sets, such that the total weight of the edges that go from one set to the other is as large as possible. In the simple max cut problem, we take the variant where all edge weights are one. Whereas the problems where we look for a partition with a minimum total weight of the edges between the sets are solvable in polynomial time with ow techniques, the (decision variants of the) max cut , and even the simple max cut problems are NP- complete [13, 10]. This motivates the research to solve the ( simple ) max cut problem on special classes of graphs. In [12] Johnson gives a table of the known results on the complexity of simple max cut restricted to several classes of graphs. The most notable of the results listed there, is perhaps the fact that simple max cut can be solved in polynomial time on planar graphs. Several cases however remain open. In this paper we resolve some of the open cases. This paper is mostly concerned with the simple max cut problem. In section 4 we comment on the max cut problem (i.e., the problem where edges do not necessarily have unit weights.) Some applications of the maxcut problem are given in the references [5, 6, 15].  Department of Computer Science, Utrecht University, P.O.Box 80.089, 3508 TB Utrecht, The Nether- lands. The work of this author was partially supported by the ESPRIT II Basic Research Actions Program of the EC under contract no. 3075 (project ALCOM). y Fachbereich IV, Mathematik und Informatik, Universit. at Trier, Postfach 3825, W-5500 Trier, Germany 1.This paper is organized as follows. In section 2 we consider the chordal graphs, and the undirected path graphs. Next, we consider the split graphs, tripartite graphs, and complements of bipartite graphs. In section 3.1, we consider cographs. An algorithm to solve simple max cut on graphs with bounded treewidth is described in section 3.2. In section 3.3, the results of sections 3.1 and 3.2 are generalized. Finally, in section 4 we comment on the problem with arbitrary edge weights. We conclude this introduction with some de nitions. We rst give a precise description of the simple max cut problem. Problem: simple max cut Input: Undirected graph G = (V;E), k 2 IN. Question: Does there exist a set S ˆ V , such that jf(s; u) 2 Ejs 2 S; u 2 V k ? If we have a partition of V into sets S  V , and V S, then an edge (u; v) 2 E with u 2 S, v 2 V S is called a cut edge. 2 NP-completeness results In this section we analysed the simple max cut problem for chordal graphs, split graphs, tripartite graphs, and complements of bipartite graphs. 2.1 Graphs, related to chordal graphs A graph is chordal, if and only if it does not contain a cycle of length at least four as an induced subgraph. Alternatively, a graph is chordal, if and only if there exists a tree T = (W; F) such that one can associate with each vertex v 2 V , a subtree Tv = (Wv ;Ev) of T, such that (v; w) 2 E i Wv \ Ww 6 = ;. This is equivalent to stating that all maximal cliques of G can be arranged in a tree T, such that for every vertex v, the cliques that contain v form a connected subtree of T. (In other words: chordal graphs are the intersection graphs of subtrees of trees.) We will show that simple max cut is NP-complete for chordal graphs. Hereto, we use the max 2-sat problem, described below. Problem: max 2-sat Input: A set of p disjunctive clauses each containing at most two literals and an integer k  p. Question: Is there a truth assignment to the variables which satis es at least k clauses ? Max 2-sat was proven to be NP-complete by Garey, Johnson and Stockmeyer [10]. (In [10] also a transformation from max 2-sat to the simple max cut problem for undirected graphs was given.) We note [9] that 3-sat remains NP-complete if for each variable there are at most ve clauses that contain either the variable or its complement. Using the reduction of Garey, Johnson and Stockmeyer [10] we can obtain a similar result for max 2-sat such that for each variable there are at most 20 clauses containing the variable or 2.its complement. It is possible to replace the number 20 by the smaller constant six using a di erent construction. In this construction each literal (variable or its complement) occurs at most three times. Theorem 2.1 Simple max cut is NP-complete for chordal graphs. Proof: (We will omit in this and all later proofs the statement that the problems are in NP.) We give a transformation from max 2-sat to simple max cut for chordal graphs. Let X = fx1 ; : : :; xn ; x1 ; : : :;xng be a variable set, let (a1 _ b1); : : :;(ap _ bp) denote a set of clauses. Let m = 2p. First we de ne a number of sets: (1) for each i 2 f1; : : :; ng take C (i) = fc (i) 1 ; : : :; c (i) m+1 g, D (i) = fd (i) 1 ; : : :; d (i) m+2 g, E (i) = fe (i) 1 ; : : :; e (i) m+2 g. (2) take for each i 2 f1; : : : ; pg, the set T (i) = ft (i) 1 ; : : :; t (i) m+2 g, and take the sets R = fr1 ; : : :; rpg, Q = fq1 ; : : :; qpg, Y = fy1 ; : : :; ypg and S = fs1 ; : : :; sm+1g. (3) take U = fu1 ; : : :; upg, V = fv1 ; : : :; vpg, W = fw1 ; : : :; wpg, and Z = fz1 ; : : :; zpg. In the following we de ne an input graph G 0 = (V 0 ;E 0 ) and want to partition the vertex set V 0 into sets V1 and V2 where V1 gets literals with truth value true and V2 gets literals with value false. The sets in (1) are used to place xi into V1 or V2 and the complement xi into the other set. Furthermore, the sets in (2) place R and Q into the rst set V1 which contains the literals with value false. For all values to ai ; bi with (ai _ bi) =true we want to have the same number of generated cut edges and for (ai _bi) =false a smaller number of cut edges. To obtain this we use the sets in (3) and the set Q = fq1 ; : : :; qpg. We now de ne the input graph G 0 = (V 0 ;E 0 ) for the simple max cut problem. V 0 is the disjoint union of all sets: X, C (i) (1  i  n), D (i) (1  i  n), E (i) (1  i  n), S, R, Q, T (i) (1  i  p), U, V , W, and Z. There is an edge between a pair of vertices in G 0 , if and only if at least one of the following sets contains both vertices, i.e. each of the following sets forms a clique in G 0 :  for each i 2 f1; : : :; ng: { fxig [C (i) [ E (i) , { fxig [C (i) [ D (i) , { fxi ; xig [C (i) ,  for each j 2 f1; : : : ; m+ 1g, take a set (clique) R [ fsj g.  X [ R [ Y .  for each i 2 f1; : : :; pg, and each j 2 f1; : : :;m+ 2g, take a set (clique) fri ; qi ; t (i) j g.  for each i 2 f1; : : :; pg: if the ith clause is (ai _ bi), then take sets (cliques) 3.{ fai ; bi ; ri ; qig { fai ; bi ; vi ; wig { fai ; ui ; vig { fbi ; vi ; zig First, we claim that the graph G 0 , formed in this way ischordal. This follows because we can arrange all cliques in a tree T, such that every vertex belongs to a set of trees that forms a connected subtree of T. (Alternatively, one can check by tedious case analysis that G 0 does not contain an induced cycle of length more than 3.) In order to count the maximum number of possible cut edges, we consider six types of edges: 1. Edges between vertices in C (i) [ D (i) [ E (i) [ fxig, for some i 2 f1; : : : ; ng. 2. Edges of the form (xi ; c (i) j ). 3. Edges between vertices in X [ R [ Y . 4. Edges of the form (ri ; sj ). 5. Edges of the form (ri ; qi), (ri ; t (i) j ), (qi ; t (i) j ), for some i 2 f1; : : : ; ng. 6. Edges of the form (qi ; ai), (qi ; bi), (ai ; ui ), (ai ; vi), (ai ; wi), (bi ; vi), (bi ; wi), (bi ; zi ), (ui ; vi ), (vi ; wi ), (wi ; zi), for some i 2 f1; : : :; ng, where the ith clause is (ai _ bi). Note that each edge of G 0 has exactly one type. Write B = 2n  (m +2) 2 + n  (m +1) + (n + p) 2 + p  (m +1) + 2p  (m +2) + 6p. We now claim that G 0 has a partition with at least B + 2k cut edges, if and only there is a truth assignment, that veri es at least k clauses. Suppose we have a truth assignment, that veri es at least k clauses. We construct a partition V 0 = V1 [ V2, V1 \ V2 = ; in the following way: V1 = R [ Q [ fxi ; c (i) j jxi false g [fxi ; d (i) j ; e (i) j jxi true g [fui ; zijai false ^ bi false g [fvi ; zijai false ^ bi true g [fui ; wijai true ^ bi false g [fvi ; wijai true ^ bi true g V2 = V n V1 : We have 2n  (m+2) 2 cut edges of type 1, n  (m+1) cut edges of type 2, (2n +p) 2 cut edges of type 3, p  (m+1) cut edges of type 4, and 2p  (m+2) cut edges of type 5. For a clause that is true, the number of type 6 cut edges corresponding to that clause is eight, and for a clause that is false, this number is six. Hence, the total number of cut edges of type 6 is 6p + 2k. The total number of cut edges of all types is precisely B + 2k. We can show, that when we have a partition of V 0 in sets V1, V2 with at least B+2k cut edges, then there must be a truth assignment with at least k true clauses. We consider for 4.each type of edges the maximum number of cut-edges. We compare these numbers with the numbers obtained in the partition formed above. For the details, we refer to our full paper. NP-hardness of the problem follows, because G 0 can be constructed in polynomial time. 2 Now we analyse a subclass of the chordal graphs, the undirected path graphs. A graph is an undirected path graph, if it is the intersection graph of paths in an (unrooted, undirected) tree. In other words, G = (V;E) is an undirected path graph, if and only if there exists a tree T = (W; F), and for every vertex v 2 V a path Pv in T, such that for all pairs of vertices v; w 2 V , v 6 = w: (v; w) 2 E, if and only if Pv and Pw have at least one vertex in common. Theorem 2.2 Simple max cut is NP-complete for undirected path graphs. Proof: We can show this by changing the construction from the proof above. We use that max 2- sat remains NP-complete, when for each variable, the number of clauses that contains the variable is bounded by the constant 3. Then, we replace each variable xi by xi;1 ; : : :; xi;3 and xi by xi;1 ; : : :;xi;3 and enlarge the sets D (i) and E (i) by two vertices. 2 A graph G = (V;E) is a split graph, if and only if there is a partition of the vertices V of G into a clique C and an independent set U. Another necessary and sucient condition for a graph G to be a split graph is that G and its complement G c are chordal graphs, see also F.oldes and Hammer [8]. We analyse now asubclass of the split graphs, namely the class of those split graphs where each vertex of the independent set U is incident to exactly two vertices of the clique C. We call these graphs the 2-split graphs. Theorem 2.3 Simple max cut is NP-complete for 2-split graphs. Proof: We use a transformation from the (unrestricted) simple max cut problem. Let a graph G = (V;E) be given. Let G c = (V;E c ) be the complement of G. Let H = (V [ E c ; F), where F = f(v; w) j v; w 2 V; v 6 = wg [f(v; e) j v 2 V; e 2 E c ; v is an endpoint of edge eg. In other words, we take a vertex in H for every vertex in G and every edge in the complement ofG. V forms a clique, E c forms an independent set in H. Every edge- representing vertex is connected to the vertices, representing its endpoints. We can show that G allows a partition with at least K cut edges, if and only if H allows a partition with at least 2  jE c j + K cut edges. 2 Double interval graphs are the intersection graphs of sets A1 ; : : :;An such that for all i, 1  i  n, Ai is the union of two closed intervals of the real line. These graphs are introduced by Harary and Trotter in [17]. Lemma 2.4 Each 2-split graph is a double interval graph. Hence, as consequence we get: Corollary 2.5 Simple max cut is NP-complete for double interval graphs. 5.2.2 Graphs, related to bipartite graphs Bipartite graphs are graphs G = (V;E) in which the vertex set can be partitioned into two sets V1 and V2 such that no edge joins two vertices in the same set. Simple MAXCUT is trivial for bipartite graphs. Thus, it is interesting to look at related graph classes. We consider the tripartite graphs, and the graphs that are the complement of a bipartite graph. The latter graphs we call the co-bipartite graphs. A generalization of bipartite graphs are the tripartite graphs G = (V;E). A graph is tripartite, if and only if the vertex set can be partitioned into three independent sets V1 ; V2 and V3. In other words, a graph is tripartite if its chromatic number is at most three. Theorem 2.6 Simple max cut is NP-complete for tripartite graphs. Proof: By transformation from simple max cut for split graphs to tripartite graphs. Let G = (V;E) be a split graph, where the vertex set is partitioned into a clique C and an independent set U, and de ne a graph G = (V ;E). For each pair ci ; cj 2 C with i 6 = j de ne a graph Gfi;jg with vertex set Vfi;jg = fci ; cj ; ; wfi;jg ; xfi;jg ; yfi;jg ; zfi;jgg Efi;jg = f(xfi;jg ; ci); (zfi;jg ; ci); (yfi;jg ; ci ); (zfi;jg ; cj ); (yfi;jg ; cj ); (wfi;jg ; cj ); (xfi;jg ; yfi;jg); (zfi;jg ; yfi;jg); (zfi;jg ; wfi;jg)g and replace the edge (ci ; cj ) by the graph Gfi;jg. Then, V is the union of vertex sets Vfi;jg and the independent set U. The edge set E is given as union of the edge sets Efi;jg and the set fe = fc; ug 2Ejc 2 C; u 2 Ug. The resulting graph is tripartite and we can show that G allows a partition with at least k cut edges if and only if G allows a partition with at least k + 3jCj(jCj 2 Theorem 2.7 Simple max cut is NP-complete for co-bipartite graphs. Proof: We use a transformation from the simple max cut problem, restricted to split graphs. Suppose G = (C [ U; E) is a split graph, U forms an independent set, and C forms a clique in G. Take a set U 0 , disjoint from C [U, with jU 0 j = jUj. Let H = (C [U [U 0 ;E[ f(v; w) j v 6 = w; v; w 2 U [ U 0 g). In other words, H is obtained from G by adding the vertices in U 0 , and putting a clique on U [ U 0 . Clearly, H is a co-bipartite graph. We can show that G has a partition with at least K cut edges, if and only if H has a partition with at least jUj 2 + K cut edges. 2 6.3 Composition of graphs In this section we show that simple max cut can be solved eciently on a class of graphs that includes the graphs with bounded treewidth and the cographs. Independently, Wanke [18] has found a polynomial time algorithm for a class of graphs that includes the cographs. We rst show the ideas of the method on cographs and on graphs with bounded treewidth. 3.1 Cographs De nition 3.1 Let G1 = (V1 ;E1), G2 = (V2 ;E2) be two graphs, with V1 and V2 disjoint sets. The disjoint union of G1 and G2 is the graph G1 [ G2 = (V1 [ V2 ;E1 [ E2). The product of G1 and G2 is the graph G1 G2 = (V1 [V2 ;E1 [E2 [f(v; w) j v 2 V1 ; w 2 V2g). De nition 3.2 The class of cographs is the smallest set of graphs, ful lling the following rules: 1. Every graph G = (V;E) with one vertex and no edges (jV j = 1 and jEj = 0) is a cograph. 2. If G1 = (V1 ;E1) is a cograph, G2 = (V2 ;E2) is a cograph, and V1 and V2 are disjoint sets, then G1 [ G2 is a cograph. 3. If G1 = (V1 ;E1) is a cograph, G2 = (V2 ;E2) is a cograph, and V1 and V2 are disjoint sets, then G1  G2 is a cograph. Alternatively, a graph is a cograph, if it does not contain a path with four vertices P4 as an induced subgraph. Many NP-complete problems are polynomial time solvable on cographs; there are only a few notable expections, e.g. achromatic number [2] and list coloring [11] are NP-complete for cographs. To each cograph G one can associate a corresponding rooted binary tree T, called the cotree of G, in the following way. Each non-leaf node in the tree is labeled with either \[" (union-nodes) or \" (product-nodes). Each non-leaf node has exactly two children. Each node of the cotree corresponds to a cograph. We remark that the most usual de nition of cotrees allows for arbitrary degree of internal nodes. However, it is easy to see that this has the same power, and can easily be transformed in cotrees with two children per internal node. In [7], it is shown that one can decide in O(n + e) time, whether a graph is a cograph, and build a corresponding cotree. Our algorithm has the following structure: rst nd a cotree for the input graph G, which is a cograph. Then for each node of the cotree, we compute a table, called maxcH, where H is the cograph corresponding to the node. These tables are computed `bottom- up' in the cotree: rst all tables of leaf-nodes are computed, and in general a table of an internal node is computed after the tables of its two children are computed. Let H = (V 0 ;E 0 ) be a cograph. The table maxcH has entries for all integers i, 0  i  jV 0 j, that denote the maximum size of a cut of H into a set of size i and a set of size jV 0 j i, in other words: maxcH(i) = maxfjf(v; w) j v 2 W1 ; w 2 W2gj j W1 [ W2 = V 0 ; W1 \ W2 = ;; jW1j = ig 7.Clearly, the size of the maximum cut of G is max0ijV j maxcG(i), hence, when we have the table maxcG, i.e., the table of the root node of the cotree, then we know the size of the maximum cut. The tables can be computed eciently, starting with the tables at the leaves, and computing tables in an order such that when we compute the table a node, then the tables of its children have already been computed. eciently The tables associated with leaf nodes are clearly all of the form: maxcH(0) = 0, maxcH(1) = 0. The following lemma shows how a table maxcG1 [G2 or a table maxcG1 G2 can be computed, after the tables maxcG1 and maxcG2 are computed. A more general result will be shown in section 5.3. Lemma 3.3 Let G1 = (V1 ;E1) and G2 = (V2 ;E2) be graphs, with V1 and V2 disjoint sets. Then: (i) maxcG1 [G2 (i) = maxfmaxcG1 (j) +maxcG2 (i j) j 0  j  i; j  jV1j; i j  jV2jg: (ii) maxcG1 G2 (i) = maxfmaxcG1 (j)+maxcG2 (ij)+j(jV2j(ij))+(jV1 jj)(ij) j 0  j  i; j  jV1j; i j  jV2jg: It directly follows that one can compute the table maxcG1 [G2 and maxcG1 G2 in O(jV1j jV2j) time. By standard arguments, the following result now can be derived: Theorem 3.4 There exists an O(n 2 ) algorithm for simple max cut on cographs. It is easy to modify this algorithm such that it also yields a partition with the maximum number of cut edges, and uses also O(n 2 ) time. 3.2 Graphs with bounded treewidth It is well know that the simple max cut problem can be solved in linear time on graphs with bounded treewidth (see e.g. [19]). We sketch the method here, as it will be generalized hereafter. The notion of treewidth of a graph was introduced by Robertson and Seymour [16], and is equivalent to several other interesting graph theoretic notions, for instance the notion of partial k-trees (see e.g., [1, 4]). De nition 3.5 A tree-decomposition of a graph G = (V;E) is a pair (fXi j i 2 Ig; T = (I;F)), where fXi j i 2 Ig is a collection of subsets of V , and T = (I;F) is a tree, such that the following conditions hold: 1. S i2I Xi = V . 2. For all edges (v; w) 2 E, there exists a node i 2 I, with v; w 2 Xi. 3. For every vertex v 2 V , the subgraph of T, induced bythe nodes fi 2 I j v 2 Xig is connected. The treewidth of a tree-decomposition (fXi j i 2 Ig; T = (I;F)) is maxi2I jXij 1. The treewidth of a graph is the minimum treewidth over all possible tree-decompositions of the graph. 8.It is not dicult to make small modi cations to a tree-decomposition, without in- creasing its treewidth, such that one can see T as a rooted tree, with root r 2 I, and the following conditions hold: 1. T is a binary tree. 2. If a nodei 2 I has two children j1 and j2, then Xi = Xj1 = Xj2 . 3. If a node i 2 I has one child j, then either Xj ˆ Xi and jXi Xj j = 1,orXi ˆ Xj and jXj Xij = 1. We will assume in the remainder that a tree-decomposition of G of this type is given, with treewidth at most k, for some constant k. Note that a tree-decomposition of G with treewidth  k can be found, if it exists, in O(n) time [3]. For every node i 2 I, let Yi denote the set of all vertices in a set Xj with j = i or j is a descendant ofi in the rooted tree T. Our algorithm is based upon computing for every node i 2 I a table maxci. For every subset S of Xi, there is an entry in the table maxci, ful lling maxci(S) = max S 0 Yi; S 0 \Xi=S jf(v; w) 2 E j v 2 S 0 ; w 2 Yi S 0 gj. In other words, for S  Xi, maxci(S) denotes the maximum number of cut edges for a partition of Yi, such that all vertices in S are in one set in the partition, and all vertices in Xi S are in the other set in the partition. The tables are again computed in a bottom-up manner: start with computing the tables for the leaves, then always compute the table for an internal node later than the tables of its child or children are computed. The following lemma, which is easy to proof, shows how the tables can be computed eciently: Lemma 3.6 (i) Let i be a leaf in T. Then for all S  Xi, maxci(S) =jf(v; w) 2 E j v 2 S; w 2 Xi j. (ii) Let i be a node with one child j in T. Suppose Xi  Xj . Then for all S  Xi, maxci(S) = maxS 0 Xj ; S 0 \Xi=S maxcj (S 0 ). (iii) Let i be a node with one child j in T. Suppose Xj [ fvg = Xi, v 62 Xj . For all S  Xi, ifv 2 S, then maxci(S) =maxcj (S fvg)+jf(s; v) j v 2 Xi Sgj, and if v 62 S, then maxci(S) =maxcj (S) +jf(s; v) j v 2 Sgj. (iv) Let i be a node with two children j1, j2 in T, with Xi = Xj1 = Xj2 . For all S  Xi, maxci(S) =maxcj1 (S) +maxcj2 (S) f(v; w) 2 E j v 2 S; w 2 Xi j. It follows that computing a table maxci can be done in O(1) time. So, in O(n) time, one can compute the table of the root r. The size of the maximum cut is maxSXr maxcr(S). Theorem 3.7 Simple max cut can be solved in O(n) time on graphs, given with a tree-decomposition of constant bounded treewidth. Again, it is possible to modify the algorithm, such that it also yields a partition with the maximum number of cut edges. 9.3.3 Composition of graphs We now generalize and combine the previous results in this section. De nition 3.8 Let H0 = (V0 ;E0) be a graph with r vertices; V0 = fv1 ; v2 ;   ; vrg. Let H1 = (V1 ;E1), H2 = (V2 ;E2), : : :, Hr = (Vr ;Er) be r disjoint graphs. The factor graph H0[H1 ;H2 ;   ;Hr] is the graph, obtained by taking the disjoint union of H1, H2, : : :, Hr, and adding all edges between pairs of vertices v, w, with v 2 Vi, w 2 Vj , and (i; j) 2 E0: H0[H1 ;H2 ;   ;Hr] = ( S1ir Vi ; S1ir Ei [ f(v; w) j 9i; j : 1  i; j  r; v 2 Vi ; w 2 Vj ; (i; j) 2 E0g). It often is useful to try to write a graph G = (V;E) as a factor graph G = H0[H1 ; H2 ;   ; Hr], for some suitable choice of H0 ; : : :;Hr. Such a `factorization', where H0 is as small as possible, r  2, can be found in polynomial time [14]. (Clearly, a trivial factorization, where G = H0 and all graphs H1 ;   ;Hn consist of one vertex always exists, but is not really useful.) Then, it is often useful to factorize the graphs H1, H2, : : :, Hr again, and then possibly factorize the formed parts of these graphs again, etc. In this way, one can associate with a graph a factor tree. A factor tree is a rooted tree, where every non-leaf node is labeled with a graph. We call this graph a label graph. The number of vertices in a label graph equals the number of children of the node to which the graph is labeled; these vertices are always numbered 1,2,: : :To each node of the factor tree, one can associate then a graph, called the factor graph, in the following way. To a leaf node, associate a graph with one vertex and no edges. To a non-leaf node, with label graph H0 = (f1; 2;   ; rg;E0), associate the graph H0[H1 ;   ;Hr], where for all i, 1  i  r, Hi is the factor graph associated to the i'th child of the node. The factor graph associated to the root of the tree is the graph, represented by this factor tree. The notion of factor tree generalizes the notion of cotree: in a cotree the only label graphs are K2 (a graph with two vertices and one edge | the label of product nodes), and K c 2 (a graph with two vertices and no edges | the label of union nodes). The following result generalizes the results of the previous two sections. Theorem 3.9 For all constants k, the simple max cut problem is solvable in polynomial time for graphs, with a factor tree, where every label graph has treewidth at most k. The rst step of the algorithm is to nd the factor tree. By using the results from [14], it follows that the factor tree can be found in polynomial time, such that the size and also the treewidth of label graphs are minimal. Also, a tree-decomposition of treewidth at most k of the type as described in the previous section is computed for every label graph. For each factor graph H = (V 0 ;E 0 ), associated with a node of the factor tree, we compute | just as we did for cographs | a table maxcH, which has entries for all integers i, 0  i  jV 0 j, that denote the maximum size of a cut of H into a set of size i and a set of size jV 0 j i, in other words: maxcH(i) = maxfjf(v; w) j v 2 W1 ; w 2 W2gj j W1 [ W2 = V 0 ; W1 \ W2 = ;; jW1j = ig 10.These tables are easily computed for factor graphs, associated with leaves. Again, the tables are computed bottom up in the factor tree. Suppose we want to compute the table for a factor graph H = H0[H1;   ;Hr], (H0 = (f1; 2;   ; rg;E0) is the label graph of some non-leaf node of the factor tree, and H1 = (V1;E1), : : :, Hr = (Vr;Er) are the factor graphs, associated with the children of that node.) We have already computed all tables maxcH1, : : :, maxcHr. As in the previous section, for every node 2 I, let Y denote the set of all vertices in a set X with = or is a descendant of in the rooted tree T. For 2 I, let H = (Z ; F ) denote the graph, obtained by removing all vertices from H, that are not in a graph Hi, with i 2 Y , or in other words, H is the subgraph of H, induced by all vertices in Z = S i2Y Vi. In order to compute the table maxcH, we compute now for every node 2 I of the tree-decomposition (fH j 2 Ig; T = (I;F)) of label graph H0 a table maxc 0 , which has an entry for every function f : X ! f0; 1; 2; : : :g, such that f(i)  jVij, where for all such functions f: maxc 0 (f; s) denotes the maximum cut size of a partition of Z into two disjoint sets W1, W2, such that for all i 2 X , jW1 \ Vij = f(i), and jW1j = s. In other words, we look for the maximum cut of H , such that f describes for all graphs Hi with i an element of the set X , how many vertices of Hi are in the set W1. We compute the tables maxc 0 bottom up, in the tree-decomposition. The next lemma shows how this can be done. The proof of this result is given in the full paper. Note that we are working with two types of trees: we have one factor tree, and with every node of this factor tree, we have associated a tree-decomposition. Lemma 3.10 (i) Let be a leaf in T. Then for all f : X ! f0; 1; 2; : : :g, with for all i 2 X : f(i)  jVij, s = P i2X f(i): maxc 0 (f; s) = X i2X maxcHi(f(i)) + X (i;j)2E0; i;j2X (f(i)  (jVjj f(j)) + f(j)  (jVij f(i))) For all other values of s, maxc 0 (f; s) = (ii) Let be a node with one child in T. Suppose X  X . Then for all s  0, f : X ! f0; 1; 2; : : :g with for all i 2 X : f(i)  jVij: maxc 0 (f; s) = maxfmaxc 0 (f 0 ; s) j 8i 2 X : f(i) =f 0 (i) ^ 8i 2 X : f 0 (i)  jVijg (iii) Let be a node with one child in T. Suppose X [ fi0g = X , i0 62 X . Then for all s  0, f : X ! f0; 1; 2; : : :g with for all i 2 X : f(i)  jVij: let f 0 be the function f restricted to X . Then maxc 0 (f; s) =maxc 0 (f; sf(i0)) + X (i0;j)2E0;j2X (f(i0)  (jVjj f(j)) 11.(iv) Let be a node with two children 1, 2 in T, with X = X 1 = X 2. Then for all s  0, f : X ! f0; 1; 2; : : :g with for all i 2 X : f(i)  jVij: maxc 0 (f; s) = max s1;s20; s1+s2P i2X f(i)=s maxc 0 1 (f; s1) +maxc 0 2 (f; s2) X (i;j)2E0;i;j2X (f(i)  (jVjj f(j)) + (jVij f(i))  f(j)) From lemma 3.10, it follows directly how all tables maxc 0 can be computed in a bottom up manner, given all tables maxcHi. The time, needed per table is linear in the size of the table, plus the sizes of the tables of its children, hence is polynomial in n (but exponential in k.) When we have the table maxc 0 with the root-node of the tree-decomposition, then we can compute the table maxcH (remember that H = H0[H1;   ;Hr]), using the following lemma. Lemma 3.11 For all r  0; r  jVHj, maxcH(r) = maxfmaxc 0 (f; r) j 8i 2 X : f(i)  jVijg. Proof: Note that H = H . We just take the maximum over all possible numbers of vertices in W1 that are in each of the sets Vi with i 2 X . 2 We now are one level higher in the factor tree. The processes are repeated until the table maxcG is obtained, from which the answer to the simple max cut problem can be determined. As each table computation can be done in polynomial time, and a linear number of tables must be computed, the whole algorithm takes time, polynomial in n, when k is a xed constant. We now have proved theorem 3.9. It is also possible to construct the partition which gives the maximum number of cut edges, without increasing the running time of the algorithm by more than a constant factor. 4 Weighted Max Cut We conclude this paper with some small observations on the weigthed variant of the problem. First, observe that max cut is NP-complete, when restricted to cliques, when only edge weigths 0 and 1 are allowed. (The problem in this form is equivalent to the simple max cut problem.) So, max cut is NP-complete for all classes of graphs that contain all cliques, (e.g., for the class of cographs.) Secondly, as rst shown by Wimer [19], max cut can be solved in linear time on graphs given with a tree-decomposition of bounded treewidth. (It is possible to modify the results of section 3.2 and obtain an algorithm, quite similar to the algorithm of Wimer.) 12.References [1] S. Arnborg, Ecient algorithms for combinatorial problems on graphs with bounded decompos- ability | A survey, BIT 25 (1985), pp. 2 { 23. [2] H.L. Bodlaender, Achromatic Number is NP-complete for cographs and interval graphs. Infor- mation Processing Letters, 31:135{138, 1989. [3] H.L. Bodlaender, A linear time algorithm for nding tree-decompositions of small treewidth. Technical Report RUU-CS-92-27, Department of Computer Science, Utrecht University, Utrecht, the Netherlands, 1992. [4] H.L. Bodlaender, A tourist guide through treewidth. Technical Report RUU-CS-92-12, Depart- ment of Computer Science, Utrecht University, Utrecht, 1992. [5] K. Chang and D. Du, Ecient algorithms for the layer assignment problem, IEEE Trans. CAD 6 (1987), pp. 67 { 78. [6] R. Chen, Y. Kajitani and S. Chan, A graph theoretic via minimization algorithm for two layer printed circuit boards, IEEE Trans. Circuit Syst. (1983), pp. 284 { 299. [7] D.G. Corneil, Y. Perl, and L.K. Stewart, A linear recognition algorithm for cographs, SIAM J. Comput. 4 (1985), pp. 926 { 934. [8] S. F. oldes and P.L. Hammer, Split graphs, Proc. 8th Southeastern Conf. on Combinatorics, Graph Theory and Computing, Louisiana State University, Baton Rouge, Louisiana, pp. 311 { 315. [9] M.R. Garey and D.S. Johnson, Computers and Intractability: A Guide to the Theory of NP- Completness, Freeman, San Francisco, 1979. [10] M.R. Garey, D.S. Johnson and L. Stockmeyer, Some simpli ed NP-complete graph problems, Theo. Comput. Sci 1 (1976), pp. 237 { 267. [11] K. Jansen and P. Scheffler, Some coloring results for tree like graphs, Workshop on Graph Theoretic Concepts in Computer Science, LNCS, 657, 1992, p. 50-59. [12] D.S. Johnson, The NP-completeness column: an ongoing guide, J. Algorith. 6 (1985), pp. 434 { 451. [13] R.M. Karp, Reducibility among combinatorial problems, in: Miller and Thatcher: Complexity of Computer Computations, Plenum Press (1972), pp. 85 { 104. [14] J.H. Muller and J. Spinrad, Incremental modular decomposition, J. ACM, 36 (1989), pp. 1 { 19. [15] R. Pinter, Optimal layer assignment for interconnect, Proc. Int. Symp. Circuit Syst. (ISCAS) (1982), pp. 398 { 401. [16] N. Robertson and P.D. Seymour, Graph minors. II. Algorithmic aspects of tree-width, J. Algo- rithms 7 (1986), pp. 309-322. [17] W.T. Trotter, Jr. and F. Harary, On double and multiple interval graphs, J. Graph Theory 3 (1979), pp. 205 { 211. [18] E. Wanke, k-NLC graphs and polynomial algorithms. Bericht, Reihe Informatik 80, Universit. at Paderborn, 1991. [19] T.V. Wimer, Linear algorithms on k-terminal graphs, PhD thesis, Department of Computer Science, Clemson University, 1987. 13