Announcements Assignment 4: Due Monday, April 5 at Midnight (due to university regulations). Submit solutions to any 2 of the 4 problems. Responsible.

Slides:



Advertisements
Similar presentations
Introduction to Algorithms NP-Complete
Advertisements

Reducibility and NP-Completeness COSC 3101B, PROF. J. ELDER 2 Computational Complexity Theory Computational Complexity Theory is the study of how much.
NP-Hard Nattee Niparnan.
Polynomial-time reductions We have seen several reductions:
Great Theoretical Ideas in Computer Science.
1 NP-completeness Lecture 2: Jan P The class of problems that can be solved in polynomial time. e.g. gcd, shortest path, prime, etc. There are many.
Department of Computer Science & Engineering
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
Five Problems CSE 421 Richard Anderson Winter 2009, Lecture 3.
Introduction To Algorithms CS 445 Discussion Session 8 Instructor: Dr Alon Efrat TA : Pooja Vaswani 04/04/2005.
The Maximum Network Flow Problem. CSE Network Flows.
Discrete Structures & Algorithms The P vs. NP Question EECE 320.
CSC5160 Topics in Algorithms Tutorial 2 Introduction to NP-Complete Problems Feb Jerry Le
Complexity 11-1 Complexity Andrei Bulatov NP-Completeness.
February 23, 2015CS21 Lecture 201 CS21 Decidability and Tractability Lecture 20 February 23, 2015.
CS138A Maximum Bipartite Matching Peter Schröder.
NP-Complete Problems Reading Material: Chapter 10 Sections 1, 2, 3, and 4 only.
The max flow problem
Analysis of Algorithms CS 477/677
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 24 Instructor: Paul Beame.
CSE 421 Algorithms Richard Anderson Lecture 27 NP Completeness.
Toward NP-Completeness: Introduction Almost all the algorithms we studies so far were bounded by some polynomial in the size of the input, so we call them.
Clique Cover Cook’s Theorem 3SAT and Independent Set
The Theory of NP-Completeness 1. What is NP-completeness? Consider the circuit satisfiability problem Difficult to answer the decision problem in polynomial.
Nattee Niparnan. Easy & Hard Problem What is “difficulty” of problem? Difficult for computer scientist to derive algorithm for the problem? Difficult.
Lecture 22 More NPC problems
The Complexity of Optimization Problems. Summary -Complexity of algorithms and problems -Complexity classes: P and NP -Reducibility -Karp reducibility.
CSEP 521 Applied Algorithms Richard Anderson Lecture 10 NP Completeness.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 33.
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
CSE 024: Design & Analysis of Algorithms Chapter 9: NP Completeness Sedgewick Chp:40 David Luebke’s Course Notes / University of Virginia, Computer Science.
EMIS 8373: Integer Programming NP-Complete Problems updated 21 April 2009.
COMPSCI 102 Introduction to Discrete Mathematics.
Graph Colouring L09: Oct 10. This Lecture Graph coloring is another important problem in graph theory. It also has many applications, including the famous.
CSE 589 Part VI. Reading Skiena, Sections 5.5 and 6.8 CLR, chapter 37.
Unit 9: Coping with NP-Completeness
NP-Complete Problems. Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems.
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness and course wrap up.
Great Theoretical Ideas In Computer Science Anupam GuptaCS Fall 2006 Lecture 28Dec 5th, 2006Carnegie Mellon University Complexity Theory: A graph.
1.1 Chapter 3: Proving NP-completeness Results Six Basic NP-Complete Problems Some Techniques for Proving NP-Completeness Some Suggested Exercises.
CS 3343: Analysis of Algorithms Lecture 25: P and NP Some slides courtesy of Carola Wenk.
CSCI 3130: Formal languages and automata theory Andrej Bogdanov The Chinese University of Hong Kong The Cook-Levin.
Inspiration Versus Perspiration: The P = ? NP Question.
CSE 589 Part V One of the symptoms of an approaching nervous breakdown is the belief that one’s work is terribly important. Bertrand Russell.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 25.
NPC.
CSCI 2670 Introduction to Theory of Computing December 2, 2004.
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness Proofs.
The NP class. NP-completeness Lecture2. The NP-class The NP class is a class that contains all the problems that can be decided by a Non-Deterministic.
The Maximum Network Flow Problem
TU/e Algorithms (2IL15) – Lecture 8 1 MAXIMUM FLOW (part II)
TU/e Algorithms (2IL15) – Lecture 10 1 NP-Completeness, II.
The Maximum Network Flow Problem
Richard Anderson Lecture 26 NP-Completeness
Introduction to Discrete Mathematics
Some Great Theoretical Ideas in Computer Science for.
Richard Anderson Lecture 26 NP-Completeness
NP-Completeness Yin Tat Lee
Richard Anderson Lecture 25 NP-Completeness
Great Theoretical Ideas in Computer Science
CSE 421 Richard Anderson Autumn 2016, Lecture 3
CSE 421 Richard Anderson Autumn 2015, Lecture 3
Richard Anderson Lecture 26 NP-Completeness
NP-Completeness Yin Tat Lee
CSE 6408 Advanced Algorithms.
CSE 421, University of Washington, Autumn 2006
Instructor: Aaron Roth
Instructor: Aaron Roth
CSE 421 Richard Anderson Autumn 2019, Lecture 3
Presentation transcript:

