Lectures 17 18 NPhard problems: Introduction - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

Lectures 17 18 NPhard problems: Introduction

Description:

s is in X iff B(s,t) = YES for some t of size ... as hard as problem X, iff ... a vertex cover set in G iff. There is no edge between remaining k nodes iff ... – PowerPoint PPT presentation

Number of Views:27
Avg rating:3.0/5.0
Slides: 18
Provided by: DarekKo5
Category:

less

Transcript and Presenter's Notes

Title: Lectures 17 18 NPhard problems: Introduction


1
Lectures 17 - 18 NP-hard problemsIntroduction
  • COMP 523 Advanced Algorithmic Techniques
  • Lecturer Dariusz Kowalski

2
Overview
  • Previous lectures
  • Network flows
  • Applications
  • largest matching in bipartite graphs
  • largest number of disjoint paths
  • This lecture
  • NP-hard problems

3
P versus NP
  • Decision problem problem for which the answer
    must be either YES or NOT
  • Polynomial time algorithm there is a constant c
    and the algorithm solving the problem in time
    O(nc) for every input of size n
  • P (polynomial time) - class of decision problems
    for which there is a polynomial time
    deterministic algorithm solving the problem
  • NP (nondeterministic polynomial time) - class of
    decision problems for which there is a certifier
    which can check a witness in polynomial time

4
Certifying in polynomial time
  • A decision problem set of inputs which are
    correct (and should be answered YES, while others
    should be answered NOT)
  • An efficient certifier B for problem X
  • B is in P
  • s is in X iff B(s,t) YES for some t of size
    polynomial of s
  • Example
  • Problem is there a clique of size k in a given
    graph with n nodes?
  • Certifier if a given graph has a clique of size
    k then given
  • this clique as the second parameter we can
    answer YES

5
Computing an efficient certifier
  • How to compute witnesses for an efficient
  • certifier for a given problem?
  • Fact
  • If the witnesses for the efficient certifier can
    be
  • found in polynomial time then the problem is in
    P.
  • Conclusion
  • P is included in NP
  • Open question
  • P NP ?

6
Polynomial reductions
  • Example decision problem if there exists a
    perfect
  • matching in bipartite graphs can be reduced to
  • network flow problem in polynomial time (by
  • adding source, target and directing the edges)
  • Other problems for undirected graphs (in NP and
  • not known to be in P)
  • Independent Set of nodes
  • Vertex cover
  • Set Cover

7
Polynomial reductions
  • Definition
  • Problem X is polynomial-time reducible to problem
    Y, or
  • problem Y is at least as hard as problem X, iff
  • problem X can be solved by the algorithm which
    works in
  • polynomial time and uses polynomial number of
    calls to the
  • black box solving problem Y.
  • Notation X ?P Y
  • Transitivity Property if X ?P Y and Y ?P Z then
    X ?P Z

8
Independent Set to Vertex Cover
  • Independent Set given graph G of n nodes and
    parameter k,
  • is there a set of k nodes such that none two of
    them are connected by
  • an edge?
  • Vertex Cover given graph G of n nodes and
    parameter k,
  • is there a set of k nodes such that every edge
    has at least one
  • end selected?
  • Polynomial Reduction
  • Solve Vertex-Cover(n-k) for the same graph
  • Proof
  • Set S of size n - k is a vertex cover set in G
    iff
  • There is no edge between remaining k nodes iff
  • Set of k remaining nodes is independent in G

9
Vertex Cover to Set Cover
  • Vertex Cover given graph G of n vertices and
    parameter k,
  • is there a set of k vertices such that every edge
    has at least one
  • end selected?
  • Set Cover given n nodes, m sets which cover the
    set of nodes, and parameter k,
  • is there a family of k sets which covers all n
    nodes?
  • Polynomial Reduction
  • Let each edge from the graph correspond to the
    node for SC system
  • For each vertex in the graph create a set of
    incident edges to SC system
  • Solve Set-Cover(m,n,k) for the created SC system
    with m nodes and n sets
  • Proof
  • Each node-edge is covered by at least one
    set-vertex since each node is covered
  • This covering is minimal

