Assignment #6, CS4/531
Assignment #6, CS4/531
Solution
Due Date: Sat Dec. 12, 2020
Total points: 44
• You MUST turn in your HW by 11:59pm on Dec 12. After that, I will NOT accept your
HW. This rule will be STRICTLY ENFORCED.
1. (0 points) Describe if the following statement is true or false. If it is true, give a short
explanation. If it’s false, give a counter example.
Let G be a (basic) flow-network with source s and sink t. Each directed edge e of G
has a positive integer capacity c(e). If f is a max-flow of G, then f saturates every
edge out of s. (Namely, for every edge e = s → v, f (e) = c(e).)
1/2 1/1
s t
2. (4 points) Describe if the following statement is true or false. If it is true, give a short
explanation. If it’s false, give a counter example.
Let G be a (basic) flow-network with source s and sink t. Each directed edge e of G
has a positive integer capacity c(e). Let (S, T ) be a minimum capacity st-cut with
respect to the capacity function c(∗). Now suppose that we add 1 to the capacity of
every edge e. Namely, we define a new capacity function c0 (e) = c(e) + 1 for every
edge e in G. Then (S, T ) is still a minimum capacity st-cut of G with respect to the
new capacity function c0 (∗).
False. The following Fig shows a counter example. In this Figure, the integer next to each edge
is the capacity of the edge. The min-cut of G is: S = {s, a} and T = {b, c, d, t}. The capacity
of the cut is c(S, T ) = 3.
After the capacity of each edge is increased by one, the new min-cut is: S 0 = {s} and
T = {a, b, c, d, t} with capacity c0 (S 0 , T 0 ) = 5.
0
1
b
1
1
4 1 c 1 t
s a
1 1
d
Figure 2: A Counter example for Problem 2.
V 0 = {x0 , x1 , . . . , xn } ∪ {y0 , y1 , . . . , yn }
x0 → xi1 → yi2 → y0
x0 → xi2 → yi3 → y0
..
.
x0 → xik−1 → yik → y0
Continue this until all paths in C are processed. All other edges of G0 have flow value 0. This
completes the construction of flow function f .
Note that under this construction, the vertices in {x1 , . . . , xn } without incoming flow corre-
spond to the ending vertices of paths in the path cover C. So the number of path cover equals
to n − (the value of flow f ). Thus in order to find a minimum path cover C of G, we can first
find a maximum flow f of G0 , then construct a path cover C corresponding to f as described
above. C would be a minimum path cover of G.
2
4. (2+3+2+3=10 points). The Graph Edge Coloring (GEC) problem is defined as follows.
The input is an undirected graph G = (V, E) with n vertices and m edges. An edge coloring
of G is an assignment of colors to the edges of G so that for any two edges e1 , e2 , if e1 and e2
share a common end vertex, then e1 and e2 must have different colors. The problem is: Given
G, determine the smallest integer k such that G has an edge coloring using k colors.
(a) Describe the decision version of the GEC problem.
(b) Suppose that we have an algorithm A for solving the decision version of the GEC problem
with run time T (n, m). Describe an algorithm B for solving the optimization version of the GEC
problem. Analyze the run time of B (in terms of T (n, m).)
(c) What is the “certificate” of the GEC problem?
(d) Consider the following Time Table (TT) problem. In a school, there are p teachers
X1 , X2 , . . . , Xp and q classes Y1 , Y2 , . . . , Yq . For each i (1 ≤ i ≤ p) and j (1 ≤ j ≤ q), the teacher
Xi meets the class Yj tij times. Obviously, during any period, each teacher can meet only one
class, and each class can meet only one teacher. The problem is to schedule a complete timetable
using the minimum possible number of periods.
Describe how to convert the TT problem to the GEC problem.
Answer: (a) The decision version of the GEC problem is: Given G and an integer k, determine
whether G has an edge coloring using at most k colors.
(b) Let OP T be the smallest integer such that G has an edge coloring using OP T colors.
Clearly 1 ≤ OP T ≤ m. We use binary search to find the value OP T as follows.
B(G, p, q)
1 if p = q
2 then return p
3 i ← b p+q
2 c
4 if A(i) return YES
5 then return B(G, p, i)
6 else return B(G, i + 1, q)
The initial call should be B(G, 1, m). Since the algorithm A solves the decision version of
the GEC problem in T (n, m) time, the running time of B would be O(T (n, m) log m).
(c) The “certificate” of the GEC problem is a m-vector (c1 , c2 , . . . , cm ) where 1 ≤ ci ≤ k for
each 1 ≤ i ≤ m. (The meaning of the certificate: ci is the color of the edge ei ).
(d) Given p teachers X1 , X2 , . . . , Xp and q classes Y1 , Y2 , . . . , Yq , we construct a graph G as
follows. For each teacher, we create a vertex ti and for each class, we create a vertex cj . Then
for each ti (1 ≤ i ≤ p) and cj (1 ≤ j ≤ q) pair, we create tij edges between them. Let T be
a valid timetable, then we can color the edges corresponding to the meetings in a class period
with the same color. Clearly we get an edge coloring for G. Let C be an edge coloring of G,
then all class meetings corresponding to the edges with the same color can be scheduled in one
class period. Thus the problem of finding a class time table using the minimum possible number
of class periods is exactly the minimum GEC problem on G.
5. (6 points) An eye-glass graph of order 2n is a graph consisting of two cycles (each with n
vertices) connected by an edge. The graph shown in Figure 3 is an eye-glass graph of 8 vertices.
Consider the following problem: Given an undirected graph G = (V, E) and an even integer
2k, decide if G contains an eye-glass graph of order 2k as a subgraph.
Show this problem is NP-complete.
Answer: First, we need to show it is in NP. We can do this by using the following non-
deterministic algorithm:
3
Figure 3: The eye-glass graph of 8 vertices.
Answer: Given an undirected graph G = (V, E), we construct another undirected graph G0 as
follows. We add a new vertex s and connect s to a vertex v ∈ V . Then we add two other new
vertices t and t0 , and connect t0 to all neighbors of v and t to t0 (see the figure below.)
Clearly this constructions takes O(|V | + |E|) time. We need to show that G has a HC if and
only if G0 has a HP.
If G has a HC C = vu1 u2 . . . un−1 v, then both u1 and un−1 are the neighbors of v, thus both
are connected to t0 . So s → v ; un−1 → t0 → t is a HP of G0 . (Here, ; denote a path that
may contains more than 1 vertices.)
If G0 has a HP, the two end vertices must be s and t, i.e., s → v ; w → t0 → t, because s
and t only have one adjacent edge. Then v ; w → v is a HC of G.
7. (8 points) The Traveling Salesman Problem (TSP) has been defined in class. The TSP
4
s
v
t
G G’ t’
Figure 4: HC ≤P HP reduction
problem with triangle inequality, denoted by TSP∆, is a restricted version of the TSP problem:
it requires that the edge weight function w satisfies the triangle inequality. (Namely, for any
three vertices u, v, w of G, w(u, v) + w(v, w) ≥ w(u, w).)
Show that TSP ≤P TSP∆. (Since TSP is NP-complete, this reduction implies that TSP∆
is also NP-complete).
Hint: You need to show that in polynomial time we can transform an instance G of the
TSP problem into another instance G0 that satisfies the triangle inequality. This can be done
by adding a large number K to the weight of every edge of G.
Answer: Let (G, w(∗, ∗), K) be an instance of TSP, where G = (V, E) is a complete graph
consisting of n vertices, w(∗, ∗) is the edge weight function, and K is a number. (So the question
is: does G has a HC with total weight ≤ K). We construct an instance (G0 , w0 (∗, ∗), K 0 ) of TSP∆
as follows.
• Let M be the maximum weight of all edges in G. (Namely M = max(i,j)∈E {w(i, j)}).
Define w0 (i, j) = w(i, j) + M for all (i, j) ∈ E.
• Set K 0 = K + M × n.
The time for constructing (G0 , w0 (∗, ∗), K 0 ) is clearly O(n2 ). So this is a polynomial-time
algorithm. To complete the proof, we need to show two things.
Claim 1: (G0 , w0 (∗, ∗), K 0 ) is an instance of TSP∆. Namely we need to show w0 (∗, ∗) satisfies
the triangle inequality.
Proof: Consider any three vertices x, y, z. We have:
• w0 (C) = w(C) + nM , as C contains n edges and for any edge e we have w0 (e) = w(e) + M .
5
• So C is a HC of G with weight w(C) ≤ K iff C is a HC of G0 with weight w0 (C) =
w(C) + nM ≤ K + nM = K 0 .
then
F (x1 = 0) = (0 ∨ x̄2 ∨ x̄3 ) ∧ (1 ∨ x2 ∨ x̄4 ) = (x̄2 ∨ x̄3 ) ∧ 1 = (x̄2 ∨ x̄3 )
and
F (x1 = 1) = (1 ∨ x̄2 ∨ x̄3 ) ∧ (0 ∨ x2 ∨ x̄4 ) = 1 ∧ (∨x2 ∨ x̄4 ) = (x2 ∨ x̄4 )
B(F )
1 if A(F ) returns NO
2 then output “F is not satisfiable” and stop.
3 for i = 1 to k:
4 do
5 F0 = F (xi = 0); F1 = F (xi = 1);
6 if A(F0 ) returns YES
7 then xi = 0; F = F0 ;
8 else xi = 1; F = F1 ;
9 end for
The loop iterates k times. F0 and F1 are obtained from F by plugging in xi values, so it can
be done in time linear of the size of the formula F . Thus algorithm takes polynomial time.