Announcements Assignment 4: Due Monday, April 5 at Midnight (due to university regulations). Submit solutions to any 2 of the 4 problems. Responsible for understanding all 4 problems (related material may be on final exam).Tutorial: Fri, Apr 2 A. Kolokolova 16:00-17:30 PSE 321 Special office hours (week prior to exam): MWF 2-3

The Maximum Network Flow Problem

Example Flow(1) Residual(1) Flow(2) Residual(2) No more augmenting paths  max flow attained.

The Basic Ford-Fulkerson Algorithm

Multiple Sources Network We have several sources and several targets.We have several sources and several targets. Want to maximize the total flow from all sources to all targets.Want to maximize the total flow from all sources to all targets. Reduce to max-flow by creating a supersource and a supersink:Reduce to max-flow by creating a supersource and a supersink:

Maximum Bipartite Matching A bipartite graph is a graph G=(V,E) in which V can be divided into two parts L and R such that every edge in E is between a vertex in L and a vertex in R. e.g. vertices in L represent skilled workers and vertices in R represent jobs. An edge connects workers to jobs they can perform.

A matching in a graph is a subset M of E, such that for all vertices v in V, at most one edge of M is incident on v.

A maximum matching is a matching of maximum cardinality. not maximum maximum

A Maximum Matching No matching of cardinality 4, because only one of v and u can be matched. In the workers-jobs example a max- matching provides work for as many people as possible. v u

Solving the Maximum Bipartite Matching Problem Reduce an instance of the maximum bipartite matching problem on graph G to an instance of the max-flow problem on a corresponding flow network G’.Reduce an instance of the maximum bipartite matching problem on graph G to an instance of the max-flow problem on a corresponding flow network G’. Solve using Ford-Fulkerson method.Solve using Ford-Fulkerson method.

Corresponding Flow Network To form the corresponding flow network G' of the bipartite graph G:To form the corresponding flow network G' of the bipartite graph G: Add a source vertex s and edges from s to L. Direct the edges in E from L to R. Add a target vertex t and edges from R to t. Assign a capacity of 1 to all edges. Claim: max-flow in G’ corresponds to a max- bipartite-matching on G.Claim: max-flow in G’ corresponds to a max- bipartite-matching on G.

Example min cut |M| = 3  max flow = 3

Lemma (CLRS 26.10)

Why can’t we just say max |f| = max |M|? Problem: we haven’t shown that f(u,v) is necessarily integer-valued for all (u,v) when f is a max flow. It follows from the lemma that max |M| = max [ integral flow], max |M| = max [ integral flow], but we also need max [integral flow] = max |f| max [integral flow] = max |f|