10
NP-completeness and NP-hardness
  • NP-complete class of problems X such that every
  • problem from NP is polynomial-time reducible to
    X.
  • Optimization problems problems where the
  • answer is a number (maximum/minimum possible)
  • Each optimization problem has its decision
    version, e.g.,
  • Find a maximum Independent Set
  • Is there an Independent Set of size k?
  • NP-hard class of optimization problems X such
    that its
  • decision version is NP-complete.
  • Example having solution for decision version of
  • Independent Set problem, we can probe a parameter
    k,
  • starting from k 1 , to find a size of a maximum
    independent set

11
Approximation algorithms
  • Having an NP-hard problem, we do not know in this
  • moment any polynomial-time algorithm solving the
  • problem (exact solution)
  • How to find almost optimal solution?
  • Approximation algorithm with ratio a gt 1 gives a
    solution
  • A such that
  • A ? a ? OPT for a min-optimization problems
  • OPT ? a ? A for a max-optimization problems
  • where OPT is an optimal solution.

12
2-approximation for VC
  • Minimum Vertex Cover - NP-hard problem
  • (maximum is trivially n)
  • Algorithm
  • Initialize set C to empty set
  • While there are remaining edges
  • Choose an edge v,w with the largest degree,
    where degree of an edge is a sum of degrees of
    its ends v,w in a current graph G
  • Put v,w to C
  • Remove all the edges adjacent to nodes v,w from
    graph G
  • Output witness set C and its size

13
Analysis of 2-approximation for VC
  • Correctness
  • Each edge is removed only after one of its ends
    is chosen
  • to set C, so each edge is covered
  • Termination
  • In each iteration we remove at least one edge
    from the
  • graph, and there are less than n2 edges
  • Approximation ratio 2
  • For each edge v,w selected at the beginning of
    an iteration at least
  • one end must be in min-VC, and we selected two,
    so set C is at most
  • twice bigger than the min-VC
  • Time complexity O(m n)
  • Exercise

14
Approximation for SC
  • Minimum Set Cover - NP-hard problem
  • (maximum is trivially m)
  • Greedy Algorithm
  • Initialize set C to empty set
  • While there are uncovered nodes
  • Choose a set F which covers the largest number of
    uncovered nodes
  • Put F to C
  • Remove all nodes covered by F
  • Output witness set C and its size

15
Analysis of approximation for SC
  • Correctness
  • Each node is marked as covered when we put the
    set covering it to set C.
  • The algorithm stops when all nodes are covered.
  • Termination
  • In each iteration we cover at least one node, and
    there are n nodes.
  • Approximation ratio log n
  • Let Si be the set selected to C in ith iteration,
    and denote by si the number of uncovered nodes
    covered by Si OPT be the minimum covering set
  • Let cv 1/ si for each node v which was covered
    by Si for the first time
  • The following holds C ?v cv
  • For every set S Si ?v?S cv ? H(S)
    (H(i)?j?i1/j denotes harmonic number)
  • C ?v cv ? ?S?OPT ?v?S cv ? H(n) ?S?OPT1
    H(n) OPT ? OPT log n
  • Time and memory complexities
  • O(M n), where M is the sum of cardinalities of
    sets
  • Exercise

16
Conclusions
  • Decision problems P and NP-complete
  • Polynomial-time reduction
  • Optimization problems in NP-hard
  • Maximum Independent Set
  • Minimum Vertex Cover
  • Minimum Set Cover
  • Approximation algorithms - polynomial time
  • Min-VC with ratio 2
  • Min-SC with ratio log n

17
Exercises
  • Analyse the time and memory complexities of
    min-VC approximation algorithm with ratio 2 and
    min-SC algorithm
  • Consider a modification of min-VC algorithm
    choose a node which covers the largest number of
    uncovered edges. Is it 2-approximation algorithm?
  • Having the 2-approximation algorithm for min-VC,
    is it easy to modify it to be a 2-approximation
    algorithm for max-IS (since there is a simple
    polynomial-time reduction between these two
    problems)?
Write a Comment
User Comments (0)
About PowerShow.com