### min cut and max cut

**• A cut in an undirected graph G = (V, E) is a partition***of the nodes into two nonempty sets S and V − S.*

*• The size of a cut (S, V − S) is the number of edges*
*between S and V − S.*

*• min cut ∈ P by the maxﬂow algorithm.*^{a}

*• max cut asks if there is a cut of size at least K.*

**– K is part of the input.**

### A Cut of Size 4

### min cut and max cut (concluded)

*• max cut has applications in circuit layout.*

**– The minimum area of a VLSI layout of a graph is not**
less than the square of its maximum cut size.^{a}

aRaspaud, S´ykora, and Vrˇto (1995); Mak and Wong (2000).

### max cut Is NP-Complete

^{a}

*• We will reduce naesat to max cut.*

*• Given a 3sat formula φ with m clauses, we shall*
*construct a graph G = (V, E) and a goal K.*

*• Furthermore, there is a cut of size at least K if and only*
*if φ is nae-satisﬁable.*

*• Our graph will have multiple edges between two nodes.*

**– Each such edge contributes one to the cut if its nodes**
are separated.

aKarp (1972); Garey, Johnson, and Stockmeyer (1976).

### The Proof

*• Suppose φ’s m clauses are C*_{1}*, C*_{2}*, . . . , C**m*.

*• The boolean variables are x*_{1}*, x*_{2}*, . . . , x**n*.

*• G has 2n nodes: x*_{1}*, x*_{2}*, . . . , x*_{n}*, ¬x*_{1}*, ¬x*_{2}*, . . . , ¬x** _{n}*.

*• Each clause with 3 distinct literals makes a triangle in G.*

*• For each clause with two identical literals, there are two*
parallel edges between the two distinct literals.

### The Proof (continued)

*• No need to consider clauses with one literal (why?).*

*• No need to consider clauses containing two opposite*
*literals x** _{i}* and

*¬x*

*(why?).*

_{i}*• For each variable x*_{i}*, add n*_{i}*copies of edge [x*_{i}*, ¬x** _{i}*],

*where n*_{i}*is the number of occurrences of x** _{i}* and

*¬x*

_{i}*in φ.*

*• Note that*

*n*
*i=1*

*n*_{i}*= 3m.*

**– The summation is simply the total number of literals.**

## » [

_{M}

## [

_{L}

## [

_{L}

## » [

_{L}

## Q FRSLHV [

_{L}

## [

_{M}

## » [

_{N}

### The Proof (continued)

*• Set K = 5m.*

*• Suppose there is a cut (S, V − S) of size 5m or more.*

*• A clause (a triangle or two parallel edges) contributes at*
most 2 to a cut no matter how you split it.

*• Suppose some x**i* and *¬x**i* are on the same side of the
cut.

*• They together contribute (at most) 2n**i* edges to the cut.

**– They appear in (at most) n*** _{i}* diﬀerent clauses.

**– A clause contributes at most 2 to a cut.**