Integrality Theorem (CLRS 26.11) If the capacity function c takes on only integral values, then: 1.The maximum flow f produced by the Ford-Fulkerson method has the property that |f| is integer-valued. 2.For all vertices u and v the value f(u,v) of the flow is an integer. So |M| = max [integral flow] = max |f|

Conclusion Network flow algorithms allow us to find the maximum bipartite matching fairly easily. Similar techniques are applicable in other combinatorial design problems.

Example In a department there are n courses and m instructors. Every instructor has a list of courses he or she can teach. Every instructor can teach at most 3 courses during a year. The goal: find an allocation of courses to the instructors subject to these constraints.

Two solutions using network flows Solution 1: convert the problem into a bipartite matching problem. Solution 2: convert the problem into a flow problem directly.

A more complicated problem There are m student groups on campus.There are m student groups on campus. We would like to form a committee with a president, 3 vice-pres, and 10 members at large.We would like to form a committee with a president, 3 vice-pres, and 10 members at large. The committee is formed by representatives of the groups.The committee is formed by representatives of the groups. Can add conditions:Can add conditions: The first group can be represented by at most 2 members, any other group can be represented by at most one. The representative of the third group cannot be the president. Reduce to network flows!Reduce to network flows!

Reducibility and NP-Completeness

Computational Complexity Theory Computational Complexity Theory is the study of how much of a given resource (such as time, space, parallelism, randomness, algebraic operations, communication, or quantum steps) is required to solve important problems.

WORST-CASE TIME We say that a program takes worst-case time T(n), if some input of size n takes T(n) steps, and no input of size n takes longer. The input size is measured in bits, unless stated otherwise.

Some Examples

A Graph Named “Gadget”

K-COLORING A k-coloring of a graph is an assignment of one color to each vertex such that: No more than k colors are used No two adjacent vertices receive the same color A graph is called k-colorable iff it has a k-coloring

A CRAYOLA Question! Is Gadget 2-colorable? No: it contains a triangle!

Is Gadget 3-colorable? A CRAYOLA Question! Yes!

Given a graph G, what is a fast algorithm to decide if it can be 2-colored? 2 CRAYOLAS PERSPIRATION; BRUTE FORCE: Try out all 2 n ways of 2 coloring G.

Given a graph G, what is a fast algorithm to decide if it can be 3-colored? 3 CRAYOLAS ????????

Let’s consider a completely different problem.

K-CLIQUES A K-clique is a set of K nodes with all k(K-1)/2 possible edges between them.

This graph contains a 4-clique

Given an n-node graph G and a number k, how can you decide if G contains a k-clique? PERSPIRATION: Try out all n choose k possible locations for the k clique INSPIRATION: ????????

OK, how about a slightly different problem?

INDEPENDENT SET An independent set is a set of vertices with no edges between them. This graph contains an independent set of size 3.

Given an n-node graph G and a number k, how can you decide if G contains an independent set of size k? PERSPIRATION: Try out all n-choose-k possible locations for independent set INSPIRATION: ????????

One more completely different problem

Combinational Circuits AND, OR, NOT, gates wired together with no feedback allowed (acyclic).

Logic Gates NotAndOr

Example Circuit

CIRCUIT-SATISFIABILITY (decision version) Given a circuit with n-inputs and one output, is there a way to assign 0-1 values to the input wires so that the output value is 1 (true)?

CIRCUIT-SATISFIABILITY (search version) Given a circuit with n-inputs and one output, find an assignment of 0-1 values to the input wires so that the output value is 1 (true), or determine that no such assignment exists.

Satisfiable Circuit Example

Satisfiable? No!

Given a circuit, is it satisfiable? PERSPIRATION: Try out all 2 n assignments INSPIRATION: ????????

We have seen 4 problems: coloring, clique, independent set, and circuit SAT. They all have a common story: A large space of possibilities only a tiny fraction of which satisfy the constraints. Brute force takes too long, and no feasible algorithm is known.

CLIQUE / INDEPENDENT SET Two problems that are cosmetically different, but substantially the same

Complement Of G Given a graph G, let G *, the complement of G, be the graph obtained by the rule that two nodes in G * are connected if and only if the corresponding nodes of G are not connected

