Coping with NP Hardness

advertisement
Coping with NP Hardness
Introduction
Duties
Base the grade on a final exam with an open material.
No obligatory homework, but strongly recommended.
Example – The Traveling Salesman Problem (TSP)
We have ๐‘› cities – {1, … , ๐‘›}
∀๐‘–, ๐‘— ∈ {1, … , ๐‘›} there’s a distance ๐‘‘๐‘–,๐‘—
๐‘›−1
๐‘ค(๐œƒ) = ∑ ๐‘‘๐œ‹๐‘–,๐œ‹๐‘–+1
๐‘–=1
TSP
Input: ๐‘‘๐‘–,๐‘— , B
Question: Is there a tour ๐œƒ of length (๐œƒ) ≤ ๐ต ?
๐‘‡๐‘†๐‘ƒ๐‘๐‘œ๐‘ข๐‘›๐‘‘ :
Input: ๐‘‘๐‘–,๐‘—
Question: Find ๐ต∗ (shortest path – with length ๐‘ค(๐œƒ ∗ ))
๐‘‡๐‘†๐‘ƒ๐‘œ๐‘๐‘ก :
Input: ๐‘‘๐‘–,๐‘—
Question: Find ๐œƒ ∗
๐‘‡๐‘†๐‘ƒ๐‘Ž๐‘™๐‘™ :
Input: ๐‘‘๐‘–,๐‘— ,B
Question: Find all the tours ๐œƒ s.t. ๐‘ค(๐œƒ) ≤ ๐ต
๐‘‡๐ด (๐‘ฅ) = the time it will take the algorithm to run
๐‘‡๐ด (๐‘›) = max{๐‘‡๐ด (๐‘ฅ)|๐‘™๐‘’๐‘›๐‘”๐‘กโ„Ž(๐‘ฅ) = ๐‘›}
P = consists of all the problems that have a poly-time algorithm.
NP = consists of all the problems that have a polynomial time verifier (or have a nondeterministic polynomial time algorithm).
Formally: ๐‘๐‘ƒ =
{๐‘๐‘Ÿ๐‘œ๐‘๐‘™๐‘’๐‘š๐‘  ๐œ‹|๐‘‡โ„Ž๐‘’๐‘Ÿ๐‘’ ๐‘–๐‘  ๐‘Ž ๐‘๐‘œ๐‘™๐‘ฆ − ๐‘ก๐‘–๐‘š๐‘’ ๐‘›๐‘œ๐‘› − ๐‘‘๐‘’๐‘ก๐‘’๐‘Ÿ๐‘š๐‘–๐‘›๐‘–๐‘ ๐‘ก๐‘–๐‘ ๐‘Ž๐‘™๐‘”๐‘œ๐‘Ÿ๐‘–๐‘กโ„Ž๐‘š ๐‘“๐‘œ๐‘Ÿ ๐‘‘๐‘’๐‘๐‘–๐‘‘๐‘–๐‘›๐‘” ๐œ‹}
EXP = The class of problems that have an exp-time algorithm.
NP Completenes
A problem ๐œ‹ Is NP-Complete if:
(1) ๐œ‹ ∈ ๐‘๐‘ƒ
(2) ∀๐œ‹ ′ ∈ ๐‘๐‘ƒ. ๐œ‹′ ∝ ๐œ‹ (there is a poly-time transformation from ๐œ‹′ to ๐œ‹)
TODO: Draw reductions from NP to NP-Complete problems
NP
P
๐œ‹
๐œ‹′′
๐œ‹′
Scheme for proving a problem is NP-Complete
To prove that a problem ๐œ‹ is NP-Complete:
(1) Show that ๐œ‹ ∈ ๐‘๐‘ƒ
(2) Show that ๐œ‹′ ∝ ๐œ‹ for some ๐œ‹′ that is already known to be NP-Complete.
Example – Partition problem
Input: Integers – ๐ถ = {๐‘1 , … , ๐‘๐‘› }
Questions: Is there a subset ๐‘  ⊂ {1, … , ๐‘›} s.t. ∑๐‘–∈๐‘† ๐‘๐‘– =
๐‘›
๐ต
2
๐ต = ∑ ๐‘๐‘–
๐‘–=1
Turing Reduction
๐œ‹1 ∝ ๐‘‡ ๐œ‹2 (๐œ‹1 is turing reducible to ๐œ‹2 )
If given a procedure P that solves ๐œ‹2 instances in constant time , It is possible to device a
polynomial time algorithm for ๐œ‹1 .
An obvious observation would be that:
๐‘‡๐‘†๐‘ƒ ∝ ๐‘‡ ๐‘‡๐‘†๐‘ƒ๐‘๐‘œ๐‘ข๐‘›๐‘‘ ∝ ๐‘‡ ๐‘‡๐‘†๐‘ƒ๐‘œ๐‘๐‘ก
But what about:
๐‘‡๐‘†๐‘ƒ๐‘๐‘œ๐‘ข๐‘›๐‘‘ ∝ ๐‘‡ ๐‘‡๐‘†๐‘ƒ
A detailed explanation -
Given: Procedure P that gets ๐‘‘๐‘–,๐‘— , ๐ต and returns T/N
Devise: Algorithm for ๐‘‡๐‘†๐‘ƒ๐‘๐‘œ๐‘ข๐‘›๐‘‘
Input: ๐‘‘๐‘–,๐‘—
Find: ๐ต∗
We can easily do it by a binary search for ๐ต∗ in the range [1, ๐‘› โˆ™ max ๐‘‘๐‘–,๐‘— ]
The sums of all weights is not always polynomial:
๐‘‘๐‘–,๐‘— = 2100 , ๐‘› = 100
Each number is only a 100 bits, but their sum is a number exponential in the size of the input.
What about:
๐‘‡๐‘†๐‘ƒ๐‘œ๐‘๐‘ก ∝ ๐‘‡ ๐‘‡๐‘†๐‘ƒ๐‘๐‘œ๐‘ข๐‘›๐‘‘ ?
K-largest subses (KLS)
Input: ๐ถ = {๐‘1 , … , ๐‘๐‘› }, ๐พ, ๐ต (๐‘1 , … , ๐‘๐‘› ∈ โ„ค)
C has 2๐‘› subsets ๐‘†๐‘– ⊆ ๐ถ
๐‘ก๐‘– = ∑ ๐‘๐‘—
๐‘๐‘— ∈๐‘†๐‘–
๐‘†1 , ๐‘†2 , … , ๐‘†2๐‘›
๐‘ก1 ≥ ๐‘ก2 ≥ โ‹ฏ ≥ ๐‘ก2๐‘›
Question: Are there at least k subsets ๐‘†๐‘– of ๐ถ of size ๐‘ก๐‘– ≥ ๐ต?
Claim: Partition ∝ ๐‘‡ KLS
Proof: Assume given a procedure ๐‘ƒ(๐ถ, ๐พ, ๐ต) → ๐‘Œ/๐‘ for ๐พ๐ฟ๐‘†.
We need a procedure ๐‘„(๐ถ, ๐ต) returning an index ๐‘— s.t. ๐‘ก๐‘— ≥ ๐ต > ๐‘ก๐‘—+1
Answer: We should look at the range [1,2๐‘› ] and perform a binary search on it. By that we would
find exactly the B that is the threshold.
Now we should use the procedure Q to produce and algorithm for partition.
๐ถ = {๐‘1 , … , ๐‘๐‘› }
1
1. ๐ต ← 2 ∑ ๐‘๐‘–
2. ๐‘—1 ← ๐‘„(๐ถ, ๐ต)
3. ๐‘—2 ← ๐‘„(๐ถ, ๐ต + 1)
4. If ๐‘—1 = ๐‘—2 then return No. Else return Yes.
Home Exercise: Prove the reduction is correct.
A harder home exercise: Give a polynomial transformation from ๐‘๐‘Ž๐‘Ÿ๐‘ก๐‘–๐‘ก๐‘–๐‘œ๐‘› ∝ ๐พ๐ฟ๐‘†.
A problem is self-reducible if there is a Turing reduction from its optimization version to its
decision version.
An example: ๐‘‡๐‘ƒ๐‘œ๐‘๐‘ก ∝ ๐‘‡ ๐‘‡๐‘†๐‘ƒ → ๐‘‡๐‘†๐‘ƒ is self reducible.
Another example: Clique is self-reducible.
Lets first define Clique…
๐ถ๐‘™๐‘–๐‘ž๐‘ข๐‘’:
Input: Graph ๐บ,integer ๐พ
Question: Does ๐บ contain a Clique of size ≥ ๐‘˜?
A Clique is a complete sub-graph.
Proof: need to show ๐ถ๐ฟ๐‘„๐‘œ๐‘๐‘ก ∝ ๐‘‡ ๐ถ๐ฟ๐‘„๐‘‘๐‘’๐‘
Or in other words – given a procedure ๐‘ƒ(๐บ, ๐‘˜) which answers whether ๐ถ๐ฟ๐‘„๐‘‘๐‘’๐‘ has a Clique of
size ๐‘˜.
We need to devise an algorithm to find the biggest Clique in graph ๐บ.
Algorithm:
1) Find ๐‘˜ ∗ which is the size of the largest Clique in ๐บ by applying ๐‘ƒ(๐บ, ๐‘˜) for0020๐‘˜ = 1, …
2) For every ๐‘ฃ ∈ ๐บ do:
a. Set ๐บ ′ ← ๐บ \{๐‘ฃ} (erase ๐‘ฃ and all its edges)
b. ๐‘ ← ๐‘ƒ(๐บ ′ , ๐‘˜ ∗)
c. If ๐‘ = ๐‘Œ then ๐บ ← ๐บ′ else set ๐บ ← ๐บ({๐‘ฃ} ∪ ๐‘(๐‘ฃ))
Home exercise 3: Show that dominating set is self reducible.
๐‘Š ⊆ ๐‘‰ in graph ๐บ is a dominating set if ∀๐‘ฅ ∈ ๐‘‰\๐‘Š has a neighbor in ๐‘Š.
๐ท๐‘‚๐‘€๐‘‘๐‘’๐‘ :
Input: ๐บ, ๐‘˜
Question: Does ๐บ have a dominating set of size ≤ ๐‘˜.
๐ท๐‘‚๐‘€๐‘œ๐‘๐‘ก :
Input: ๐บ
Question: Find the smallest dominating set.
Pseudo-Polynomial Algorithms
Knapsack Problem
Input: Item types 1, … , ๐‘›. Each item has a size ๐‘†๐‘– and cost ๐ถ๐‘– .
Also given a knapsack of size ๐พ. Profit target ๐ต.
Question: Are there integers {๐‘ฅ1 , … , ๐‘ฅ๐‘› } s.t. ∑๐‘›๐‘–=1 ๐‘ฅ๐‘– ๐‘†๐‘– ≤ ๐พ and the profit is larger than B
(∑๐‘›๐‘–=1 ๐‘ฅ๐‘– ๐ถ๐‘– ≥ ๐ต)
Uniform Knapsack
A variant in which K=B (๐‘†๐‘– = ๐ถ๐‘– )
Question: ∃๐‘ฅฬ… , … , ๐‘ฅฬ…๐‘› s.t. ∑ ๐‘ฅ๐‘– ๐ถ๐‘– = ๐‘˜.
0-1 Knapsack
Same except ๐‘ฅ๐‘– ∈ {0,1}
Algorithm for Uniform Knapsack
Stage A
Build a DAG (Directed Acyclic Graph) on ๐‘‰ = {0, … , ๐‘˜}
๐ธ = {⟨๐ด, ๐ต⟩|1 ≤ ๐ด < ๐ต ≤ ๐‘˜, ∃๐‘–. ๐ด + ๐ถ๐‘– = ๐ต}
Example:
๐‘˜=8
0
1
2
3
4
5
6
7
Stage B
Check reachibility from 0 to ๐‘˜ in the DAG.
Home exercise 4: Prove that ๐‘˜ ks reachable from 0 ↔ โ‹ƒ ๐พ(๐ถฬ… , ๐พ) = ๐‘ฆ.
max(๐ผ) = largest number in the input ๐ผ.
A is a pseudo-polynomial time algorithm for a problem ๐œ‹ if its complexity is bounded by a
polynomial in both length of the input and max(๐ผ).
---------- End of lesson 1
Pseudo Polynomial Algorithms
Instance ๐ผ composed of numbers
๐‘™๐‘’๐‘›๐‘”๐‘กโ„Ž(๐ผ)
max(๐ผ) =largest number in ๐ผ.
๐ด is pseudo-polynomial if ∃polynomial ๐‘ ๐‘ . ๐‘ก. ∀๐ผ, ๐‘‡๐ด (๐ผ) ≤ ๐‘ƒ(๐‘™๐‘’๐‘›๐‘”๐‘กโ„Ž(๐ผ), max(๐ผ))
Strongly NP-Hardness
For problem ๐œ‹, denote by ๐œ‹๐‘ž (๐‘ž is some polynomial) the problem restricted to instances ๐ผ in
which max(๐ผ) ≤ ๐‘ž(๐‘™๐‘’๐‘›๐‘”๐‘กโ„Ž(๐‘–)).
๐œ‹ is strongly NP-Hard if ๐œ‹๐‘ž is NP-Hard.
Fact: If ๐œ‹ is strongly NP-Hard it does not have a pseudo-polynomial time algorithm (unless
P=NP).
Exercise 1: Prove.
0-1 knapsack
Input: ๐ถ = {๐‘1 , … , ๐‘๐‘› }, ๐‘˜
Question: Is there a subset ๐‘  ⊂ {1, … , ๐‘›} ๐‘ . ๐‘ก. ∑๐‘–∈๐‘† ๐‘๐‘– = ๐‘˜?
Dynamic Programming
๐‘‡(๐‘–, ๐‘) = {
1 ∃๐‘  ⊆ {1, … , ๐‘–} ๐‘ . ๐‘ก. ∑ ๐‘๐‘— = ๐‘
0
For 1 ≤ ๐‘– ≤ ๐‘›, 0 ≤ ๐‘ ≤ ๐‘˜
๐‘—∈๐‘†
๐‘œ๐‘กโ„Ž๐‘’๐‘Ÿ๐‘ค๐‘–๐‘ ๐‘’
The final answer would be: ๐‘‡(๐‘›, ๐‘˜).
Process: We start by filling row ๐‘– = 1.
1 ๐‘ = 0 ∨ ๐‘ = ๐‘1
๐‘‡(1, ๐‘) = {
0
๐‘œ๐‘กโ„Ž๐‘’๐‘Ÿ๐‘ค๐‘–๐‘ ๐‘’
Suppose we filled rows till ๐‘–, and now we fill row ๐‘– + 1:
1 ๐‘‡(๐‘–, ๐‘) ∨ ๐‘‡(๐‘–, ๐‘ − ๐‘๐‘–+1 )
๐‘‡(๐‘– + 1, ๐‘) = {
0
๐‘œ๐‘กโ„Ž๐‘’๐‘Ÿ๐‘ค๐‘–๐‘ ๐‘’
Time: ๐‘‚(๐‘›๐พ). So it’s pseudo polynomial.
๐‘ป๐‘บ๐‘ท๐’๐’‘๐’•
Input: ๐‘‘๐‘–,๐‘—
๐‘› ๐‘›
The number of possibilities is (๐‘› − 1)! โˆ™ ๐‘› = ๐‘›! ~ ( ๐‘’ ) ~2๐‘‚(๐‘› ๐‘™๐‘œ๐‘”๐‘›)
We want to do it in ๐‘‚(๐‘(๐‘›) โˆ™ 2๐‘› )
๐‘€ = {2, … , ๐‘›}
๐‘‡(๐‘–, ๐‘†) = length of the shortest tour that starts at city 1, visits all visits of ๐‘† exactly once and
ends at ๐‘—.
Process of filling ๐‘‡:
For |๐‘†| = 1: ๐‘† = {๐‘—}.
๐‘‡(๐‘—, ๐‘†) = ๐‘‘๐‘–,๐‘—
For |๐‘†| = ๐‘™ + 1:
Let’s define ๐‘† ′ to be the vertices between city 1 and ๐‘—.
|๐‘† ′ | = ๐‘™.
๐‘‡(๐‘–, ๐‘†) = min{๐‘‡(๐‘˜, ๐‘† ′ )|๐‘† ′ ⊆ ๐‘†, |๐‘† ′ | = ๐‘™, ๐‘˜ ∈ ๐‘† ′}
Final answer: min{๐‘‡(๐‘—, ๐‘€) + ๐‘‘๐‘—,1 }
๐‘—∈๐‘€
We have 2๐‘›−1 different subsets times n. And ๐‘› operations for each cell.
So in conclusion we are talking about 2๐‘›−1 โˆ™ ๐‘›2 .
Exercise 2: Find the shortest TSP path (and not cycle).
TSP Path:
You start at some city ๐œ‹1 and travel to a city ๐œ‹๐‘› . Allowing you to start or to end at any city.
Exercise 3: TSP with dependent distances:
Input: ๐‘‘๐‘–,๐‘—,๐‘˜ - the cost/distance for going from ๐‘– to ๐‘— if the city you visited be fore was ๐‘˜.
Recursion
3SAT
Input: ๐œ‘ = โ‹€๐‘š
๐‘–=1 ๐‘๐‘–
๐‘–
๐‘–
๐‘๐‘– = (๐‘ข1 ∨ ๐‘ข2 ∨ ๐‘ข3๐‘– ), ๐‘ข๐‘– ∈ {๐‘ฅ๐‘– , ๐‘ฅฬ…๐‘– }
Question: Does ๐œ‘ have a satisfying truth assignment ๐‘“: {๐‘ฅ1 , … , ๐‘ฅ๐‘› } → {๐‘‡, ๐น} ๐‘ . ๐‘ก. ๐‘“(๐‘ฅฬ…๐‘– ) = ฬ…ฬ…ฬ…ฬ…ฬ…ฬ…ฬ…
๐‘“(๐‘ฅ๐‘– )
X3SAT
๐‘“ is required to satisfy in each clause exactly one literal.
Naïve Algorithm: ๐‘‚(2๐‘› ๐‘(๐‘š))
๐‘“(๐‘ฅ๐‘– ) = ๐‘‡
Suppose ๐‘ฅ๐‘– appears in some ๐ถ = (๐‘ข๐‘– , ๐‘ข๐‘— , ๐‘ข๐‘˜ ). Suppose ๐‘ข๐‘– = ๐‘ฅ๐‘– .
Then must yield ๐‘“(๐‘ข๐‘— ) = ๐‘“(๐‘ข๐‘˜ ) = ๐‘“.
Symmetrically, if ๐‘ข๐‘– = ๐‘ฅฬ…๐‘– we should set them to true.
If ๐‘“(๐‘ฅ๐‘– ) = ๐น
๐ถ = (๐‘ฅ๐‘– , ๐‘ข๐‘— , ๐‘ข๐‘˜ ) → ๐‘“(๐‘ข๐‘— ) ≠ ๐‘“(๐‘ข๐‘˜ ) →
Get rid of ๐‘‹๐‘˜ and replace it by ๐‘ฅ๐‘— or ๐‘ฅฬ…๐‘—
Canonical form: ๐œ‘ is in canonical form if each close contains 3 different variables.
Fact: If ๐œ‘ is not in canonical form, then it can be transformed into a shorter ๐œ‘ in canonical form
in polynomial time.
Idea: Suppose that ๐œ‘ is not canonical. Let ๐‘ = (๐‘ข1 , ๐‘ข2 , ๐‘ข3 ) be a clause violating the condition.
Clauses might already be simplified formulas and not necessarily the input.
Suppose (๐‘ข1 , ๐‘ข2 , ๐น), ๐‘ข2 = ๐‘ฅ2
We can discard ๐‘ข1 , replacing by ๐‘ฅ1 / ฬ…ฬ…ฬ…
๐‘ฅ1 as needed
(๐‘ฅ1 , ๐‘ฅ1 , ๐‘ฅ1 ) → not satisfyable
(๐‘ฅ1 , ๐‘ฅ1 , ฬ…ฬ…ฬ…)
๐‘ฅ1 → ๐‘“(๐‘ฅ! ) = ๐น
โ‹ฎ
(๐‘ฅ1 , ๐‘ฅ1 , ๐‘ฅ2 ) → ๐‘“(๐‘ฅ1 ) = ๐น, ๐‘“(๐‘ฅ2 ) = ๐‘‡
Algorithm for X3SAT:
(1) Pick ๐‘ฅ๐‘– ∈ ๐œ‘
(2) ๐‘ ← ๐‘‡๐ธ๐‘†๐‘‡(๐œ‘, ๐‘ฅ๐‘– , ๐‘‡)
(3) If ๐‘ = ๐‘‡ then return ๐‘‡.
(4) Else ๐‘ ← ๐‘‡๐ธ๐‘†๐‘‡(๐œ‘, ๐‘ฅ๐‘– , ๐น) and return ๐‘.
Procedure ๐‘‡๐ธ๐‘†๐‘‡(๐œ‘, ๐‘ฅ๐‘– , ๐‘ฃ)
(1) Set ๐‘“(๐‘ฅ๐‘– ) ← ๐‘ฃ
(2) Canonize ๐œ‘ → ๐œ‘′ .
a. If found contradicton while canonizing. Return ๐น.
b. If ๐œ‘ ′ = ∅ then return ๐‘‡.
(3) Run ๐‘‹3๐‘†๐ด๐‘‡(๐œ‘′ ).
๐‘”(๐‘›) = max ๐‘‡๐ด (๐œ‘) over ๐œ‘ with n variables.
Suppos that there is a clause in which ๐‘ฅ๐‘– appear positively.
๐‘ = (๐‘ฅ๐‘– , ๐‘ข2 , ๐‘ข3 ). When you assign: ๐‘“(๐‘ฅ๐‘– ) ← ๐‘‡ ⇒ ๐‘“(๐‘ข2 ) = ๐‘“(๐‘ข3 ) = ๐น.
So ๐œ‘′ has at least 3 variables less.
(๐‘ฅโŸ๐‘– , ๐‘ข2 , ๐‘ข3 )
๐น
๐‘ข2 ≡ ๐‘ข
ฬ…ฬ…ฬ…3
So ๐œ‘′ has at least 2 variables less.
Case 2:
๐‘ = (๐‘ฅฬ…๐‘– , ๐‘ข2 , ๐‘ข3 )
๐‘›
๐‘”(๐‘›) ≤ ๐‘(๐‘›) + 2 โˆ™ ๐‘”(๐‘› − 2) ⇒ ๐‘”(๐‘›) ≤ 2 2
๐‘”(๐‘›) ≤ ๐‘(๐‘›) + 2๐›ผ(๐‘›−2) + 2๐›ผ(๐‘›−3)
2SAT
Clauses ๐‘๐‘– = (๐‘ข1๐‘– , ๐‘ข2๐‘– )
-------end of lesson 2
๐‘๐‘’๐‘’๐‘‘ ๐‘ก๐‘œ ๐‘๐‘Ÿ๐‘œ๐‘ฃ๐‘’!
≤
2๐›ผ๐‘›
Maximum Independent Set on Planar Graphs
MIS-Planar Algorithm
1. Find a Separator ๐‘†
2. For every Independent Set ๐‘€0 ⊆ ๐‘†
a. Erase from ๐ด๐‘– all vertices adjacent to ๐‘€0 along with their edges
b. Apply ๐‘€1 ← MIS-Planar ()
c. Apply ๐‘€2 ← MIS-Planar ()
d. ๐‘€ ← ๐‘€0 ∪ ๐‘€1 ∪ ๐‘€2
3. Return the largest ๐‘€ seen
Correctness
Denote by ๐‘€∗ = Maximum Independent Set of ๐บ
๐‘€∗ = ๐‘€0∗ ∪ ๐‘€1∗ ∪ ๐‘€2∗
๐‘€0 = ๐‘€0∗
๐‘‡(๐‘›) = The maximum time complexity on ๐‘› vertex graph (in the worst case).
2
๐‘‡(๐‘›) ≤ ๐‘1 ๐‘›๐‘Ÿ2√๐‘› (๐‘2 ๐‘› + 2๐‘‡ ( ๐‘›))
3
Guess that ๐‘‡(๐‘›) ≤ 2๐ถ1 ๐‘›
Exercise – Verify!
A graph is planar if it does not contain a ๐พ5 or ๐พ33 as a sub-graph (minor).
Therefore, The clique problem on planar graph is not analogous to IS. The complementary graph
of a planar graph is not always a planar graph.
0-1 Knapsack
Input: Integers {๐‘Ž, … , ๐‘Ž๐‘› }
Question: Is there a subset ๐‘† ⊆ {๐‘Ž1 , … , ๐‘Ž๐‘› } such that ∑๐‘–⊆๐‘† ๐‘Ž๐‘– = ๐ต ?
P.P. Algorithm ๐‘‚(๐‘›๐ต)~2๐‘›
๐‘›
Now we will see a 2 2 algorithm.
Assume ๐‘› is even.
๐ด๐›ผ {๐‘Ž1 , … , ๐‘Ž๐‘› }
2
๐ด๐›ฝ {๐‘Ž๐‘›+1 , … , ๐‘Ž๐‘› }
๐‘›
๐พ = 22
Look at the sorted items of ๐ด๐›ผ and ๐ด๐›ฝ
๐‘›
๐‘† = ๐‘†1 ∪ ๐‘†2
๐‘›
๐‘†1 ⊆ {1, … , }
2
๐‘›
๐‘†2 ⊆ { + 1, … , ๐‘›}
2
Set ๐‘– = 0, ๐‘— = 2 − 1
We check whether ๐›ผ๐‘– + ๐›ฝ๐‘— = ๐ต?
If it’s smaller than B – ๐‘– = ๐‘– + 1
If it’s larger than B – ๐‘— = ๐‘— − 1
If it equals, we’re done!
We loop until either ๐‘– or ๐‘— reaches the end.
Claim: The algorithm is correct.
Proof: We need to show that if the algorithm returns no, then there’s no solution.
By contradiction: Suppose there is some ๐‘† ∗ that solves the problem.
๐‘† ∗ = ๐‘†1∗ + ๐‘†2∗ ๐‘ . ๐‘ก. ๐‘†1∗ ⊆ ๐‘†1 , ๐‘†2∗ ⊆ ๐‘†2
By the definition of the algorithm, one of the indices had to explore the entire table since the
algorithm gave a negative answer.
Suppose ๐‘– reached the value ๐‘– ∗ before ๐‘— reached ๐‘— ∗ if at all.
But
๐›ผ๐‘– + ๐›ฝ๐‘— > ๐›ผ๐‘–∗ + ๐›ฝ๐‘—∗
Since always larger than B. But then we should have advanced with ๐‘—. But our situation stays the
same. So eventually ๐‘— will reach ๐‘— ∗ - contradiction.
๐‘›
The time complexity at the moment is ๐‘› โˆ™ 2 2 . The additional ๐‘› factor is due to the initial sorting.
However, we can sort the subset linearly – we just need to add the subsets containing a new
item and merge them with the old subsets till we have all subsets.
We still have that ๐‘‡ โˆ™ ๐‘† = ๐‘‚(2๐‘› )
What happens if we divide everything into ๐‘˜ tables?
๐‘‡ = ๐‘‚ (2
๐‘˜−1
๐‘›
๐‘˜ )
๐‘›
๐‘† = ๐‘‚ (2๐‘˜ )
๐‘›
๐ด๐›ผ1 = {1, … , }
๐‘˜
2nd description:
We will break ๐ด still into two sets – ๐ด๐›ผ and ๐ด๐›ฝ .
๐‘›
๐ด๐›ผ = {1, … , ๐‘˜ }
๐ด๐›ฝ = the rest
We build only the table ๐›ผ (sorted).
For every subset ๐‘„ ⊆ ๐ด๐›ฝ do
๐‘ž = ∑ ๐‘Ž๐‘–
๐‘Ž๐‘– ∈๐‘„
๐‘Ÿ = ๐ต−๐‘ž
Check if ๐‘Ÿ appears in the table ๐›ผ.
(by binary search)
There are 2|๐›ฝ| iterations = 2
๐‘˜−1
๐‘›
๐‘˜
iterations.
๐‘›
๐‘˜
Each iteration takes time.
๐‘‡ = ๐‘‚ (๐‘› โˆ™ 2
๐‘˜−1
๐‘›
๐‘˜ )
๐‘›
๐‘† = ๐‘‚ (2๐‘˜ )
We would like to show that we can do it in:
๐‘›
๐‘‡ = ๐‘‚ (22 )
๐‘›
๐‘† = ๐‘‚ (24 )
๐‘›
๐พ = 24
๐‘›
Lets divide everything into four parts (each size 4 ). Now lets treat each two parts as a single part
of size ๐‘›2 . Denote the first “unified” table as ๐›ผ + ๐›ฝ
Implementation of ๐œถ
By a priority queue ๐‘ƒ๐‘„๐›ผ+๐›ฝ
๐‘›
Storing ๐‘‚ (2 4 ) = ๐‘‚(๐พ) elements
Operations: Insert, Extract_min
Obviously we need all possible combinations of elements of ๐›ผ and ๐›ฝ. Therefore we can imagine
a matrix of all possible combinations.
At first, we will put just the first column in the queue. It is clear the value at 0,0 is the minimal
one - so the minimal one is already in the queue.
Whenever we take out a value from the queue, we will insert the value to its right.
Similarly, we can unite the last two ๐พ sized lists of subsets.
Exercise: Apply the technique for the following:
Exact Hitting set
Input: Universe
๐‘ˆ = {๐‘ข1 , … , ๐‘ข๐‘› }
Subsets ๐‘†1 , … , ๐‘†๐‘š ⊆ ๐‘ˆ
Question: Find ๐‘… ⊆ ๐‘ˆ touching each ๐‘†๐‘– exactly once
(i.e. |๐‘… ∩ ๐‘†๐‘– | = 1∀๐‘–)
You can say that ๐‘š is no longer than ๐‘›.
------ end of lesson 3
Theorem: If there exists a poly-time algorithm for finding a clique of size ๐‘˜ = log ๐‘› in a given
graph of size ๐‘›, then there exists a poly-time algorithm for finding a clique of arbitrary size ๐‘˜ in
๐บ in time ~2๐‘‚(√๐‘˜ log ๐‘›) ≤ 2๐‘‚(√๐‘› log ๐‘›)
Proof: Suppose we are given a polytime algorithm for finding a clique of size ๐‘˜, ∀๐‘˜ ≤ log ๐‘›
Algorithm ๐ต[๐บ, ๐‘˜] (๐บ is arbitrary)
1. Construct ๐บฬƒ (๐‘‰ฬƒ , ๐ธฬƒ )
๐‘‰ฬƒ = {๐‘Š ⊂ ๐‘‰||๐‘Š| = √๐‘˜}
๐‘›
[|๐‘‰ฬƒ | = ๐‘›ฬƒ = ( ) ≤ 2√๐‘˜ log ๐‘› ]
√๐‘˜
๐ธฬƒ = {(๐‘Š, ๐‘Š ′ )|๐‘Š ∩ ๐‘Š ′ = ∅, ๐‘Š ∪ ๐‘Š ′ ๐‘–๐‘  ๐‘Ž ๐‘๐‘™๐‘–๐‘ž๐‘ข๐‘’ ๐‘–๐‘› ๐บ}
2. Apply ๐ด[๐บฬƒ , √๐‘…]
And return it’s answer.
Observation 1: √๐‘˜ < log ๐‘›ฬƒ = √๐‘˜ log ๐‘› ⇒ ๐ด works in time ๐‘‚(๐‘›ฬƒ๐‘ ) = ๐‘‚ (2๐‘‚(√๐‘˜ log ๐‘›) )
Observation 2: ๐บฬƒ has a √๐‘˜-Clique ⇔ ๐บ has a ๐‘˜-clique.
Approximation Algorithms
Optimization problem ๐œ‹.
Input ๐ผ
๐‘“ ∗ (๐ผ) =Value of optimal solution of ๐ผ
Polytime algorithm for ๐œ‹ for input ๐ผ, return ๐‘“๐ด (๐ผ).
We are interested in
|๐‘“๐ด (๐ผ)−๐‘“∗ (๐ผ)|
๐‘“∗ (๐ผ)
the error measure.
|๐‘“๐ด (๐ผ)−๐‘“∗ (๐ผ)|
≤๐œŒ
๐‘“∗ (๐ผ)
๐‘“ (๐ผ)
For minimization: ๐‘“๐ด∗ (๐ผ) ≤ ๐œŒ. A
Definition 1: We say that ๐ด has approximation ratio ρ if ∀Input ๐ผ
๐‘“∗ (๐ผ)
๐ด (๐ผ)
Definition 2: For maximization problems: ๐‘“
≤ ๐œŒ.
good
approximation is when 1 ≤ ๐œŒ
TSP
๐‘‡๐‘†๐‘ƒ๐‘‚๐‘ƒ๐‘‡ – ๐‘› cities, 1 … ๐‘› and there was a distance between every two cities ๐‘‘๐‘–๐‘—
The goal is to find a cyclic tour that visits all cities, such that it’s shortest (has minimal distance).
Common Assumptions
(1) Symmetry: ๐‘‘๐‘–๐‘— = ๐‘‘๐‘—๐‘–
(2) Triangle Inequality: ๐‘‘๐‘–๐‘— ≤ ๐‘‘๐‘–๐‘˜ + ๐‘‘๐‘˜๐‘—
Cannot Approximate without Triangle Inequality
Theorem: If there is an approximation algorithm for ๐‘‡๐‘†๐‘ƒ (without triangle inequality) with ratio
๐œŒ (up to exp(๐‘›)) then ๐‘ƒ = ๐‘๐‘ƒ
Proof: Suppose we have such an approximation algorithm ๐ด with ratio ๐œŒ.
We will use it to define a polynomial algorithm ๐ต for the Hamiltonian cycle problem.
Reminder: The Hamiltonian cycle problem has input ๐บ and the question is: Is there a cycle that
goes exactly once through every vertex?
Algorithm ๐ต gets an input ๐บ
Create A ๐‘‡๐‘†๐‘ƒ instance on ๐‘› cities (assuming that ๐บ is of size ๐‘›).
(๐‘–, ๐‘—) ∈ ๐บ
1,
๐‘‘๐‘–๐‘— = {
๐œŒ๐‘› + 2, ๐‘œ๐‘กโ„Ž๐‘’๐‘Ÿ๐‘ค๐‘–๐‘ ๐‘’
Now run ๐ด on this instance.
If ๐น๐ด [๐ผ] = ๐‘› return yes. Otherwise return no.
Claim: ๐บ has a Hamiltonian cycle ⇔ ๐ต returns yes.
Proof:
G has no Hamiltonian cycle ⇒ B surely returns no by definition of ๐ผ
๐บ has a Hamiltonian cycle๐‘“ ∗ (๐‘›) = ๐‘›. Suppose ๐ต returns “no”. or ๐‘“๐ด (๐ผ) > ๐‘›. It means that
๐‘“๐ด (๐ผ) ≥ (๐‘› − 1) + (๐œŒ๐‘› + 2) ≥ (๐œŒ + 1)๐‘› + 1
๐‘“๐ด (๐ผ)−๐‘“∗ (๐ผ)
๐‘“∗ (๐ผ)
≥
๐œŒ๐‘›+1
๐‘›
> ๐œŒ ⇒ ๐ด Does not have approximation ration ๐œŒ.
Nearest Neighbor Heuristics
Each step, you visit the closest city which you haven’t visited yet. A greedy procedure…
This is the least efficient of the procedures we’ll describe.
๐œŒ ≅ log ๐‘›
This ๐œŒ will probably be true for directed graphs as well.
Global Nearest Neighbor Heuristics
We hold a cycle at any given moment. We look for the city that can be added to the cycle such
that the cycle is minimal (of all possible cycles with the added city).
In this algorithm ๐œŒ = 1 according to definition 1 and ๐œŒ = 2 according to the second definition.
The Tree Algorithm
1. Construct a minimum spanning tree ๐‘‡ for ๐‘‘๐‘–๐‘—
2. Construct an Euler tour ๐œƒ on ๐‘‡.
3. Shortcut the tour ๐œƒ to a tour ๐œƒ ′ which visits every city exactly once.
We know ๐‘ค(๐œƒ ′ ) ≤ ๐‘ค(๐œƒ) (due to the triangle inequality)
๐‘ค(๐œƒ) ≤ 2๐‘ค(๐‘‡) Since
๐œƒ ∗ - best tour.
But ๐‘ค(๐‘‡) ≤ ๐‘ค(๐‘‡๐œƒ∗ ) ≤ ๐‘ค(๐œƒ ∗ )
So we know ๐‘ค(๐œƒ ′ ) ≤ 2๐‘ค(๐œƒ ∗ )
Definition 1: ๐œŒ ≤
|๐‘ค(๐œƒ∗ )−๐‘ค(๐œƒ′ )|
๐‘ค(๐œƒ∗ )
Definition 2: ๐œŒ ≤
๐‘ค(๐œƒ′ )
๐‘ค(๐œƒ∗ )
≤
≤
2๐‘ค(๐œƒ∗ )
๐‘ค(๐œƒ∗ )
2๐‘ค(๐œƒ∗ )−๐‘ค(๐œƒ∗ )
๐‘ค(๐œƒ∗ )
=1
≤2
Tight Exaple
TODO: Draw tight example
The tight example is a circle graph where each edge has a single edge to a vertex outside the
circle. The weight within the cycle is ๐›ผ and the weight of every outer edge will be ๐›ฝ. ๐›ฝ โ‰ช ๐›ผ.
๐‘ค(๐œƒ ′ ) = (๐‘› − 1)๐›ผ + 2๐›ฝ + (๐‘› − 1)(๐›ผ + 2๐›ฝ) ≈ 2๐‘›(๐›ผ + ๐›ฝ)
๐‘›
๐‘ค(๐œƒ ∗ ) = ๐‘› โˆ™ ๐›ผ + +๐‘›๐›ฝ + 2๐›ฝ โˆ™ 2 ≈ ๐‘›(๐›ผ + 2๐›ฝ)
So the ratio is ≈ 2.
Chrostofides
Euler Graph: All degrees are even. On an Euler graph you always have an Euler tour (if and only
if).
In any graph, the number of nodes of odd degree is even.
1.
2.
3.
4.
Build ๐‘€๐‘†๐‘‡ ๐‘‡
Select a weight matching ๐‘€ on the odd degree vertices ๐‘.
Compute an Euler tour ๐œƒ on ๐‘‡ ∪ ๐‘€
Shortcut into ๐œƒ ′
?
๐‘ค(๐‘‡) + ๐‘ค(๐‘€) ≤ 1.5๐‘ค(๐œƒ ∗ )
1
Prove: ๐‘ค(๐‘€) ≤ 2 ๐‘ค(๐œƒ ∗ )
Observe the tour ๐œƒ ∗.
Observe the tour ๐œƒฬ‚ which is a tour of all the vertices of ๐‘€.
Denote alternating edges of ๐‘ as ๐‘€1 and ๐‘€2 .
๐œƒฬ‚ = ๐‘€1 ∪ ๐‘€2
๐‘€1 , ๐‘€2 are matchings on ๐‘.
๐‘ค(๐‘€)
≤
๐‘ค(๐‘€1 ), ๐‘ค(๐‘€2 )
๐ถโ„Ž๐‘œ๐‘ ๐‘’๐‘› ๐‘Ž๐‘  ๐‘กโ„Ž๐‘’ ๐‘š๐‘–๐‘›
๐‘ค๐‘’๐‘–๐‘”โ„Ž๐‘ก ๐‘š๐‘Ž๐‘ก๐‘โ„Ž๐‘–๐‘› ๐‘œ๐‘› ๐‘
2๐‘ค(๐‘€) ≤ ๐‘ค(๐‘€1 ) + ๐‘ค(๐‘€2 ) = ๐‘ค(๐œƒฬ‚) ≤ ๐‘ค(๐œƒ ∗ )
Thightness
TODO: Draw the tightness example
----- end of lesson 4
Exercise 1: [Tree algorithm for TSP]
a) Describe a variant of the algorithm for the TSP path problem
b) Show ratio 2
c) Give a tight “bad” example
๐‘˜-TSP
๐‘˜ salesman with an office located at some city. They can share the load. So we must construct ๐‘˜
different tours (Starting from the home city and ending there as well) that will traverse all cities.
The goal is to minimize the longest tour.
Paths: ๐œƒ1 , … , ๐œƒ๐‘˜ . |๐œƒฬ‚| ≥ |๐œƒ๐‘– |
Minimize ๐œƒ๐‘– .
Heuristics
1. Compute the shortest “ordinary” tour ๐œƒ = ⟨๐‘–1 , ๐‘–2 , … , ๐‘–๐‘› , ๐‘–1 ⟩
2. We would like to identify breakpoints – {๐‘–๐‘1 , … , ๐‘–๐‘๐‘˜−1 }
3. Each agent will start with the city after a breakpoint, and return at the next breakpoint.
TODO: Draw the k-tour drawings
Denote ๐ฟ = |๐œƒ|
And denote: ๐‘‘๐‘š๐‘Ž๐‘ฅ = max {๐‘‘1๐‘– }
2≤i≤n
Choosing the breakpoints:
๐‘—
(๐ฟ − 2๐‘‘๐‘š๐‘Ž๐‘ฅ ) + ๐‘‘๐‘š๐‘Ž๐‘ฅ }
๐‘˜
1
Lemma 1: Each ๐œƒ๐‘— satisfies that |๐œƒ๐‘— | ≤ ๐‘˜ (๐ฟ − 2๐‘‘๐‘š๐‘Ž๐‘ฅ ) + 2๐‘‘๐‘š๐‘Ž๐‘ฅ
๐‘๐‘— = max {1 ≤ ๐‘™ ≤ ๐‘›||๐œƒ[1 → ๐‘–๐‘™ ]| ≤
Proof:
For ๐‘— = 1:
Denote ๐‘’1 as the edge from ๐‘–๐‘1 back to point ๐‘–1
1
๐‘˜
|๐œƒ๐‘˜ |: By choice of ๐‘1 , ๐›ผ ≤ (๐ฟ − 2๐‘‘๐‘š๐‘Ž๐‘ฅ ) + ๐‘‘๐‘š๐‘Ž๐‘ฅ
|๐‘’1 | ≤ ๐‘‘๐‘š๐‘Ž๐‘ฅ
|๐œƒ1 | = ๐›ผ + |๐‘’1 | ≤
1
(๐ฟ − 2๐‘‘๐‘š๐‘Ž๐‘ฅ ) + 2๐‘‘๐‘š๐‘Ž๐‘ฅ
๐‘˜
๐‘– < ๐‘— < ๐‘˜:
Denote
By choice of ๐‘๐‘– ,๐‘๐‘–+1
(*) ๐›ผ + ๐›ฝ >
๐‘—−1
(๐ฟ
๐‘˜
− 2๐‘‘๐‘š๐‘Ž๐‘ฅ ) + ๐‘‘๐‘š๐‘Ž๐‘ฅ
๐‘—
(**) ๐›ผ + ๐›ฝ + ๐›พ ≤ ๐‘˜ (๐ฟ − 2๐‘‘๐‘š๐‘Ž๐‘ฅ ) + ๐‘‘๐‘š๐‘Ž๐‘ฅ
1
(*)+(**) ๐›พ ≤ ๐‘˜ (๐ฟ − 2๐‘‘๐‘š๐‘Ž๐‘ฅ )
|๐œƒ๐‘— | = ๐›พ + |๐‘’1 | + |๐‘’2 | ≤
1
(๐ฟ − 2๐‘‘๐‘š๐‘Ž๐‘ฅ ) + 2๐‘‘๐‘š๐‘Ž๐‘ฅ
๐‘˜
The only case left is ๐‘— = ๐‘˜. Left as an exercise.
1
1
Result 2: |๐œƒฬ‚| ≤ ๐‘˜ + 2 (1 − ๐‘˜) ๐‘‘๐‘š๐‘Ž๐‘ฅ
๐œƒฬ‚ ∗ - The best ๐‘˜ tour
๐œƒ ∗ - the best tour
Lemma 3: |๐œƒ ∗ | ≤ ๐‘˜|๐œƒฬ‚ ∗ |
๐œƒ ∗ ≤ |๐œƒ1∗ ∪ ๐œƒ2∗ ∪ … ∪ ๐œƒ๐‘˜∗ | ≤ ๐‘˜|๐œƒฬ‚ ∗ |
Lemma 4:
|๐œƒฬ‚ ∗ | ≥ 2๐‘‘๐‘š๐‘Ž๐‘ฅ
Lemma 5: If |๐œƒ| ≤ ๐‘Ÿ โˆ™ |๐œƒ ∗ |
1
Then |๐œƒฬ‚| ≤ (๐‘Ÿ + 1 − ) |๐œƒฬ‚ ∗ |
๐‘˜
Proof:
๐ฟ
1
+ 2 (1 − ) ๐‘‘๐‘š๐‘Ž๐‘ฅ
๐‘˜
๐‘…
|๐œƒ ∗ |
1
≤๐‘Ÿโˆ™
+ 2 (1 − ) ๐‘‘๐‘š๐‘Ž๐‘ฅ
๐‘˜
๐‘˜
๐‘˜|๐œƒ ∗ |
1 1
≤๐‘Ÿโˆ™
+ 2 (1 − ) |๐œƒฬ‚ ∗ |
๐‘˜
๐‘˜ 2
1
= ๐‘Ÿ(๐œƒฬ‚ ∗ ) + (1 − ) |๐œƒฬ‚ ∗ |
๐‘˜
|๐œƒฬ‚| ≤
Bottleneck graph problems
๐‘› vertices
๐‘‘๐‘–๐‘— ,
1 ≤ ๐‘–, ๐‘— ≤ ๐‘›
Triangle inequality holds.
๐’Œ-centers problem
๐‘˜-centers – โ„ณ ⊆ ๐‘‰, |๐‘š| = ๐‘˜
๐‘€: {1, … , ๐‘›} → โ„ณ
∀๐‘– , ๐‘€(๐‘–) satisfies ๐‘‘๐‘–,๐‘€(๐‘–) ≤ ๐‘‘๐‘–,๐‘š ∀๐‘š ∈ โ„ณ
๐‘‘(โ„ณ) = max{๐‘‘๐‘–,๐‘€(๐‘–) }
i
Decision Version:
Input: {๐‘‘๐‘–๐‘— }, ๐‘˜, ๐‘‘
Question: Is there โ„ณ of size ๐‘˜ such that ๐‘‘(โ„ณ) ≤ ๐‘‘?
๐‘˜ − ๐ถ๐‘’๐‘›๐‘ก๐‘’๐‘Ÿ๐‘ ๐‘‚๐‘ƒ๐‘‡
Input: {๐‘‘๐‘–๐‘— }, ๐‘˜
Question: Find โ„ณ with minimal ๐‘‘(โ„ณ)
Feasible Solution:
Edge subgraph
๐ป = (๐‘‰, ๐ธ ′ ) with cost max(๐ป) = max′{๐‘‘๐‘–๐‘— }
(i,j)∈E
๐’ข =Collection of feasible subgraphs
Optimal solution: ๐ป ∈ ๐’ข such that max(๐ป) ≤ max(๐ป ′ ) ∀๐ป ′ ∈ ๐’ข
For the ๐‘˜ − ๐ถ๐‘’๐‘›๐‘ก๐‘’๐‘Ÿ๐‘  problem:
๐’ข๐‘˜−๐ถ๐‘‡๐‘… = {๐ป|๐ป = ๐‘˜ ๐‘ ๐‘ก๐‘Ž๐‘Ÿ๐‘  ๐‘ค๐‘–๐‘กโ„Ž ๐‘กโ„Ž๐‘’ ๐‘˜ ๐‘๐‘’๐‘›๐‘ก๐‘’๐‘Ÿ๐‘  ๐‘Ž๐‘  ๐‘Ÿ๐‘œ๐‘œ๐‘ก๐‘ }
โ„ณ = {๐‘š1 , … , ๐‘š๐‘˜ }
Algorithm
๐ธ = {๐‘’1 , ๐‘’2 , … } such that ๐‘‘๐‘’1 ≤ ๐‘‘๐‘’2 ≤ โ‹ฏ ≤ ๐‘‘๐‘’๐‘›(๐‘›−1)
2
๐‘–’th bottleneck graph
๐‘๐‘›(๐‘–) = {๐‘‰, {๐‘’1 , … , ๐‘’๐‘– }}
Algorithm A:
For ๐‘– = 1,2, … do
๐บ๐‘– ← ๐‘๐‘›(๐‘–)
If ๐บ๐‘– contains an edge subgraph ๐ป such that ๐ป ∈ ๐’ข then return ๐ป
Correctness:
๐ป found in ๐‘๐‘›(๐‘–)
max(๐ป) = ๐‘‘๐‘’๐‘–
Power Graphs
For some ๐‘ก ≥ 2, ๐บ = (๐‘‰, ๐ธ)
๐บ ๐‘ก = (๐‘‰, ๐ธ ′ ) such that ๐ธ ′ =
{(๐‘–, ๐‘—)|๐‘กโ„Ž๐‘’๐‘Ÿ๐‘’ ๐‘’๐‘ฅ๐‘–๐‘ ๐‘ก๐‘  ๐‘Ž ๐‘๐‘Ž๐‘กโ„Ž ๐‘œ๐‘“ ๐‘Ž๐‘ก ๐‘š๐‘œ๐‘ ๐‘ก ๐‘ก ๐‘’๐‘‘๐‘”๐‘’๐‘  ๐‘๐‘œ๐‘›๐‘›๐‘’๐‘๐‘ก๐‘–๐‘›๐‘” ๐‘– ๐‘Ž๐‘›๐‘‘ ๐‘— ๐‘–๐‘› ๐บ}
Claim: max(๐บ ๐‘ก ) ≤ ๐‘ก โˆ™ max(๐บ)
Proof: If (๐‘–, ๐‘—) ∈ ๐ธ ′ (๐บ ๐‘ก )
๐‘‘๐‘’๐‘– ≤ max(๐บ)
๐‘‘๐‘–๐‘— ≤ ๐‘ก โˆ™ max(๐บ)
In the “if”
Procedure ๐‘‡๐‘’๐‘ ๐‘ก(๐บ๐‘– , ๐‘ก) returning:
1) Failure
2) Edge subgraph ๐ป of ๐บ๐‘–๐‘ก such that ๐ป ∈ ๐’ข
Algorithm B:
For ๐‘– = 1,2, … do
๐บ๐‘– ← ๐‘๐‘›(๐‘–)
๐‘ฅ ← ๐‘‡๐‘’๐‘ ๐‘ก(๐บ๐‘– , ๐‘ก)
If ≠ ”Failure” then return ๐‘ฅ and halt
Claim 2: If ๐‘‡๐‘’๐‘ ๐‘ก complies with its specifications, then algorithm B has ratio ๐‘ก.
Proof: Suppose the algorithm stopped on iteration ๐‘–. Test returned “failure” for 1, … , ๐‘– − 1
Which means there is no feasible solution using only ๐‘’1 , … , ๐‘’๐‘–−1
⇒ ๐‘‘(โ„ณ ∗ ) > ๐‘‘๐‘’๐‘–−1 ≥ ๐‘‘๐‘’๐‘–
๐ป ∈ ๐บ๐‘–๐‘ก = ๐‘๐‘›(๐‘–)๐‘ก ⇒ ๐‘‘(โ„ณ๐‘Ž๐‘™๐‘” ) ≤ max(๐ป) ≤ ๐‘ก โˆ™ ๐‘‘๐‘’๐‘– โˆŽ
Implementing test for ๐‘˜-center
๐‘ก=2
๐‘‡๐‘’๐‘ ๐‘ก(๐บ, 2):
1. Construct ๐บ 2
2. Find a maximal independent set in ๐บ 2 , โ„ณ
3. If |โ„ณ| > ๐‘˜ then return failure. Else return โ„ณ
Claim: Test satisfies requirements 1+2.
2 is easy.
1 – Suppose that test returns failure while there is an edge subgraph ๐ป in ๐บ such that ๐ป consists
of ๐‘˜ stars spanning ๐‘‰.
But since ๐ป ∈ ๐บ is a list of stars, after you square it you get a list of cliques. If there were at least
๐‘˜ stars, there are at least ๐‘˜ cliques and you can’t find a maximal larger idependent set.
Exercise 3: Give a tight “bad example”.
Exercise 4: Prove that the greedy centers algorithm also yields an approximation ratio of 2.
(and give a tight example)
Lower bound:
If there is a polynomial time approximation algorithm for ๐‘˜ − ๐‘๐‘’๐‘›๐‘ก๐‘’๐‘Ÿ๐‘  (with triangle inequality)
with ratio strictly less than 2, then ๐‘ = ๐‘๐‘ƒ
Proof sketch: Given an algorithm with ratio < 2 define a polynomial time algorithm for
dominating set.
Given ๐บ and ๐‘˜ (where the question is: Is there a dominating set of size at most ๐‘˜?)
1. Create instance of ๐‘˜-centers by setting ๐‘‘๐‘–๐‘— = 1 if edge (๐‘–, ๐‘—) is in the graph and 0
otherwise
Another bottleneck problem:
Bottleneck TSP
Input: {๐‘‘๐‘–๐‘— }
Question: Find a tour ๐œƒ = ⟨๐‘–1 , ๐‘–2 , … , ๐‘–๐‘› , ๐‘–1 ⟩ such that max{๐‘‘๐‘–๐‘™ ,๐‘–๐‘™+1 } is minimized.
l
๐’ข = {๐‘ก๐‘œ๐‘ข๐‘Ÿ๐‘  ๐œƒ ๐‘œ๐‘› ๐‘กโ„Ž๐‘’ ๐‘๐‘–๐‘ก๐‘–๐‘’๐‘ }
๐‘๐‘œ๐‘ ๐‘ก = max(๐œƒ)
Fact 1: Testing if a graph ๐บ is 2 connected is polynomial.
Fact 2: If ๐บ is not 2-connected, then it does not have a Hamiltonian cycle
Fact 3: If ๐บ is 2-connected – ๐บ 2 has a Hamiltonian cycle (which can be constructed in polynomial
time).
--- end of lesson 5
Maximum independent set (MIS)
Input: graph ๐บ of size ๐‘›
Question: Find largest independent set ๐‘€∗
Known: No approximation algorithm with ration ๐‘›1−๐œ–
Best known: Ratio ๐‘› โˆ™
(log log ๐‘›)2
log3 ๐‘›
Algorithm A (Greedy MIS):
๐‘†←∅
While ๐บ ≠ ∅ do
- Pick lowest degree ๐‘ฃ
- ๐‘† ← ๐‘† ∪ {๐‘ฃ}
- Erase {๐‘ฃ } ∪ Γ(๐‘ฃ) from ๐บ
This is not a good algorithm…
Bad example:
TODO: Draw bad example
๐‘›
Lemma 1: If the maximum degree of ๐บ is Δ, then ๐ด will return |๐‘†| ≥ Δ+1
๐‘›
Proof: Each iteration erases at most Δ + 1 vertices from ๐บ ⇒ # of iterations ≥ Δ+1
And # of iterations = |๐‘†|
1
Lemma 2: If ๐œ’(๐บ) = ๐‘˜ (๐บ is ๐‘˜-colorable) then A will find ๐‘† of size |๐‘†| ≥ 2 log k ๐‘›
๐‘›
(๐บ has |๐‘€∗ | ≥ ๐‘˜)
๐‘›
Proof: ๐บ has ๐‘› vertices and ๐œ’(๐บ) = ๐‘˜ ⇒ ∃ colorclas of size ≥ ๐‘˜ ⇒ The lowest degee in ๐บ is at
๐‘›
๐‘˜
๐‘›
๐‘˜
most ๐‘› − ⇒ This iteration will erase at most ๐‘› − + 1 vectices
๐‘›
1
๐‘“(๐‘›) ≥ 1 + ๐‘“ (๐‘˜ − 1) ⇒ ๐‘“(๐‘›) ≥ 2 log k ๐‘›
๐‘›
Algorithm B (Greedy algorithm with ratio log ๐‘›):
Partition ๐‘‰ into ๐‘‰1 , … , ๐‘‰
๐‘›
log ๐‘›
For each ๐บ(๐‘‰๐‘– ) find MIS ๐‘†๐‘–
Return the largest ๐‘†๐‘–
TODO: Draw partitioning of the best empty set
|๐‘€∗ |
๐‘› log ๐‘›
|๐‘€∗ |
๐‘›
≤
|๐‘†๐ต | log ๐‘›
|๐‘†๐ต | ≥
A bad example is the empty set. Instead of taking all the nodes, we just take on of the sets.
Getting ratio
๐‘›(log log ๐‘›)2
log2 ๐‘›
|๐‘€∗ | = ๐‘›/๐พ
TODO: Draw ranges of ๐พ
Case โ€ซ( ืโ€ฌalgorithm A1):
If ๐พ ≥ log 2 ๐‘›
๐‘›
|๐‘€∗ | ≤ 2
log ๐‘›
So we can just return a single vertex.
Case โ€ซ( ื‘โ€ฌalgorithm A2):
log ๐‘›
< ๐พ < log 2 ๐‘›
log log ๐‘›
log ๐‘›
1. ๐‘ก ← log log ๐‘›
๐‘›
2. Partition ๐‘‰ into sets ๐‘‰1 , … , ๐‘‰ of size ๐‘˜๐‘ก
๐พ๐‘ก
3. In each ๐บ๐‘– = ๐บ(๐‘‰๐‘– )
Search for an independent set of size ๐‘ก
4. Return one of them
In ๐‘ƒ because the number of cases:
log ๐‘›
๐พ๐‘ก
( ) ≤ (๐พ๐‘ก)๐‘ก ≤ log 2 ๐‘› = (22๐‘™๐‘œ๐‘” log ๐‘› )log log ๐‘› = 22 log ๐‘› = ๐‘›2
๐‘ก
Claim: ∃๐‘– such that ๐บ๐‘– contains an IS of size ๐‘ก
๐‘›
Proof: |๐‘€∗ | = ๐‘˜
So ∃๐‘– such that
๐‘›⁄
|๐‘€∗ ∩ ๐‘‰๐‘– | ≥ ๐‘› ๐‘˜ = ๐‘ก
⁄๐พ๐‘ก
๐‘›
∗
⁄
|๐‘€ |
๐‘›
๐‘›
๐œŒ≤
≤ ๐‘˜=
=
๐‘ก
๐‘˜๐‘ก
|๐‘†๐ด2 |
log ๐‘› 2
(
)
log log ๐‘›
Case โ€ซื“โ€ฌ:
๐‘›
|๐‘€∗ | =
๐‘˜
๐พ const
Handling graphs without large cliques.
Graphs without triangles:
Algorithm ๐น[3, ๐บ]:
1. If Δ(๐บ) < √๐‘› (Δ is the maximal degree)
then apply greedy algorithm ๐ด
2. Otherwise:
- Pick vertex ๐‘ฃ of degree Δ
- Return ๐‘† = Γ(๐‘ฃ)
Γ(๐‘ฃ) ≥ √๐‘›
So ๐œŒ๐น ≥ √๐‘›
EX: Show that the following is a bad example
TODO: Draw bad example
Graphs with no cliques of size ≥ ๐‘˜:
Algorithm ๐น[๐พ, ๐บ]
๐‘˜ = 2 return ๐‘‰
๐‘˜ = 3: return ๐น[3, ๐บ]
๐‘˜ > 3:
1
If Δ(๐บ) < ๐‘›1−๐‘˜−1 then apply the greedy algorithm ๐ด
Else
1
-
Pick a vertex ๐‘ฃ of maximum degree ๐‘‘(๐‘ฃ) = Δ ≥ ๐‘›1−๐‘˜−1
๐‘† ← ๐น(๐‘˜ − 1, Γ(๐‘ฃ))
Return ๐‘†
What is the ratio of the algorithm?
1
If Δ < ๐‘›1−๐‘˜−1
๐‘›
Greedy finds |๐‘†| ≥ Δ+1 ≥
๐‘›
1
1−
๐‘› ๐‘˜−1
1
= ๐‘›๐‘˜−1
1
If Δ ≥ ๐‘›1−๐‘˜−1
1
๐‘›′ = |Γ(๐‘ฃ)| ≥ ๐‘›1−๐‘˜−1
By the induction hypothesis ๐น(๐‘˜ − 1, Γ(๐‘ฃ)) returns |๐‘ | ≥
|๐‘†| ≥
1
1 ๐‘˜−1
1−
(๐‘› ๐‘˜−1 )
1
1
(๐‘›′ )๐‘˜−1
๐‘˜−1
1
= ๐‘›๐‘˜−1
1
Claim: ๐น returns |๐‘†| ≥ ๐‘ โˆ™ ๐‘›๐‘˜−1
๐‘›
We know |๐‘€∗ | = ๐พ, K constant.
1
|๐‘€∗ | = ( + ๐ธ) ๐‘›
๐‘˜
1
1
1
[๐‘˜ = 2๐พ, ๐œ– = ๐‘˜ ⇒ ๐‘˜ + ๐œ– = ๐พ]
1
๐‘˜
1
Lemma: If |๐‘€∗ | = ( + ๐œ–) ๐‘› then we can find |๐‘†| ≥ (๐œ–๐‘›)๐‘˜−1
We will now describe an algorithm called ๐น๐‘Ÿ๐‘’๐‘’๐‘˜ (๐บ)
While ๐บ ha ๐‘˜ cliques
- Find a clique of size ๐‘˜
- Erase it from the graph
1
Claim: If there is an independent set of size (๐‘˜ + ๐œ–๐‘›) then ๐น๐‘Ÿ๐‘’๐‘’๐‘˜ (๐บ) will leave us with a raph ๐บ ′
without ๐‘˜-cliques, |๐‘ฃ(๐บ ′ )| ≥ ๐œ–๐‘›
Proof: ๐‘ฅ iterations
Erased ๐‘ฅ๐‘˜ vertices
๐‘ฅ๐‘˜ ≤ ๐‘›
๐‘›
๐‘ฅ≤๐‘˜
Each iteration erased at most one ๐‘€∗ vertex
1
This means that at the end, ๐บ ′ still contains at least (๐‘˜ + ๐œ–) ๐‘› − ๐‘ฅ vertices of ๐‘€∗\
1
1
๐‘›
( + ๐œ–) ๐‘› − ๐‘ฅ ≥ ( + ๐œ–) ๐‘› − = ๐œ–๐‘›
๐‘˜
๐‘˜
๐‘˜
|๐‘‰(๐บ ′ )| ≥ ๐œ–๐‘›
A comment that doesn’t help us: Also, ๐บ ′ still has an independent set of size ≥ ๐œ–๐‘›
Algorithm ๐ด4
- Apply ๐น๐‘Ÿ๐‘’๐‘’๐‘˜ (๐บ)
- Apply ๐น(๐‘˜, ๐บ)
Case โ€ซื“โ€ฌ:
|๐‘€∗ |๐‘›
1
= ( + ๐œ–) ๐‘›,
๐‘˜
๐‘˜
⇒ After ๐น๐‘Ÿ๐‘’๐‘’๐‘˜ we have
๐œŒ๐ด4 ≤
1
๐‘›
1
1
( ๐‘›)๐‘˜−1
๐‘˜
=๐‘˜
1
๐‘˜−1
|๐‘‰(๐บ ′ )|
โˆ™๐‘›
1
1−
๐‘˜−1
≥
1
๐‘›
๐‘˜
๐‘˜ = 2๐พ,
⇒ ๐น finds |๐‘†| ≥
๐œ–=
1
1
๐‘˜
1
1−๐‘˜
(๐‘˜ ๐‘› )
๐‘…→∞
๐‘˜ ๐‘˜−1 < 2 → 1
So it’s not just a constant, it’s a small constant.
Cases โ€ซื“โ€ฌ+โ€ซื’โ€ฌ:
Ramsey’s Theorem:
In a graph of ๐‘› vertices
๐‘ +๐‘ก−2
∀๐‘ , ๐‘ก such that ๐‘› ≥ (
), ๐บ must contain either an ๐‘†-clique or a ๐‘ก-independent set.
๐‘ −1
(Can be found in polynomial time)
Algorithm ๐‘…(๐‘ , ๐‘ก, ๐‘‰):
1. If ๐‘† = 0 then return ∅ as clique
If ๐‘ก = 0 return ∅ as IS
2. Pick vertex ๐‘ฃ
๐›พ ← |Γ(๐‘ฃ)|
๐‘ +๐‘ก−3
3. If ๐›พ ≥ (
) then do
๐‘ −2
a. Apply ๐‘…(๐‘  − 1 , ๐‘ก, Γ(๐‘ฃ))
b. If found (๐‘ −, 1)-clique ๐‘†, then return ๐‘† ∪ {๐‘ฃ}
c. If found ๐‘ก-IS ๐‘‡, then return it
4. Else
a. ๐‘ ← ๐‘‰\({0} ∪ Γ(๐‘ฃ))
๐‘ +๐‘ก−3
)]
[|๐‘| ≥ (
๐‘ −1
b. Apply ๐‘…(๐‘ , ๐‘ก − 1, ๐‘)
c. If found ๐‘†-clique return it
d. If found ๐‘ก − 1 independent set return ๐‘‡ ∪ {๐‘ฃ}
To prove the algorithm works, we must show inductively that the different options are correct.
Ex: Prove correctness of ๐‘… and of theorem.
2
Corolary: ∀๐‘ ≥ 1 constant, ∀๐บ of size ๐‘› [๐‘œ๐‘› ≥ ๐‘›3 ]
log ๐‘›
๐บ contains either a clique of size ≥ 2๐‘ log log ๐‘› or an IS of size ≥ ๐‘ก = log c ๐‘›
Algorithm ๐ด3+4
๐‘›
ฬ‚ = log ๐‘› ]
[|๐‘€∗ | = ๐‘˜ for ๐พ < ๐พ
๐‘ log log ๐‘›
log ๐‘›
ฬ‚=
0. ๐พ ← 2๐พ
๐‘ log log ๐‘›
1. Apply ๐‘…(๐‘ , ๐‘ก, ๐‘‰) with ๐‘  = ๐‘˜, ๐‘ก = log c ๐‘›
(take ๐‘ = 2)
2. If found an IS o size ๐‘ก return it
3. If found clique of size ๐‘†, erase it from ๐บ and goto(1)
--- end of lesson 6
Coloring
Theorem: If there exists an approximation algorithm for ๐‘€๐ผ๐‘† with ratio ๐œŒ(๐‘›) [non-decreasing]
then there exists an approximation for coloring with ratio ๐œŒ(๐‘›) โˆ™ log ๐‘›.
๐‘›
We can even say something stronger. If ๐œŒ(๐‘›) ≈ logα ๐‘› then the coloring has ratio 3๐œŒ(๐‘›) or
something like that.
๐‘›
Proof: Assume we have an algorithm ๐ด for ๐‘€๐ผ๐‘† with ratio ~ logα ๐‘›
Algorithm ๐ต for coloring:
1. ๐‘– ← 1
๐‘›
2. While |๐‘‰| ≥ logα ๐‘› do
a. Invoke algorithm ๐ด, get independent set ๐ผ
b. Color ๐ผ vertices by ๐‘–
c. Discard ๐ผ vertices by ๐‘–
d. Discard ๐ผ vertices of their edges from ๐บ
e. ๐‘– ← ๐‘– + 1
3. Color each remaining vertex with a new color
Lemma 1: Algorithm ๐ด uses ≤
3๐‘›
๐œ’
logα ๐‘›
colors (where ๐œ’ = chromatic number of the graph).
Proof: Suppose that there were m iterations. So we used ๐‘š colors in the WHILE loop. And the
number of colors at line 3 was ๐‘š′
๐‘›
๐‘›
We know that: ๐‘š′ < logα ๐‘› ≤ logα ๐‘› ๐œ’
Remains to show ๐‘š ≤
2๐‘›
๐œ’
logα ๐‘›
∀๐‘–
๐‘‰๐‘– = iteration set at the beginning of stage ๐‘–
๐บ๐‘– - graph at that stage
๐‘›๐‘– = |๐‘‰๐‘– |
๐ผ๐‘– – independent set colored at that stage
๐œ’๐‘– – chromatic number at that stage
๐ผ๐‘–∗ - maximal independent set of ๐บ๐‘–
Claim 2: |๐ผ๐‘–∗ | ≥
๐‘›๐‘–
๐œ’
Proof: The chromatic number of a subset of the graph is smaller of equals to the chromatic
number of the original graph. There exists a subset ๐‘† ⊂ ๐‘‰๐‘– such that ๐‘† is independent and
๐‘›๐‘– ๐‘›๐‘–
|๐ผ๐‘–∗ | ≥ |๐‘†| ≥ ≥
๐œ’๐‘–
๐œ’
Corollary: |๐ผ๐‘– | ≥
logα ๐‘›
2๐œ’
Proof: From approximation ratio of ๐ด:
|๐ผ๐‘–∗ |
|๐ผ๐‘– |
≤ ๐œŒ(๐‘›๐‘– )
(*)
1
For sufficiently large ๐‘›: log α ๐‘›๐‘– ≥ 2 log α ๐‘›
๐‘›
because ๐‘›๐‘– ≥ logα ๐‘›. Why?
1
log α ๐‘›
2
1
log ๐‘› − ๐›ผ log log ๐‘› ≥ 2๐›ผ log ๐‘› for sufficiently large ๐‘›
log α ๐‘›๐‘– ≥ (log ๐‘› − ๐›ผ log log ๐‘›)๐›ผ ≥
๐œŒ(๐‘›๐‘– ) ≤
๐‘›๐‘–
๐‘›
≤
α
log ๐‘› log α ๐‘›
|๐ผ๐‘–∗ |
|๐ผ๐‘– | =
๐œŒ(๐‘›๐‘– )
๐‘๐‘ฆ (∗)
๐‘๐‘™๐‘Ž๐‘–๐‘š 2
(∗)
≥
๐‘›๐‘–
⁄๐œ’
๐‘›๐‘–
⁄1 α
2 log ๐‘›
๐‘›1 = ๐‘›
๐‘›๐‘–+1 = ๐‘›๐‘– − |๐ผ๐‘– | ≤ ๐‘›๐‘– −
≥
log α ๐‘›
2๐œ’
log α ๐‘›
2๐œ’
After ๐‘š − 1 iterations
α
log ๐‘›
2๐œ’
๐‘“๐‘œ๐‘Ÿ ๐‘™๐‘Ž๐‘Ÿ๐‘”๐‘’
๐‘’๐‘›๐‘œ๐‘ข๐‘”โ„Ž ๐‘›
≤
๐‘›
log α ๐‘›
(๐‘š
≤
๐‘›
≤
๐‘›
−
−
1)
๐‘š−1
log α ๐‘›
2๐œ’
log α ๐‘›
2๐‘›
๐‘š
≤ ๐‘›,
๐‘š≤
โˆ™๐œ’
2๐œ’
log α ๐‘›
Algorithm DEG
Δ = max degree of ๐บ
Color set {1, … , Δ + 1}
Consider 3-Colorable ๐บ.
TODO: Draw set of neighbors of ๐‘ฃ – Γ(๐‘ฃ)
Observation 1: ∀๐‘ฃ. ๐บ(Γ(๐‘ฃ)) is bipartite(≡ 2 colorable).
Algorithm ๐ด:
a. ๐‘– ← 1
b. While Δ(๐บ) ≥ √๐‘› do
(1) Pick max degree ๐‘ฃ ∈ ๐บ
(2) Color ๐‘ฃ by ๐‘– + 2
(3) Color the vertices of Γ(๐‘ฃ) by colors ๐‘–, ๐‘– + 1
(4) Discard {๐‘ฃ} ∪ Γ(๐‘ฃ) from ๐บ (and their edges)
(5) ๐‘– ← ๐‘– + 2
c. Color the remaining ๐บ using algorithm ๐ท๐ธ๐บ.
Note:
(1) Step ๐‘ uses at most √๐‘› colors
(2) Step ๐‘3 is polynomial
(3) 2 colors per iteration
(4) # iterations ≤ √๐‘›
๐œ’๐ด ≤ 2
โŸ๐‘› ≤ 3√๐‘›
โŸโˆ™ √๐‘› + √
๐‘
๐‘
๐‘›
Slight improvement: ๐‘‚ (√log ๐‘›) colors. (there are ways to color a graph in ๐‘›0.39 )
๐‘›
1. While Δ (๐บ) ≥ √log ๐‘› do
a. ๐บ ′ ← ๐บ
๐‘†←∅
b. While ๐บ ′ ≠ ∅ and |๐‘†| < log ๐‘› do
i. Pick max degree vertex ๐‘ฃ
ii. ๐‘† ← ๐‘† ∪ {๐‘ฃ}
iii. Discard from ๐บ ′ {๐‘ฃ} ∪ Γ(๐‘ฃ)
c. Examine every ๐‘Š ⊆ ๐‘†, pick largest ๐‘ค ⊆ ๐‘† such that Γ(๐‘Š) (=โ‹ƒ๐‘ข∈๐‘Š Γ(๐‘ค)) is
bipartite
d. Discard from ๐บ the vertices ๐‘Š ∪ Γ(๐‘Š)
e. Color ๐‘Š by a new color and Γ(๐‘Š) by two new colors.
2. Apply DEG to the remaining vertices
We can always find a set ๐‘Š ⊂ ๐‘† such that |๐‘Š| ≥
log ๐‘›
3
such that Γ(๐‘Š) is bipartite.
Claim:
๐‘›
(1) Step 2 uses ≤ √log ๐‘› colors
(2) Step 1 has ๐‘š iterations, ๐‘š ≤
3๐‘›
√๐‘›๐‘™๐‘œ๐‘” ๐‘›
1
๐‘›
= 3√log ๐‘›
(3) Each iteration colors at least ≥ ≥ 3 √๐‘›๐‘™๐‘œ๐‘” ๐‘› vertices
(4) Algorithm is in ๐‘ƒ (the only suspicious step is c, and it’s OK because ๐‘† is logarithmic.
|๐‘Š| ≥
log ๐‘›
,
3
๐‘›
1
Γ(๐‘Š) ≥ |๐‘Š| โˆ™ √
≥ √๐‘›๐‘™๐‘œ๐‘” ๐‘›
log ๐‘› 3
Exercise: Consider the following problem:
Input: ๐บ(๐‘‰, ๐ธ) |๐‘‰| = ๐‘›
๐œ’(๐บ) = 3
๐‘Š ⊂ ๐‘‰, |๐‘Š| ≤ log ๐‘›
Known; ๐‘Š is independent and dominating
Question: Color ๐บ with ๐‘‚(log log ๐‘›) colors.
Greedy Algorithm
Set Cover/Hitting Set
Input: Universe ๐ผ = {1, … , ๐‘š}
Subsets ๐‘ƒ1 , … , ๐‘ƒ๐‘› ∀๐‘–. ๐‘ƒ๐‘– ⊆ ๐ผ
SC: Collection of subsets.
๐‘† ⊆ ๐ฝ = {1, … , ๐‘›}, such that โ‹ƒ๐›พ∈๐‘† ๐‘ƒ๐›พ = ๐ผ
HS: Subset ๐‘… ⊆ ๐ผ such that ๐‘… ∩ ๐‘ƒ๐‘– ≠ ∅ ∀๐‘–
TODO: Draw matching between ๐ผ and ๐ฝ
So actually the question can be reduced to finding a dominating set in a bipartite graph (where
elements are on the left, sets are on the right, and you have an edge if the element is in the set).
The weighted version has weights on the edges and we are looking for the cheapest cover.
Greedy Algorithm for weighted set cover:
๐‘†←∅
While ๐ผ ≠ ∅ do
Find ๐‘˜ such that
๐‘ƒ๐‘˜
๐‘˜
is minimal
๐‘† ← ๐‘† ∪ {๐‘˜}
Discard the elements of ๐‘ƒ๐‘˜ from ๐ผ and from all their sets.
A tight bad example:
๐ผ = {1, … , ๐‘š}
๐ฝ = {1, … , ๐‘š + 1}
1
๐ถ๐‘— = ,
๐‘ƒ๐‘— = {๐‘—},
๐‘—
๐‘ƒ๐‘š+1 = ๐ผ
๐ถ๐‘š+1 = 1 + ๐œ–
1≤๐‘—≤๐‘š
By the greedy selection, we will pick: ๐‘๐‘š , ๐‘๐‘š−1 , … , ๐‘1 in the first ๐‘š step.
1
1
1
๐ถ๐‘Ž๐‘™๐‘” = +
+. . + = ๐ป(๐‘š)~ log ๐‘š
๐‘š ๐‘š−1
1
๐ถ ∗ = ๐‘๐‘š+1 = 1 + ๐œ–
Tight bad example for the unwaited case:
TODO: Draw a picture of the universe
--- end of lesson 7
Greedy Algorithms – Framework
๐‘ˆ = {๐‘ข1 , … , ๐‘ข๐‘› } universe.
Solution ๐‘† ⊆ ๐‘ˆ.
Cost of ๐‘ข๐‘– = ๐‘๐‘–
๐‘(๐‘†) = ∑ ๐‘๐‘–
๐‘ข๐‘– ∈๐‘†
Constraints → feasability
Goal: Lowest cost feasible ๐‘†.
Penalty: ๐‘ƒ: 2๐‘ˆ → โ„ค+ ∪ {0}
๐‘† feasible ⇔ ๐‘ƒ(๐‘†) = 0
Requirements:
(A1) Penalty monotonicity – ๐‘†1 ⊆ ๐‘†2 ⇒ ๐‘ƒ(๐‘†1 ) ≥ ๐‘ƒ(๐‘†2 )
To choose elements greedily – Δ(๐‘†, ๐‘ข) = ๐‘ƒ(๐‘†) − ๐‘ƒ(๐‘† ∪ {๐‘ข})
(2) While ๐‘ƒ(๐‘†) > 0 do
a) Choose ๐‘ข maximizing the ratio:
Δ(๐‘†,๐‘ข๐‘– )
๐‘๐‘–
b) ๐‘† ← ๐‘† ∪ {๐‘ข๐‘– }
(A3) polinomiality:
Computing ๐‘ƒ(๐‘†) is polynomial.
ฬƒ(๐‘†, ๐‘ข)
Exercise: Suppose computing Δ is NP hard, but you can, in polynomial time compute Δ
ฬƒ(๐‘†, ๐‘ข) ≤ 1 Δ(๐‘†, ๐‘ข)
such that ๐œ–Δ(๐‘†, ๐‘ข) ≤ Δ
๐œ–
Suppose we are looking now at ๐‘†. And suppose ๐‘† ∗ is the optimal set.
๐‘†ฬ… = ๐‘† ∗ \๐‘† “missing”
Currently Δ(๐‘†, ๐‘†ฬ…) = ๐‘ƒ(๐‘†) − ๐‘ƒ(๐‘†
โŸ ∪ ๐‘†ฬ…) = ๐‘ƒ(๐‘†)
=0
(A2) ∑๐‘ข๐‘–∈๐‘†ฬ… Δ(๐‘†, ๐‘ข๐‘– ) ≥ ๐‘ƒ(๐‘†)
๐‘ ∗ = ๐‘(๐‘† ∗ )
∀๐‘† such that ๐‘ƒ(๐‘†) > 0, denote by ๐‘ข(๐‘†) = element added by the greedy algorithm.
Claim 1:
Δ(๐‘†, ๐‘ข(๐‘†)) ๐‘ƒ(๐‘†)
≥ ∗
๐‘๐‘ข(๐‘ )
๐‘
๐‘†ฬ… = ๐‘† ∗ \๐‘† = {๐‘ข1 , … , ๐‘ข๐‘–๐‘™ }
๐‘™
(∗) ∑ Δ (๐‘†, ๐‘ข๐‘–๐‘— ) ≥ ๐‘ƒ(๐‘†)
๐‘—=1
(∗∗)๐‘(๐‘† ∗ ) = ๐‘ ∗ ≥ ๐‘(๐‘†ฬ…)
(๐ด2)
∑๐‘™๐‘—=1 Δ (๐‘†, ๐‘ข๐‘–๐‘— )
∑๐‘™๐‘—=1 Δ(๐‘†, ๐‘ข๐‘–๐‘™ ) (∗∗) ๐‘ƒ(๐‘†)
Δ(๐‘†, ๐‘ข(๐‘†))
≥
=
≥
๐‘๐‘ข(๐‘†)
๐‘∗
๐‘(๐‘†ฬ…)
∑๐‘™๐‘—=1 ๐‘ (๐‘ข๐‘–๐‘— )
We know that:
Δ(๐‘†, ๐‘ข(๐‘†)) Δ (๐‘†, ๐‘ข๐‘–๐‘— )
≥
๐‘๐‘ข(๐‘†)
๐‘ (๐‘ข )
๐‘–๐‘—
(Because if ∀๐‘— ๐‘‹ ≥
(∗∗∗) ๐‘(๐‘ข(๐‘ )) ≤
๐‘Ž๐‘–
๐‘๐‘—
∑๐‘Ž
⇒ ๐‘‹ ≥ ∑ ๐‘๐‘–)
๐‘—
๐‘ ∗ โˆ™ Δ(๐‘†, ๐‘ข(๐‘†))
๐‘ƒ(๐‘†)
Denote by ๐‘๐‘” = cost of the solution chosen by the greedy algorithm
Claim 2: ๐‘๐‘” ≤ ๐ป(๐‘(∅)) โˆ™ ๐‘ ∗ \
1
2
1
3
Where ๐ป(๐‘š) = 1 + + + โ‹ฏ +
1
๐‘š
≈ ln ๐‘š
Proof: ๐‘ข1 , ๐‘ข2 , … , ๐‘ข๐‘š are added to the solution by the greedy algorithm in the order which it
added them. Their cost: ๐‘1 , … , ๐‘๐‘š .
Δ1 , … , Δ๐‘š and ๐‘ƒ1 , … , ๐‘ƒ๐‘š (penalty before iteration ๐‘–)
๐‘ƒ(∅) = ๐‘ƒ1
๐‘ƒ๐‘–+1 = ๐‘ƒ๐‘– − Δ๐‘–
๐‘ƒ๐‘š+1 = 0
๐‘š
๐‘๐‘” = ∑ ๐‘๐‘–
๐‘–=1
๐‘š
๐‘š
๐‘š
๐‘š
๐‘–=1
๐‘–=1
๐‘–=1
๐‘ƒ๐‘š+1 +1
๐‘ ∗ โˆ™ Δ๐‘–
Δ๐‘–
1
1
1
≤ ∑
= ๐‘∗ โˆ™ ∑ ≤ ๐‘∗ โˆ™ ∑ ( +
+ โ‹ฏ+
)=
๐‘ƒ๐‘–
๐‘ƒ๐‘–
๐‘ƒ๐‘– ๐‘ƒ๐‘– − 1
๐‘ƒ๐‘– − Δ๐‘– + 1
(∗∗∗)
1
1
1
1
๐‘∗ โˆ™ ∑ ( +
+โ‹ฏ+
) = ๐‘∗ โˆ™ ∑
= ๐‘ ∗ โˆ™ ๐ป(๐‘ƒ1 ) = ๐‘ ∗ โˆ™ ๐ป(๐‘ƒ(∅)) โˆŽ
๐‘ƒ๐‘– ๐‘ƒ๐‘– − 1
๐‘ƒ๐‘–+1 + 1
๐‘—
๐‘–=1
๐‘—=๐‘ƒ1
Stronger (but more convenient) version of (A2)
(A2’) ∀๐‘ข, ๐‘†1 , ๐‘†2 . ๐‘†1 ⊆ ๐‘†2 ⇒ Δ(๐‘†1 , ๐‘ข) ≥ Δ(๐‘†2 , ๐‘ข)
Claim 3: (๐ด2′ ) ⇒ (๐ด2) Exercise – prove!
Example: Set-Cover.
๐‘ˆ = {1, … , ๐‘›} corresponding to sets ๐‘†1 , … , ๐‘†๐‘› ⊆ ๐ผ
Constraints:
๐ผ = {1, … , ๐‘š}
Feasible solution: ๐‘… ⊂ ๐‘ˆ such that โ‹ƒ๐‘–∈๐‘… ๐‘†๐‘– = ๐ผ
We would like to minimize the cost of ๐‘… such that ๐‘… is feasible.
1. Define penalty:
๐‘ƒ(๐‘…) = # elements f ๐ผ not in โ‹ƒ๐‘–∈๐‘… ๐‘†๐‘– = |๐ผ\ โ‹ƒ๐‘–∈๐‘… ๐‘†๐‘– |
๐‘ƒ(∅) = ๐‘š, ๐‘ƒ(๐‘ˆ) = 0 assuming โ‹ƒ๐‘–∈๐‘… ๐‘†๐‘– = ๐ผ
(A1) V
(A3) V
(A’2)
Suppose we have ๐‘…1 = {๐‘†๐‘–1 , … , ๐‘†๐‘–๐‘™ } adding ๐‘†๐‘— reduces ๐‘ƒ by ๐‘…
Then for ๐‘…1 ⊇ ๐‘…1
๐‘…2 = {๐‘†๐‘–1 , … , ๐‘†๐‘–๐‘™ , ๐‘†๐‘–๐‘™ +1 , … , ๐‘†๐‘–๐‘˜ }
Adding ๐‘†๐‘— to ๐‘…2 will reduce ๐‘ƒ by at most ๐‘˜
Exercise: prove formally!
Example:
K-Set cover
Choose min0cost collection of sets (from ๐‘†1 , … , ๐‘†๐‘› ) such that each element ๐‘– ∈ ๐ผ appears in at
least ๐‘˜ sets.
Exercise: Choose ๐‘ƒ. Show A1,A2’,A3
Min test-set:
๐ผ = {1, … , ๐‘š}
๐‘†1 , … , ๐‘†๐‘› and choose ๐‘… ⊂ {1, … , ๐‘›} such that for every 2 elements: ๐‘–, ๐‘— ∈ ๐ผ there is ๐‘˜ ∈ ๐‘… such
that ๐‘†๐‘˜ contains exactly one of ๐‘– add ๐‘—.
Some centers problem:
Input: ๐บ(๐‘‰, ๐ธ), distances ๐‘‘(๐‘ข, ๐‘ฃ) ∈ โ„ค+
๐œ‘: ๐‘‰ → โ„ค+ demand vertex ๐‘ฃ needs ๐œ‘(๐‘ฃ) units.
Cost of opening a facility in ๐‘ฃ๐‘– = ๐‘๐‘–
Solution = ๐‘Š ⊂ ๐‘‰ where facilities are opened.
๐‘(๐‘Š) = ∑ ๐‘๐‘–
๐‘ฃ๐‘– ∈๐‘Š
Goal: pick min-cost ๐‘Š such that ∀ client ๐‘ฃ, ๐œ‘(๐‘ฃ) โˆ™ ๐‘‘๐‘–๐‘ ๐‘ก(๐‘ฃ, ๐‘›๐‘’๐‘Ž๐‘Ÿ(๐‘Š, ๐‘ฃ)) ≤ ๐œŒ
HittingSet problem:
๐‘ˆ = {๐‘ข1 , … , ๐‘ข๐‘š },
๐’ฎ = {๐‘†1 , … , ๐‘†๐‘› }
Solution: ๐‘† ⊂ ๐‘ˆ
๐‘† hits ๐‘†๐‘– if ๐‘† ∩ ๐‘†๐‘– ≠ ∅
Feasible solution: hits every ๐‘†๐‘–
Dual-HittingSet problem:
Input: ๐‘ˆ, ๐’ฎ, ๐‘
Goal: Select ๐‘† ⊂ ๐‘ˆ, |๐‘†| = ๐‘
Maximize the number of sets hit.
The optimum: |๐‘† ∗ | = ๐‘ = {๐‘ข1∗ , … , ๐‘ข๐‘∗ } hitting ๐‘‹ sets of ๐’ฎ. ๐’ฎ ∗ ⊂ ๐’ฎ = sets hit by ๐‘† ∗. |๐’ฎ ∗ | = ๐‘‹
1
⇒ greedy yields |๐’ฎ๐‘” | = ๐‘ hitting at least ≥ (1 − ๐‘’) โˆ™ ๐‘‹
1
2
But we will only show it hits ≥ ๐‘‹
Greedy chooses:
๐‘ฅ
๐‘ข1 ∃๐‘ข๐‘–∗ hitting ≥ ๐‘ sets. Gains ๐‘”1 hits.
๐‘ฅ
๐‘”1 ≥
๐‘
|๐’ฎ ∗ | = ๐‘‹
๐’ฎ2∗ = ๐’ฎ ∗ \{sets hit by ๐‘ข1 }
|๐’ฎ2∗ | ≥ ๐‘‹ − ๐‘”1
∃๐‘ข๐‘–∗ hitting ≥
(๐‘‹−๐‘”1 )
๐‘
sets of ๐’ฎ2∗
๐‘ข2 gains ๐‘”2 hits
(๐‘ฅ − ๐‘”1 )
๐‘”2 ≥
๐‘
…
๐‘ข๐‘– gains ๐‘”๐‘– ≥
๐‘‹−๐‘”1 −๐‘”2 ,…,๐‘”๐‘–−1
๐‘
๐‘ โˆ™ ๐‘”1 ≥ ๐‘‹
๐‘ โˆ™ ๐‘”2 + ๐‘”1 ≥ ๐‘‹
๐‘๐‘”๐‘ + ๐‘”๐‘−1 + ๐‘”๐‘−2 + โ‹ฏ + ๐‘”1 ≥ ๐‘‹
Hitting ๐‘”1 + ๐‘”2 + โ‹ฏ + ๐‘”๐‘
But we will not show it!
Instead we will show:
๐‘ โ„Ž๐‘œ๐‘ข๐‘™๐‘‘ ๐‘๐‘’
≥
1
(1 − ๐‘’) ๐‘‹
๐‘๐‘”๐‘ + (๐‘ + 1)๐‘”๐‘−1 + โ‹ฏ + (2๐‘ƒ − 2)๐‘”2 + (2๐‘ƒ − 1)๐‘”1 ≥ ๐‘ โˆ™ ๐‘‹
(2๐‘ƒ − 1)(๐‘”๐‘ + ๐‘”๐‘−1 + โ‹ฏ + ๐‘”2 + ๐‘”1 ) ≥ ๐‘ โˆ™ ๐‘‹
๐‘
๐‘‹๐‘”๐‘Ÿ๐‘’๐‘’๐‘‘๐‘ฆ = ∑ ๐‘”๐‘– ≥
๐‘–=1
๐‘
๐‘‹
๐‘‹≥
2๐‘ƒ − 1
2
Comment 1: The bound is tight (there are examples).
Conclude: OPT needs more than ๐‘˜ − 1 elements to hit all sets
--- end of lesson
Hit-all Algorithm
Vertex cover.
Input: Algorithm ๐บ(๐‘‰, ๐ธ)
Question: Find the smallest set of vertices ๐ถ such that every edge is touched.
๐ถ←∅
While ๐ธ ≠ ∅ do
Pick ๐‘’ = ⟨๐‘ข, ๐‘ฃ⟩ ∈ ๐ธ
๐ถ ← ๐ถ ∪ {๐‘ข, ๐‘ฃ}
Discard from ๐ธ all “touched” edges
If we were to solve it using a greedy algorithm:
๐‘ƒ(∅) = |๐ธ|
Ratio ≤ ln|๐ธ| ≤ 2 ln ๐‘›
Bad example for a greedy algorithm:
TODO: Draw bad example for a greedy algorithm
Back to the hit-all algorithm
Suppose we chose ๐‘€ = {๐‘’1 , . . , ๐‘’๐‘š } edges considered by the algorithm.
๐‘€ =maximal matching
๐ถ๐‘Ž๐‘™๐‘” = 2๐‘€
๐ถ∗ ≥ ๐‘€
Set Cover
๐‘ˆ = {1, … , ๐‘š},
๐‘†1 , … , ๐‘†๐‘›
deg(๐‘–) = # sets ๐‘†๐‘— such that ๐‘– ∈ ๐‘†๐‘–
Δ(๐’ฎ) = max{deg(๐‘–)}
i
Exercise: Hit-all algorithm has approximation ratio Δ.
Greedy algorithm to weighted set cover
๐ถ1 , … , ๐ถ๐‘›
๐ถ๐‘– - the cost of using ๐‘†๐‘–
The greedy algorithm does the following:
1. ๐ผ ← ∅
2. While ๐‘ˆ ≠ ∅ do
๐ถ
a. Find ๐‘– such that |๐‘†๐‘–| is minimum
๐‘–
b. ๐ผ ← ๐ผ ∪ {๐‘–}
c. Discard from ๐ผ and every remaining ๐‘†๐‘–′ the element ๐‘Ž ∈ ๐‘†๐‘–
Theorem: Approximation ≤ ln ๐‘š
Proof: ๐‘ž = max{|๐‘†๐‘– |}
๐œŒ๐‘”๐‘Ÿ๐‘’๐‘’๐‘‘๐‘ฆ = ๐ป(๐‘ž)
Representing ๐‘Š๐‘†๐ถ as an integer linear program
Linear Programming
{๐‘ฅ1 , … , ๐‘ฅ๐‘› }
Minimize ∑๐‘›๐‘–=1 ๐‘๐‘– ๐‘ฅ๐‘–
Subject to:
๐‘Ž11 ๐‘ฅ1 + โ‹ฏ + ๐‘Ž1๐‘› ๐‘ฅ๐‘› ≥ ๐‘1
โ‹ฎ
๐‘Ž๐‘š1 ๐‘ฅ1 + โ‹ฏ + ๐‘Ž๐‘š๐‘› ๐‘ฅ๐‘› ≥ ๐‘๐‘š
Or: min ๐‘ฬ…๐‘ฅฬ… such that ๐ด๐‘ฅฬ… ≥ ๐‘ฬ…
๐‘ฅ๐‘– ≥ 0
In our case, ๐‘ฅ๐‘– ∈ {0,1}
We want to choose a subset of the set ๐‘†1 , … , ๐‘†๐‘› so the variables will be ๐‘ฅ1 , … , ๐‘ฅ๐‘› and their
intended interpretation will be that ๐‘ฅ1 should get the value of 1 if set ๐‘ 1 is selected to the cover,
and 0 otherwise.
1,
๐‘†๐‘– ๐‘ ๐‘’๐‘™๐‘’๐‘๐‘ก๐‘’๐‘‘ ๐‘ก๐‘œ ๐‘กโ„Ž๐‘’ ๐‘๐‘œ๐‘ฃ๐‘’๐‘Ÿ
๐‘ฅ๐‘– ← {
0,
๐‘œ๐‘กโ„Ž๐‘’๐‘Ÿ๐‘ค๐‘–๐‘ ๐‘’
Minimize ∑๐‘›๐‘–=1 ๐‘ฅ๐‘– ๐‘๐‘–
Such that ∀๐‘— ∈ ๐‘ˆ (๐‘– ≤ ๐‘— ≤ ๐‘š). ∑๐‘†๐‘–∋๐‘— ๐‘ฅ๐‘– ≥ 1
Since we need integer linear programming, the problem is NP hard!
This is what we call a primal linear program.
Dual Linear Programming
{๐‘ฆ1 , … , ๐‘ฆ๐‘š }
The dual would be to maximize ∑๐‘— ๐‘๐‘– ๐‘ฆ๐‘– subject to ๐ด๐‘‡ ๐‘ฆฬ… ≤ ๐‘ฬ….
Refer to ๐‘ฅฬ… , ๐‘ฆฬ… feasible solutions if they satisfy their constraints (respectively).
And denote by ๐‘ฅฬ‚, ๐‘ฆฬ‚ the optimal solutions to the primal and the dual (respectively).
Weak LP-Duality Theorem
If ๐‘ฅฬ… is feasible for the primal LP, and ๐‘ฆฬ… is feasible for the dual LP, then:
๐‘ฬ…๐‘ฅฬ… ≥ ๐‘ฬ…๐‘ฆฬ…
Proof:
๐‘›
๐‘ฬ…๐‘ฅฬ… = ∑ ๐‘๐‘— ๐‘ฅ๐‘—
๐‘๐‘ฆ ๐‘กโ„Ž๐‘’ ๐‘‘๐‘ข๐‘Ž๐‘™ ๐‘›
๐‘๐‘œ๐‘›๐‘ ๐‘ก๐‘Ÿ๐‘Ž๐‘–๐‘›๐‘ก
≥
๐‘—=1
๐‘š
๐‘š
๐‘›
∑ (∑ ๐‘Ž๐‘–๐‘— ๐‘ฆ๐‘– ) ๐‘ฅ๐‘— = ∑ (∑ ๐‘Ž๐‘–๐‘— ๐‘ฅ๐‘— ) ๐‘ฆ๐‘–
๐‘—=1
๐‘–=1
๐‘–=1
๐‘๐‘ฆ ๐‘กโ„Ž๐‘’ ๐‘๐‘Ÿ๐‘–๐‘š๐‘Ž๐‘™ ๐‘š
๐‘๐‘œ๐‘›๐‘ ๐‘ก๐‘Ÿ๐‘Ž๐‘–๐‘›๐‘ก๐‘ 
≥
๐‘—=1
∑ ๐‘๐‘– ๐‘ฆ๐‘– = ๐‘ฬ…๐‘ฆฬ…
๐‘–=1
The (not weak) LP duality theorem is: ๐‘ฬ…๐‘ฅฬ‚ = ๐‘ฬ…๐‘ฆฬ‚
Cost Decomposition
Suppose that in iteration ๐‘ก of the greedy algorithm, it chose some set denoted ๐‘†๐‘–๐‘ก .
๐พ๐‘ก = {๐‘—|๐‘— ๐‘–๐‘  ๐‘ ๐‘ก๐‘–๐‘™๐‘™ ๐‘–๐‘› ๐‘†๐‘–๐‘ก ๐‘Ž๐‘ก ๐‘–๐‘ก๐‘’๐‘Ÿ๐‘Ž๐‘ก๐‘–๐‘œ๐‘› ๐‘ก}
For every ๐‘— ∈ ๐พ๐‘ก :
๐‘๐‘–
๐‘ƒ๐‘Ÿ๐‘–๐‘๐‘’(๐‘—) = ๐‘ก
๐พ๐‘ก
๐ถ๐‘”๐‘Ÿ๐‘’๐‘’๐‘‘๐‘ฆ = ∑ ∑ ๐‘๐‘Ÿ๐‘–๐‘๐‘’(๐‘—) = ∑ ๐‘๐‘–๐‘ก =
๐‘ก ๐‘—∈๐พ๐‘ก
๐‘ก
Guessing a solution for the dual-weighted set cover.
Dual Weighted Set Cover
max ∑๐‘š
๐‘—=1 ๐‘ฆ๐‘— such that ∑ ๐‘—∈๐‘†๐‘— ๐‘ฆ๐‘— ≤ ๐‘๐‘– ∀1 ≤ ๐‘– ≤ ๐‘›
๐‘ฆ๐‘— ≥0
Guessed ๐‘ฆฬ…
๐‘๐‘Ÿ๐‘–๐‘๐‘’(๐‘—)
๐‘ฆ๐‘— =
๐ป(๐‘ž)
(for ๐‘ž = max|๐‘†๐‘– |)
Claim: ๐‘ฆฬ… is a feasible solution for dual-weighted set cover.
Proof: Need to show that ∀๐‘–, ∑๐‘—∈๐‘†๐‘–
๐‘๐‘Ÿ๐‘–๐‘๐‘’(๐‘—)
๐ป(๐‘ž)
≤ ๐‘๐‘– or ∑๐‘—∈๐‘†๐‘– ๐‘๐‘Ÿ๐‘–๐‘๐‘’(๐‘—) ≤ ๐‘๐‘– โˆ™ ๐ป(๐‘ž)
๐‘†๐‘– = {๐‘—1 , … , ๐‘—๐‘˜ } ordered by the ordering the greedy algorithm covered them. If two elements are
covered in the same iteration, we don’t care about the ordering.
Suppose ๐‘—๐‘™ was covered in iteration ๐‘ก (by ๐‘†๐‘–๐‘ก )
๐‘๐‘–
๐‘๐‘Ÿ๐‘–๐‘๐‘’(๐‘—๐‘ก ) = ๐‘ก
|๐พ๐‘ก |
Why didn’t the algorithm choose ๐‘†๐‘– ?
By choosing ๐‘†๐‘– we would have paid ๐‘๐‘– .
๐‘๐‘–
๐‘
๐‘–
So we know |๐พ๐‘ก| ≤ ๐‘˜−(๐‘™+1)
.
๐‘ก
๐‘˜
๐‘˜
๐‘˜
๐‘ง=1
๐‘ง=1
๐‘™=1
๐‘๐‘–
1
∑ ๐‘๐‘Ÿ๐‘–๐‘๐‘’(๐‘—) = ∑ ๐‘๐‘Ÿ๐‘–๐‘๐‘’(๐‘—๐‘ง) ≤ ∑
= ๐‘๐‘– ∑ = ๐‘๐‘– ๐ป(๐‘˜) ≤ ๐‘๐‘– ๐ป(๐‘ž)
๐‘˜−๐‘™+1
๐‘™
๐‘—∈๐‘†๐‘–
๐‘๐‘”๐‘Ÿ๐‘’๐‘’๐‘‘๐‘ฆ = ∑ ๐‘๐‘Ÿ๐‘–๐‘๐‘’(๐‘—)
๐‘—
๐ป๐‘ž โˆ™ ๐‘ฬ…
๐‘ฅฬ…โŸ∗
๐‘โ„Ž๐‘œ๐‘–๐‘๐‘’ ๐‘œ๐‘“
๐‘ฆ๐‘—
=
∑ ๐ป๐‘ž ๐‘ฆ๐‘— = ๐ป๐‘ž โˆ™ 1ฬ… โˆ™ ๐‘ฆฬ…
๐‘Š๐ฟ๐‘ƒ−๐‘‘๐‘ข๐‘Ž๐‘™
≤
๐ป๐‘ž โˆ™ ๐‘ฬ… โˆ™
โŸ
๐‘ฅฬ‚
๐‘œ๐‘๐‘ก๐‘–๐‘š๐‘Ž๐‘™
๐‘๐‘Ÿ๐‘–๐‘š๐‘Ž๐‘™
(๐‘“๐‘Ÿ๐‘Ž๐‘๐‘ก๐‘–๐‘œ๐‘›๐‘Ž๐‘™)
๐‘ ๐‘œ๐‘™๐‘ข๐‘ก๐‘–๐‘œ๐‘›
๐‘—
= ๐ป๐‘ž ๐ถ ∗
๐‘‚๐‘๐‘ก๐‘–๐‘š๐‘Ž๐‘™
๐‘ ๐‘œ๐‘™๐‘ข๐‘ก๐‘–๐‘œ๐‘›
๐‘“๐‘œ๐‘Ÿ ๐‘กโ„Ž๐‘’
๐ผ๐ฟ๐‘ƒ
Example: Cover by 3 paths
Input: graph ๐บ = (๐‘‰, ๐ธ) of ๐‘› vertices
Question: cover the vertices by a minimum collection of paths of length 3.
1 1 11
๐œŒ๐‘”๐‘Ÿ๐‘’๐‘’๐‘‘๐‘ฆ = ๐ป(3) = 1 + + =
2 3
6
3
Exercise: Show algorithm with ๐œŒ๐ด ≤ 2. With Bonus!
Exercise 2: Show polynomial algorithms for paths for length is 2.
Deterministic rounding
Vertex Cover
ILP
Variables: ๐‘ฅ๐‘– for each ๐‘ฃ๐‘–
1,
๐‘ฃ๐‘– ∈ ๐‘
๐‘ฅ๐‘– = {
0,
๐‘œ๐‘กโ„Ž๐‘’๐‘Ÿ๐‘ค๐‘–๐‘ ๐‘’
Minimize ∑๐‘– ๐‘ฅ๐‘–
Subject to ๐‘ฅ๐‘– + ๐‘ฅ๐‘— ≥ 1, ๐‘ฅ๐‘– ∈ {0,1}, ∀๐‘’ = {๐‘ฃ๐‘– , ๐‘ฃ๐‘— }
LP
≤
0 ≤ ๐‘ฅ๐‘– ≤ 1
In polytime, find optimum ๐‘ฅฬ‚
Rounded integeral solution:
1
1,
๐‘ฅ
ฬ‚
≥
′
๐‘–
๐‘ฅ๐‘– ← {
2
0,
๐‘œ๐‘กโ„Ž๐‘’๐‘Ÿ๐‘ค๐‘–๐‘ ๐‘’
Observation: ∀๐‘–, ๐‘ฅ๐‘–′ ≤ 2๐‘ฅฬ‚๐‘–
Claim 1: ๐‘ฅฬ…′ is a feasible solution to the ILP-VC.
Proof: Consider any edge ๐‘’ = ⟨๐‘ฃ๐‘– , ๐‘ฃ๐‘— ⟩
The LP had a constraint: ๐‘ฅ๐‘– + ๐‘ฅ๐‘— ≥ 1
1
2
1
2
Therefore, we know that ๐‘ฅฬ‚๐‘– + ๐‘ฅฬ‚๐‘— ≥ 1 ⇒ either ๐‘ฅฬ‚๐‘– ≥ or ๐‘ฅฬ‚๐‘— ≥ . This means that either ๐‘ฅ๐‘–′ or ๐‘ฅ๐‘—′
was set to 1. Which means that either ๐‘ฃ๐‘– ∈ ๐‘ or ๐‘ฃ๐‘— ∈ ๐‘.
Claim 2: ๐‘๐ท๐‘… ≤ 2๐ถ ∗
๐‘๐ท๐‘… = ∑ ๐‘ฅ๐‘–′ ≤ ∑ 2๐‘ฅฬ‚๐‘– ≤ 2 โˆ™
๐‘–
โŸ
๐‘ฬ‚
๐‘œ๐‘๐‘ก ๐‘“๐‘Ž๐‘
๐‘ ๐‘œ๐‘™๐‘ข๐‘ก๐‘–๐‘œ๐‘›
๐‘–
Generalization to Weighted Set Cover
Δ = max{deg(๐‘–)}
i
Hit-all→ ๐œŒ = Δ
1) Write ILP for Weighted Set Cover
2) Solve relaxed SP, get ๐‘ฅฬ‚ (fractional)
1
1,
๐‘ฅฬ‚๐‘– ≥
Δ
3) Round by setting ๐‘ฅ๐‘–′ ← {
0, ๐‘œ๐‘กโ„Ž๐‘’๐‘Ÿ๐‘ค๐‘–๐‘ ๐‘’
1,
๐‘ฅฬ‚๐‘– > 0
3’) ๐‘ฅ๐‘–′ ← {
0, ๐‘œ๐‘กโ„Ž๐‘’๐‘Ÿ๐‘ค๐‘–๐‘ ๐‘’
≤ 2 โˆ™ ๐‘∗
Download