Lecture 5
Takeaway from Bipartite Matching
- We saw how to solve a problem (bi-partite matching and others) by reducing it to another problem (maximum flow).
- In general, we can design an algorithm to map instances of a new problem to instances of known solvable problem (e.g., max-flow) to solve this new problem!
- Mapping from one problem to another which preserves solutions is called reduction.
Reduction: Basic Idea
Convert solutions to the known problem to the solutions to the new problem
- Instance of new problem
- Instance of known problem
- Solution of known problem
- Solution of new problem
Reduction: Formal Definition
Problems .
reduces to () if there is a mapping from any instance to some instance , such that the solution for yields a solution for .
This means that L is no harder than K
Using reduction to design algorithms
In the example of reduction to solve Bipartite Matching:
Bipartite Matching
Max-flow Problem
Efficiency:
- Reduction: (Polynomial time reduction )
- Solve prom (Polynomial time to solve )
- Convert the solution for to a solution to (Polynomial time to solve )
Efficient Reduction
A reduction is efficient () if for any :
- is computable from in polynomial () time.
- Solution to is computable from solution of in polynomial () time.
We call is poly-time reducible to , or poly-time reduces to .
Which problem is harder?
Theorem: If and there is a polynomial time algorithm to solve , then there is a polynomial time algorithm to solve .
Proof: Given an instance of If we can convert the problem in polynomial time with respect to the original problem .
- Compute :
- Solve :
- Convert solution:
Total time: Need to show:
Proof:
Since we can convert in time, and on every time step, (constant step) we can only write constant amount of data.
So
Hardness Problems
Reductions show the relationship between problem hardness!
Question: Could you solve a problem in polynomial time?
Easy: polynomial time solution Hard: No polynomial time solution (as far as we know)
Types of Problems
Decision Problem: Yes/No answer
Examples: Subset sums
- Is the there a flow of size
- Is there a shortest path of length from vertex to vertex .
- Given a set of intercal, can you schedule of them.
Optimization Problem: What is the value of an optimal feasible solution of a problem?
- Minimization: Minimize cost
- min cut
- minimal spanning tree
- shortest path
- Maximization: Maximize profit
- interval scheduling
- maximum flow
- maximum matching
Canonical Decision Problem
Does the instance (an optimization problem) have a feasible solution with objective value :
Objective value (maximization) (minimization)
is the reduced Canonical Decision problem
Hardness of Canonical Decision Problems
Lemma 1: ( is no harder than )
Proof: Assume maximization problem : does have a solution .
Example: Does graph have flow .
Let be the maximum objective on by solving .
Let the instance of and be the problem and be the objective
- (optimization problem)
- Is ? If so, return true, else return false.
Lemma 2: If for any constant , then .
Proof: First we could show . Suppose maximization problem, canonical decision problem is is there a solution .
Naïve Linear Search: Ask , if returns false, ask until returns true
Runtime: At most search to iterate all possibilities.
This is exponential! How to reduce it?
Our old friend Binary (exponential) Search is back!
You gets a no at some value: try power of 2 until you get a no, then do binary search
# questions:
Binary search in area: from last yes to first no.
Runtime: Binary search ()
Reduction for Algorithm Design vs Hardness
For problems
If is “easy” (exists a poly-time solution), then is also easy.
If is “hard” (no poly-time solution), then is also hard.
Every problem that we worked on so far, is “easy”, so we reduce from new problem to known problem (e.g., max-flow).
Reduction for Hardness: Independent Set (ISET)
Input: Given an undirected graph ,
A subset of vertices is called an independent set if no two vertices of are connected by an edge.
Problem: Does contain an independent set of size ?
returns true if contains an independent set of size , and false otherwise.
Algorithm? NO! We think that this is a hard problem.
A lot of people have tried and could not find a poly-time solution
Example: Vertex Cover (VC)
Input: Given an undirected graph
A subset of vertices is called a vertex cover if contains at least one end point of every edge.
Formally, for all edges , either , or .
Problem: returns true if has a vertex cover of size , and false otherwise (minimization problem)
Example:
How hard is Vertex Cover?
Claim: Side Note: when we prove is hard, we prove it is no easier than .
DO NOT:
Proof: Show that has an independent set of if and only if the same graph (not always!) has a vertex cover of size .
Map:
Proof of reduction: Direction 1
Claim 1: of size of size
Proof: Assume has an of size , consider
Claim: is a vertex cover
Proof of reduction: Direction 2
Claim 2: of size of size
Proof: Assume has an of size , consider
Claim: is an independent set
What does poly-time mean?
Algorithm runs in time polynomial to input size.
- If the input has items, algorithm runs in for any constant is poly-time.
- Examples: intervals to schedule, number of integers to sort, # vertices + # edges in a graph
- Numerical Value (Integer ), what is the input size?
- Examples: weights, capacity, total time, flow constraints
- It is not straightforward!
Real time complexity of F-F?
In class:
- = this much space to represent the graph
- : size of the maximum flow.
If every edge has capacity , then Running time:
What is the actual input size?
Each edge ( edges):
- 2 vertices: distinct symbol, bits per symbol
- 1 capacity:
Size of graph:
Running time:
-
- Exponential if is exponential in
Pseudo-polynomial
Naïve Ford-Fulkerson is bad!
Problem ’s inputs contain some numerical values, say . We need only log bits to store . If algorithms runs in , then it is exponential, or pseudopolynomial.
In homework, you improved F-F to make it work in , to make it a real polynomial algorithm.
Conclusion: Reductions
- Reduction
- Construction of mapping with runtime
- Bidirectional proof
- Efficient Reduction
- Which problem is harder?
- If is hard, then is hard. Used to show hardness
- If is easy, then is easy. Used for design algorithms
- Canonical Decision Problem
- Reduction to and from the optimization problem
- Reduction for hardness
- Independent Set Vertex Cover
On class
Reduction:
OPT: Find max flow of at least one instance
DEC: Is there a flow of size , given the instance is defined by the tuple
Yes, if there exists one No, otherwise
Forget about F-F and assume that you have an oracle that solves the decision problem.
First solution (the naive solution): iterate over until the oracle returns false and the last one returns true would be the max flow.
Time complexity: , where is the time complexity of the oracle Input size: , and capacities
A better solution: do a binary search. If there is no upper bound, we use exponential binary search instead. Then,
As is linear in the size of the input, the running time is polynomial to the solution of the original problem.
Assume that ISET is a hard problem, i.e. we don't know of any polynomial time solution. We want to show that vertex cover is also a hard problem here:
- Given an instance of ISET, construct an instance of VC
- Show that the construction can be done in polynomial time
- Show that if the ISET instance is true than the CV instance is true
- Show that if the VC instance is true then the ISET instance is true.
ISET: given , is there a set of vertices that do not share edges of size
VC: given , is there a set of vertices that cover all edges of size
- Given being an instance of ISET, we construct as an instance of VC.
- It is obvious that it is a polynomial time construction since copying the graph is linear, in the size of the graph and the subtraction of integers is constant time.
Direction 1: ISET of size k VC of size Assume that ISET(G,K) returns true, show that returns true
Let be an independent set of size and
We claim that is a vertex cover of size
Proof:
We proceed by contradiction. Assume that is NOT a vertex cover, and it means that there is an edge such that . And it implies that , which contradicts with the assumption that S is an independent set. Therefore, is an vertex cover
Direction 2: VC of size ISET of size
Let be a vertex cover of size , let
We claim that is an independent set of size .
Again, assume, for the sake of contradiction, that is not an independent set. And we get
And this is a contradiction with our assumption.