Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


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

1

2 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

3 The Maximum Network Flow Problem

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

5 The Basic Ford-Fulkerson Algorithm

6 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:

7 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.

8 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.

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

10 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

11 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.

12 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.

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

14 Lemma (CLRS 26.10)

15 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|

16 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|

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

18 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.

19 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.

20 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!

21 Reducibility and NP-Completeness

22 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.

23 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.

24 Some Examples

25 A Graph Named “Gadget”

26 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

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

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

29 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.

30

31

32

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

34 Let’s consider a completely different problem.

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

36 This graph contains a 4-clique

37 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: ????????

38 OK, how about a slightly different problem?

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

40 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: ????????

41 One more completely different problem

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

43 Logic Gates NotAndOr

44 Example Circuit

45 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)?

46 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.

47 Satisfiable Circuit Example

48 Satisfiable? No!

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

50 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.

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

52 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

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

54 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

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

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

57 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.

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

59 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 ).

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

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

62 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 ).

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

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

65 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?

66 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.

67 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.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

82 OR NOT xy z x y z

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

84 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

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

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

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105 That’s All, Folks!


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

Similar presentations


Ads by Google