Reduction Suppose you have a method for solving the k-clique problem. How could it be used to solve the independent set problem?

Or what if you have an Oracle? or·a·cle Pronunciation: 'or-&-k&l, 'är- Function: noun Etymology: Middle English, from Middle French, from Latin oraculum, from orare to speak 1 a : a person (as a priestess of ancient Greece) through whom a deity is believed to speak 2 a : a person giving wise or authoritative decisions or opinions

Let G be an n-node graph. GIVEN: Clique Oracle BUILD: Indep. Set Oracle

Let G be an n-node graph. GIVEN: Indep. Set Oracle BUILD: Clique Oracle

Thus, we can quickly reduce clique problem to an independent set problem and vice versa. There is a fast method for one if and only if there is a fast method for the other.

Given an oracle for circuit SAT, how can you quickly solve 3-colorability?

V n (X,Y) Let V n be a circuit that takes an n-node graph X and an assignment Y of colors to these nodes, and verifies that Y is a valid 3- colouring of X. i.e., V n (X,Y)=1 iff Y is a 3- colouring of X. X is expressed as an n-choose-2 bit sequence. Y is expressed as a 2n bit sequence. Given n, we can construct V n in time O(n 2 ).

Let G be an n-node graph. GIVEN: SAT Oracle G BUILD: 3- color Oracle V n (G,Y)

Given an oracle for circuit SAT, how can you quickly solve k-clique?

V n,k (X,Y) Let V n be a circuit that takes an n-node graph X and a subset of nodes Y, and verifies that Y is a k-clique X. I.e., V n (X,Y)=1 iff Y is a k- clique of X. X is expressed as an n choose 2 bit sequence. Y is expressed as an n bit sequence. Given n, we can construct V n,k in time O(n 2 ).

Let G be an n-node graph. GIVEN: SAT Oracle BUILD: Clique Oracle V n,k (G,Y)

Given an oracle for 3-colorability, how can you quickly solve circuit SAT?

Reducing Circuit-SAT to 3-Colouring Goal: map circuit to graph that is 3- colourable only if circuit is satisfiable. How do we represent a logic gate as a 3-colouring problem?

X Y Output Example X and Y and Output are boolean variables in circuit. Without loss of generality, map truth values to colours, e.g. 0  red 1  green Add base colour for encoding purposes, e.g. yellow.

X Y Output Example Note that in a valid 3- colouring, this node cannot have the same colour as X, Y or Output. Thus, without loss of generality, we can assign it the base colour, yellow.

X Y Output Example Now suppose we fix this node to represent false.

X Y Output Example F Now suppose we fix this node to represent false.

Example T F X Y Output Now build a truth table for (X, Y, Output). What if X=Y=0?

Example T F X Y Output Now build a truth table for (X, Y, Output). What if X=Y=0?

Example T F X Y Output Now build a truth table for (X, Y, Output). What if X=Y=0?

Example T F X Y Output Now build a truth table for (X, Y, Output). What if X=Y=0?

Example T F X Y Output Thus (X,Y)=0  Output=0

Example T F X Y Output Conversely, what if Output=0?

Example T F X Y Output Conversely, what if Output=0?

Example T F X Y Output Conversely, what if Output=0?

Example T F X Y Output Conversely, what if Output=0?

Example T F X Y Output Thus Output=0  X=Y=0.

Example T F X Y Output XYOutputFFF FTT TFT TTT What type of gate is this? An OR gate!

TF X What type of gate is this? A NOT gate! Output

OR NOT xy z x y z

OR NOT xy z x y z Satisfiability of this circuit = 3-colorability of this graph

Let C be an n-input circuit. GIVEN: 3-color Oracle C BUILD: SAT Oracle Graph composed of gadgets that mimic the gates in C

Formal Statement There is a polynomial-time function f such that: C is satisfiable f(C) is 3 colorable

4 Problems All Equivalent If you can solve one quickly then you can solve them all quickly: Circuit-SATClique Independent Set 3 Colorability

That’s All, Folks!