Algorithm II
10. Extending Tractability
WU Xiaokun 吴晓堃
xkun.wu [at] gmail
Q. Suppose I need to solve an \mathcal{NP}-complete problem. What should I
do?
A. Theory says you’re unlikely to find poly-time
algorithm.
Must sacrifice one of three desired features.
This lecture. Solve some special cases of \mathcal{NP}-complete problems.
Given a graph G = (V, E) and an integer k, is there a subset of vertices S \subseteq V such that | S | \le k, and for each edge (u, v) either u \in S or v \in S or both?
Q. VERTEX-COVER is \mathcal{NP}-complete. But what if k is small?
Brute force. O(k n^{k+1}).
Goal. Limit exponential dependency on k, say to O(2^k k n).
Ex. n = 1000, k =
10.
Brute. k n^{k+1} = 10^{34}
\Rightarrow infeasible.
Better. 2^k k n = 10^7
\Rightarrow feasible.
Remark. If k is a constant, then the algorithm is poly-time; if k is a small constant, then it’s also practical.
Claim. Let (u, v) be an edge of G. G has a vertex cover of size \le k iff at least one of G - \{ u \} and G - \{ v \} has a vertex cover of size \le k - 1.
Pf. \Rightarrow Suppose G has a vertex cover S of size \le k.
Pf. \Leftarrow Suppose S is a vertex cover of G - \{ u \} of size \le k - 1.
Claim. If G has a
vertex cover of size k, it has \le k (n - 1) edges.
Pf. Each vertex covers at most n - 1 edges.
Claim. The following algorithm determines if G has a vertex cover of size \le k in O(2^k kn) time.
Vertex-Cover
(G, k)
Vertex-Cover
(G - \{u\}, k-1);Vertex-Cover
(G - \{v\}, k-1);Pf.
T(n,k) = \left\{ \begin{array}{ll} c & \text{if}\ k = 0 \\ cn & \text{if}\ k = 1 \Rightarrow T(n,k) \le 2^k ckn \\ 2T(n,k-1) + ckn & \text{if}\ k > 1 \\ \end{array}\right.
Independent set on trees. Given a tree, find a max-cardinality subset of nodes such that no two are adjacent.
Fact. A tree has at least one node that is a leaf (degree = 1).
Key observation. If node v is a leaf, there exists a max-cardinality independent set containing v.
Pf. [exchange argument]
Theorem. The greedy algorithm finds a max-cardinality independent set in forests (and hence trees).
INDEPENDENT-SET-IN-A-FOREST
(F)
Remark. Can implement in O(n) time by maintaining nodes of degree 1 in postorder.
Weighted independent set on trees. Given a tree and node weights w_v \ge 0, find an independent set S that maximizes \sum_{v \in S} w_v.
Observation. If (u, v) is an edge such that v is a leaf node, then either OPT includes u or OPT includes all leaf nodes incident to u.
Dynamic-programming solution. Root tree at some node, say r.
Bellman equation.
\begin{aligned} OPT_{in} (u) & = w_u + \sum_{v \in children(u)} OPT_{out} (v) \\ OPT_{out} (u) & = \sum_{v \in children(u)} \max \{ OPT_{in} (v), OPT_{out} (v) \} \\ \end{aligned}
Theorem. The DP algorithm computes max weight of an independent set in a tree in O(n) time.
WEIGHTED-INDEPENDENT-SET-IN-A-TREE
(T)
Independent set on trees. Tractable because we can find a node that breaks the communication among the subproblems in different subtrees.
Graphs of bounded tree width. Elegant generalization of trees that:
Wavelength-division multiplexing (WDM). Allows m communication streams (arcs) to share a portion of a fiber optic cable, provided they are transmitted using different wavelengths.
Ring topology. Special case is when network is a cycle on n nodes.
Bad news. \mathcal{NP}-complete, even on rings.
Brute force. Can determine if k colors suffice in O(k^m) time by trying all k-colorings.
Goal. O(f (k)) \cdot poly(m, n) on rings.
Interval coloring (partitioning). Greedy algorithm finds coloring such that number of colors equals depth of schedule.
c | c | d | d | f | f | j | j | |||
b | b | b | b | b | g | g | i | i | ||
a | a | e | e | e | e | h | h | h | h |
Circular arc coloring.
Circular arc coloring. Given a set of n arcs with depth d \le k, can the arcs be colored with k colors?
Equivalent problem. Cut the network between nodes v_1 and v_n. The arcs can be colored with k colors iff the intervals can be colored with k colors in such a way that “sliced” arcs have the same color.
Dynamic programming algorithm.
Running time. O(k! \cdot n).
Remark. This algorithm is practical for small values of k (say k = 10) even if the number of nodes n (or paths) is large.
Given a graph G = (V, E) and an integer k, is there a subset of vertices S \subseteq V such that | S | \le k, and for each edge (u, v) either u \in S or v \in S or both?
Weak duality. Let M
be a matching, and let S be a vertex
cover. Then, | M | ≤ | S |.
Pf. Each vertex can cover at most one edge in any
matching.
Theorem. [König-Egerváry] In a bipartite graph, the max cardinality of a matching is equal to the min cardinality of a vertex cover.
Theorem. [König-Egerváry] In a bipartite graph, the max cardinality of a matching is equal to the min cardinality of a vertex cover.
Theorem. [König-Egerváry] In a bipartite graph, the max cardinality of a matching is equal to the min cardinality of a vertex cover.
Suffices to find matching M and cover S such that | M | = | S |.
Formulate max flow problem as for bipartite matching.
Let M be max cardinality matching and let (A, B) be min cut.
Define L_A = L \cap A, L_B = L \cap B , R_A = R \cap A, R_B = R \cap B.
Claim 1. S = L_B ∪ R_A is a vertex cover.
Claim 2. | M | = | S |.