» [_{L}
[_{L}

Q_{L}ØWULDQJOHVÙ
3 L

### The Proof (continued)

*• Either x** _{i}* or

*¬x*

_{i}*contributes at most n*

*to the cut by the pigeonhole principle.*

_{i}*• Changing the side of that literal does not decrease the*
size of the cut.

*• Hence we assume variables are separated from their*
negations.

*• The total number of edges in the cut that join opposite*
*literals x** _{i}* and

*¬x*

*is*

_{i}

_{n}*i=1* *n** _{i}*.

*• But* _{n}

*i=1* *n**i* *= 3m.*

### The Proof (concluded)

*• The remaining K − 3m ≥ 2m edges in the cut must*
*come from the m triangles or parallel edges that*
correspond to the clauses.

*• Each can contribute at most 2 to the cut.*^{a}

*• So all are split.*

*• A split clause means at least one of its literals is true*
and at least one false.

*• The other direction is left as an exercise.*

### This Cut Does Not Meet the Goal *K = 5 × 3 = 15*

» [_{}

» [_{}

» [_{}
[_{}

[_{}

[_{}

*• (x*_{1} *∨ x*_{2} *∨ x*_{2}) *∧ (x*_{1} *∨ ¬x*_{3} *∨ ¬x*_{3}) *∧ (¬x*_{1} *∨ ¬x*_{2} *∨ x*_{3}).

*• The cut size is 13 < 15.*

### This Cut Meets the Goal *K = 5 × 3 = 15*

» [_{}

» [_{}

» [_{}
[_{}

[_{}

[_{}
WUXH

IDOVH

### Remarks

*• We had proved that max cut is NP-complete for*
multigraphs.

*• How about proving the same thing for simple graphs?*^{a}

*• How to modify the proof to reduce 4sat to max cut?*^{b}

*• All NP-complete problems are mutually reducible by*
deﬁnition.^{c}

**– So they are equally hard in this sense.**^{d}

aContributed by Mr. Tai-Dai Chou (J93922005) on June 2, 2005.

bContributed by Mr. Chien-Lin Chen (J94922015) on June 8, 2006.

cContributed by Mr. Ren-Shuo Liu (D98922016) on October 27, 2009.

dContributed by Mr. Ren-Shuo Liu (D98922016) on October 27, 2009.

### max bisection

*• max cut becomes max bisection if we require that*

*| S | = | V − S |.*

*• It has many applications, especially in VLSI layout.*

### max bisection Is NP-Complete

*• We shall reduce the more general max cut to max*
bisection.

**• Add |V | = n isolated nodes to G to yield G*** ^{}*.

*• G*^{}*has 2n nodes.*

*• G*^{}*’s goal K is identical to G’s*

**– As the new nodes have no edges, they contribute 0 to**
the cut.

*• This completes the reduction.*

### The Proof (concluded)

*• Every cut (S, V − S) of G = (V, E) can be made into a*
bisection by appropriately allocating the new nodes
*between S and V − S.*

*• Hence each cut of G can be made a cut of G** ^{}* of the
same size, and vice versa.

### bisection width

*• bisection width is like max bisection except that it*
*asks if there is a bisection of size at most K (sort of min*
bisection).

*• Unlike min cut, bisection width is NP-complete.*

*• We reduce max bisection to bisection width.*

*• Given a graph G = (V, E), where | V | is even, we*
*generate the complement of G.*

*• Given a goal of K, we generate a goal of n*^{2} *− K.*^{a}

a*| V | = 2n.*

### The Proof (concluded)

*• To show the reduction works, simply notice the following*
easily veriﬁable claims.

**– A graph G = (V, E), where |V | = 2n, has a bisection***of size K if and only if the complement*^{a} *of G has a*
*bisection of size n*^{2} *− K.*

* – So G has a bisection of size ≥ K if and only if its*
complement has a bisection of size

*≤ n*

^{2}

*− K.*

aRecall p. 374.

### hamiltonian path Is NP-Complete

^{a}

**Theorem 45 Given an undirected graph, the question***whether it has a Hamiltonian path is NP-complete.*

aKarp (1972).

### A Hamiltonian Path at IKEA, Covina, California?

### tsp (d) Is NP-Complete

**Corollary 46 tsp (d) is NP-complete.**

*• Consider a graph G with n nodes.*

*• Create a weighted complete graph G** ^{}* with the same

*nodes as G.*

*• Set d*_{ij}*= 1 on G*^{}*if [ i, j ] ∈ G and d*_{ij}*= 2 on G** ^{}* if

*[ i, j ] ∈ G.*

**– Note that G*** ^{}* is a complete graph.

*• Set the budget B = n + 1.*

*• This completes the reduction.*

### tsp (d) Is NP-Complete (continued)

*• Suppose G*^{}*has a tour of distance at most n + 1.*^{a}

*• Then that tour on G** ^{}* must contain at most one edge
with weight 2.

*• If a tour on G** ^{}* contains one edge with weight 2, remove

*that edge to arrive at a Hamiltonian path for G.*

*• Suppose a tour on G** ^{}* contains no edge with weight 2.

*• Remove any edge to arrive at a Hamiltonian path for G.*

### tsp (d) Is NP-Complete (concluded)

*• On the other hand, suppose G has a Hamiltonian path.*

*• There is a tour on G** ^{}* containing at most one edge with
weight 2.

**– Start with a Hamiltonian path and then close the**
loop.

*• The total cost is then at most (n − 1) + 2 = n + 1 = B.*

*• We conclude that there is a tour of length B or less on*
*G*^{}*if and only if G has a Hamiltonian path.*

### Random tsp

*• Suppose each distance d** _{ij}* is picked uniformly and

*independently from the interval [ 0, 1 ].*

*• It is known that the total distance of the shortest tour*
*has a mean value of β√*

*n for some positive β.*

*• In fact, the total distance of the shortest tour deviates*
*from the mean by more than t with probability at most*
*e*^{−t}^{2}* ^{/(4n)}*!

^{a}

aDubhashi and Panconesi (2012).

### Graph Coloring

*• k-coloring: Can the nodes of a graph be colored with*

*≤ k colors such that no two adjacent nodes have the*
same color?^{a}

*• 2-coloring is in P (why?).*

*• But 3-coloring is NP-complete (see next page).*

*• k-coloring is NP-complete for k ≥ 3 (why?).*

*• exact-k-coloring asks if the nodes of a graph can be*
*colored using exactly k colors.*

*• It remains NP-complete for k ≥ 3 (why?).*

### 3-coloring Is NP-Complete

^{a}

*• We will reduce naesat to 3-coloring.*

*• We are given a set of clauses C*_{1}*, C*_{2}*, . . . , C**m* each with 3
literals.

*• The boolean variables are x*_{1}*, x*_{2}*, . . . , x**n*.

*• We shall construct a graph G that can be colored with*
colors *{ 0, 1, 2 } if and only if all the clauses can be*

nae-satisﬁed.

aKarp (1972).

### The Proof (continued)

*• Every variable x**i* *is involved in a triangle [ a, x**i**, ¬x**i* ]
*with a common node a.*

*• Each clause C**i* *= (c**i1* *∨ c**i2* *∨ c**i3*) is also represented by a
triangle

*[ c*_{i1}*, c*_{i2}*, c*_{i3}*].*

**– Node c**_{ij}*and a node in an a-triangle [ a, x*_{k}*, ¬x** _{k}* ]

*with the same label represent distinct nodes.*

*• There is an edge between c** _{ij}* and the node that

*represents the jth literal of C*

*.*

_{i}^{a}

*¬c*

### Construction for *· · · ∧ (x*

^{1}

*∨ ¬x*

^{2}

*∨ ¬x*

^{3}

*) ∧ · · ·*

### [

_{}

### [

_{}

### [

_{}

### [

_{}

### c [

_{}

### c [

_{}

### D

### The Proof (continued)

Suppose the graph is 3-colorable.

*• Assume without loss of generality that node a takes the*
color 2.

*• A triangle must use up all 3 colors.*

*• As a result, one of x** _{i}* and

*¬x*

*must take the color 0 and the other 1.*

_{i}### The Proof (continued)

*• Treat 1 as true and 0 as false.*^{a}

* – We are dealing with the a-triangles here, not the*
clause triangles yet.

*• The resulting truth assignment is clearly contradiction*
free.

*• As each clause triangle contains one color 1 and one*
color 0, the clauses are nae-satisﬁed.

aThe opposite also works.

### The Proof (continued)

Suppose the clauses are nae-satisﬁable.

*• Color node a with color 2.*

*• Color the nodes representing literals by their truth*
values (color 0 for false and color 1 for true).

* – We are dealing with the a-triangles here, not the*
clause triangles.

### The Proof (continued)

*• For each clause triangle:*

**– Pick any two literals with opposite truth values.**^{a}
**– Color the corresponding nodes with 0 if the literal is**

true and 1 if it is false.

**– Color the remaining node with color 2.**

aBreak ties arbitrarily.

### The Proof (concluded)

*• The coloring is legitimate.*

* – If literal w of a clause triangle has color 2, then its*
color will never be an issue.

**– If literal w of a clause triangle has color 1, then it***must be connected up to literal w with color 0.*

**– If literal w of a clause triangle has color 0, then it***must be connected up to literal w with color 1.*

### Algorithms for 3-coloring and the Chromatic Number *χ(G)*

*• Assume G is 3-colorable.*

*• There is a classic algorithm that ﬁnds a 3-coloring in*
*time O(3*^{n/3}*) = 1.4422** ^{n}*.

^{a}

*• It can be improved to O(1.3289** ^{n}*).

^{b}

aLawler (1976).

bBeigel and Eppstein (2000).

### Algorithms for 3-coloring and the Chromatic Number *χ(G) (concluded)*

**• The chromatic number χ(G) is the smallest number***of colors needed to color a graph G.*

*• There is an algorithm to ﬁnd χ(G) in time*
*O((4/3)*^{n/3}*) = 2.4422** ^{n}*.

^{a}

*• It can be improved to O((4/3 + 3*^{4/3}*/4)*^{n}*) = O(2.4150** ^{n}*)

^{b}and 2

^{n}*n*

*.*

^{O(1)}^{c}

*• Computing χ(G) cannot be easier than 3-coloring.*^{d}

aLawler (1976).

### tripartite matching

*• We are given three sets B, G, and H, each containing n*
elements.

*• Let T ⊆ B × G × H be a ternary relation.*

*• tripartite matching asks if there is a set of n triples*
*in T , none of which has a component in common.*

**– Each element in B is matched to a diﬀerent element***in G and diﬀerent element in H.*

**Theorem 47 (Karp (1972)) tripartite matching is***NP-complete.*

### Related Problems

*• We are given a family F = {S*_{1}*, S*_{2}*, . . . , S**n**} of subsets of*
*a ﬁnite set U and a budget B.*

*• set covering asks if there exists a set of B sets in F*
*whose union is U .*

*• set packing asks if there are B disjoint sets in F .*

*• Assume |U| = 3m for some m ∈ N and |S*_{i}*| = 3 for all i.*

*• exact cover by 3-sets asks if there are m sets in F*

SET COVERING SET PACKING

### Related Problems (concluded)

* Corollary 48 (Karp (1972)) set covering, set*
packing

*, and exact cover by 3-sets are all*

*NP-complete.*

*• set covering is used to prove that the inﬂuence*
maximization problem in social networks is

NP-complete.^{a}

aKempe, Kleinberg, and Tardos (2003).

### knapsack

*• There is a set of n items.*

*• Item i has value v**i* *∈ Z*^{+} *and weight w*_{i}*∈ Z*^{+}.

*• We are given K ∈ Z*^{+} *and W ∈ Z*^{+}.

*• knapsack asks if there exists a subset*
*I ⊆ {1, 2, . . . , n}*

such that

*i∈I* *w*_{i}*≤ W and*

*i∈I* *v*_{i}*≥ K.*

**– We want to achieve the maximum satisfaction within**
the budget.

### knapsack Is NP-Complete

^{a}

*• knapsack ∈ NP: Guess an I and check the constraints.*

*• We shall reduce exact cover by 3-sets to knapsack,*
*in which v**i* *= w**i* *for all i and K = W .*

*• The simpliﬁed knapsack now asks if a subset of*
*v*_{1}*, v*_{2}*, . . . , v*_{n}*adds up to exactly K.*^{b}

**– Picture yourself as a radio DJ.**

aKarp (1972).

bThis problem is called subset sum.

### The Proof (continued)

*• The primary diﬀerences between the two problems are:*^{a}
**– Sets vs. numbers.**

**– Union vs. addition.**

*• We are given a family F = {S*_{1}*, S*_{2}*, . . . , S*_{n}*} of size-3*
*subsets of U = {1, 2, . . . , 3m}.*

*• exact cover by 3-sets asks if there are m disjoint*
*sets in F that cover the set U .*

aThanks to a lively class discussion on November 16, 2010.

### The Proof (continued)

*• Think of a set as a bit vector in {0, 1}** ^{3m}*.

**– Assume m = 3.****– 110010000 means the set {1, 2, 5}.**

**– 001100010 means the set {3, 4, 8}.**

*• Assume there are n = 5 size-3 subsets in F .*

*• Our goal is*

*3m*

*1 1 · · · 1 .*

### The Proof (continued)

*• A bit vector can also be seen as a binary number.*

*• Set union resembles addition:*

001100010 + 110010000 111110010

which denotes the set *{1, 2, 3, 4, 5, 8}, as desired.*

### The Proof (continued)

*• Trouble occurs when there is carry:*

010000000 + 010000000 100000000

which denotes the wrong set *{1}, not the correct {2}.*

### The Proof (continued)

*• Or consider*

001100010 + 001110000 011010010

which denotes the set *{2, 3, 5, 8}, not the correct*
*{3, 4, 5, 8}.*^{a}

aCorrected by Mr. Chihwei Lin (D97922003) on January 21, 2010.

### The Proof (continued)

*• Carry may also lead to a situation where we obtain our*
solution *1 1 · · · 1 with more than m sets in F .*

*• For example,*

000100010 001110000 101100000 + 000001101 111111111

### The Proof (continued)

*• And it uses 4 sets instead of the required m = 3.*^{a}

*• To ﬁx this problem, we enlarge the base just enough so*
that there are no carries.^{b}

*• Because there are n vectors in total, we change the base*
*from 2 to n + 1.*

aThanks to a lively class discussion on November 20, 2002.

bYou cannot map *∪ to ∨ because knapsack requires + not ∨!*

### The Proof (continued)

*• Set v** _{i}* to be the integer corresponding to the bit vector

*encoding S*

_{i}*in base n + 1:*

*v**i* =

*j∈S**i*

1 *× (n + 1)** ^{3m−j}* (3)

*• Set*

*K =*

*3m−1*

*j=0*

1 *× (n + 1)** ^{j}* =

*3m*

1 1 *· · · 1 (base n + 1).*

*• Now in base n + 1, if there is a set S such that*

^{3m}

### The Proof (continued)

*• For example, the case on p. 423 becomes*
000100010

001110000
101100000
+ 000001101
102311111
*in base n + 1 = 6.*

*• As desired, it no longer meets the goal.*

### The Proof (continued)

*• Suppose F admits an exact cover, say {S*_{1}*, S*_{2}*, . . . , S*_{m}*}.*

*• Then picking I = {1, 2, . . . , m} clearly results in*

*v*_{1} *+ v*_{2} + *· · · + v**m* =

*3m*

1 1*· · · 1 .*

*• It is important to note that the meaning of addition (+)*
is independent of the base.^{a}

**– It is just regular addition.**

**– But an S***i* *may give rise to diﬀerent integers v**i* in Eq.

(3) on p. 425 under diﬀerent bases.

### The Proof (concluded)

*• On the other hand, suppose there exists an I such that*

*i∈I*

*v** _{i}* =

*3m*

1 1 *· · · 1*
*in base n + 1.*

*• The no-carry property implies that | I | = m and*
*{S**i* *: i ∈ I}*

is an exact cover.

### An Example

*• Let m = 3, U = {1, 2, 3, 4, 5, 6, 7, 8, 9}, and*
*S*_{1} = *{1, 3, 4},*

*S*_{2} = *{2, 3, 4},*
*S*_{3} = *{2, 5, 6},*
*S*_{4} = *{6, 7, 8},*
*S*_{5} = *{7, 8, 9}.*

*• Note that n = 5, as there are 5 S** _{i}*’s.

### An Example (continued)

*• Our reduction produces*

*K* =

*3×3−1*

*j=0*

6* ^{j}* =

*3×3*

1 1*· · · 1*_{6} = 2015539_{10}*,*
*v*_{1} = *101100000 = 1734048,*

*v*_{2} = *011100000 = 334368,*
*v*_{3} = *010011000 = 281448,*
*v*_{4} = *000001110 = 258,*
*v*_{5} = *000000111 = 43.*

### An Example (concluded)

*• Note v*_{1} *+ v*_{3} *+ v*_{5} *= K because*

101100000 010011000 + 000000111 111111111

*• Indeed,*

*S*_{1} *∪ S*_{3} *∪ S*_{5} = *{1, 2, 3, 4, 5, 6, 7, 8, 9},*

### bin packing

*• We are given N positive integers a*_{1}*, a*_{2}*, . . . , a**N*, an

*integer C (the capacity), and an integer B (the number*
of bins).

*• bin packing asks if these numbers can be partitioned*
*into B subsets, each of which has total sum at most C.*

*• Think of packing bags at the check-out counter.*

**Theorem 49 bin packing is NP-complete.**

### bin packing (concluded)

*• But suppose a*_{1}*, a*_{2}*, . . . , a** _{N}* are randomly distributed
between 0 and 1.

*• Let B be the smallest number of unit-capacity bins*
capable of holding them.

*• Then B can deviate from its average by more than t*
*with probability at most 2e*^{−2t}^{2}* ^{/N}*.

^{a}

aDubhashi and Panconesi (2012).