Algorithms and Data Structures 2011/12 Week 9 Solutions (Tues 15th - Fri 18th Nov)

Similar documents
Main Reference: Sections in CLRS.

1 Motivation and Basic Definitions

Network Flow. Data Structures and Algorithms Andrei Bulatov

The Residual Graph. 11 Augmenting Path Algorithms. Augmenting Path Algorithm. Augmenting Path Algorithm

Flow networks. Flow Networks. A flow on a network. Flow networks. The maximum-flow problem. Introduction to Algorithms, Lecture 22 December 5, 2001

The Residual Graph. 12 Augmenting Path Algorithms. Augmenting Path Algorithm. Augmenting Path Algorithm

Randomized Perfect Bipartite Matching

Problem Set If all directed edges in a network have distinct capacities, then there is a unique maximum flow.

Soviet Rail Network, 1955

Greedy. I Divide and Conquer. I Dynamic Programming. I Network Flows. Network Flow. I Previous topics: design techniques

Today: Max Flow Proofs

Network Flows: Introduction & Maximum Flow

Maximum Flow 5/6/17 21:08. Presentation for use with the textbook, Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 2015

Matching. Slides designed by Kevin Wayne.

CSC 364S Notes University of Toronto, Spring, The networks we will consider are directed graphs, where each edge has associated with it

Soviet Rail Network, 1955

Algorithmic Discrete Mathematics 6. Exercise Sheet

CS 473G Lecture 15: Max-Flow Algorithms and Applications Fall 2005

CSE 521: Design & Analysis of Algorithms I

Algorithm Design and Analysis

CS4445/9544 Analysis of Algorithms II Solution for Assignment 1

Maximum Flow and Minimum Cut

Graphs III - Network Flow

Fall 2014 David Wagner MT2 Soln

! Abstraction for material flowing through the edges. ! G = (V, E) = directed graph, no parallel edges.

Network Flow Applications

16 Max-Flow Algorithms and Applications

CS261: A Second Course in Algorithms Lecture #1: Course Goals and Introduction to Maximum Flow

Algorithm Design and Analysis

Flow networks, flow, maximum flow. Some definitions. Edmonton. Saskatoon Winnipeg. Vancouver Regina. Calgary. 12/12 a.

MAXIMUM FLOW. introduction Ford-Fulkerson algorithm maxflow-mincut theorem

Admin MAX FLOW APPLICATIONS. Flow graph/networks. Flow constraints 4/30/13. CS lunch today Grading. in-flow = out-flow for every vertex (except s, t)

Max Flow, Min Cut COS 521. Kevin Wayne Fall Soviet Rail Network, Cuts. Minimum Cut Problem. Flow network.

6/3/2009. CS 244 Algorithm Design Instructor: t Artur Czumaj. Lecture 8 Network flows. Maximum Flow and Minimum Cut. Minimum Cut Problem.

18 Extensions of Maximum Flow

4/12/12. Applications of the Maxflow Problem 7.5 Bipartite Matching. Bipartite Matching. Bipartite Matching. Bipartite matching: the flow network

Introduction to Congestion Games

CMPS 6610/4610 Fall Flow Networks. Carola Wenk Slides adapted from slides by Charles Leiserson

Reminder: Flow Networks

Introduction to SLE Lecture Notes

Network Flows UPCOPENCOURSEWARE number 34414

Maximum Flow. Contents. Max Flow Network. Maximum Flow and Minimum Cut

Maximum Flow 3/3 4/6 1/1 4/7 3/3. s 3/5 1/9 1/1 3/5 2/2. 1/18/2005 4:03 AM Maximum Flow 1

Flow Networks. Ma/CS 6a. Class 14: Flow Exercises

CSE 421 Introduction to Algorithms Winter The Network Flow Problem

Maximum Flow. How do we transport the maximum amount data from source to sink? Some of these slides are adapted from Lecture Notes of Kevin Wayne.

7.5 Bipartite Matching. Chapter 7. Network Flow. Matching. Bipartite Matching

Math 2142 Exam 1 Review Problems. x 2 + f (0) 3! for the 3rd Taylor polynomial at x = 0. To calculate the various quantities:

26.1 Flow networks. f (u,v) = 0.

u(t) Figure 1. Open loop control system

PHYSICS 151 Notes for Online Lecture #4

Network flows. The problem. c : V V! R + 0 [ f+1g. flow network G = (V, E, c), a source s and a sink t uv not in E implies c(u, v) = 0

Maximum Flow in Planar Graphs

Basic Tools CMSC 641. Running Time. Problem. Problem. Algorithmic Design Paradigms. lg (n!) (lg n)! (lg n) lgn n.2

2. VECTORS. R Vectors are denoted by bold-face characters such as R, V, etc. The magnitude of a vector, such as R, is denoted as R, R, V

Please Complete Course Survey. CMPSCI 311: Introduction to Algorithms. Approximation Algorithms. Coping With NP-Completeness. Greedy Vertex Cover

3/3/2015. Chapter 7. Network Flow. Maximum Flow and Minimum Cut. Minimum Cut Problem

6.302 Feedback Systems Recitation : Phase-locked Loops Prof. Joel L. Dawson

April 3, The maximum flow problem. See class notes on website.

Today s topics. CSE 421 Algorithms. Problem Reduction Examples. Problem Reduction. Undirected Network Flow. Bipartite Matching. Problem Reductions

Chapter 3 Kinematics in Two Dimensions

They were originally developed for network problem [Dantzig, Ford, Fulkerson 1956]

Rectilinear Kinematics

Math 2214 Solution Test 1 B Spring 2016

Differential Geometry: Numerical Integration and Surface Flow

20/20 20/20 0/5 0/5 20/20 20/20 5/5 0/5 0/5 5/5 0/20 25/30 20/20 30/30 20/20 0/5 5/5 20/20 0/5 0/5 15/20 15/25 20/20 10/10

Bipartite Matching. Matching. Bipartite Matching. Maxflow Formulation

Dynamic Programming 11/8/2009. Weighted Interval Scheduling. Weighted Interval Scheduling. Unweighted Interval Scheduling: Review

, the. L and the L. x x. max. i n. It is easy to show that these two norms satisfy the following relation: x x n x = (17.3) max

23 Maximum Flows and Minimum Cuts

Math Wednesday March 3, , 4.3: First order systems of Differential Equations Why you should expect existence and uniqueness for the IVP

KEY. Math 334 Midterm I Fall 2008 sections 001 and 003 Instructor: Scott Glasgow

Selfish Routing. Tim Roughgarden Cornell University. Includes joint work with Éva Tardos

EECE 301 Signals & Systems Prof. Mark Fowler

Differential Geometry: Revisiting Curvatures

Average Case Lower Bounds for Monotone Switching Networks

Physics 240: Worksheet 16 Name

t is a basis for the solution space to this system, then the matrix having these solutions as columns, t x 1 t, x 2 t,... x n t x 2 t...

Inventory Analysis and Management. Multi-Period Stochastic Models: Optimality of (s, S) Policy for K-Convex Objective Functions

3.1.3 INTRODUCTION TO DYNAMIC OPTIMIZATION: DISCRETE TIME PROBLEMS. A. The Hamiltonian and First-Order Conditions in a Finite Time Horizon

7. NETWORK FLOW I. Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley. Last updated on 11/22/17 6:11 AM

s in boxe wers ans Put

Discussion Session 2 Constant Acceleration/Relative Motion Week 03

Warm Up. Correct order: s,u,v,y,x,w,t

We just finished the Erdős-Stone Theorem, and ex(n, F ) (1 1/(χ(F ) 1)) ( n

23.2. Representing Periodic Functions by Fourier Series. Introduction. Prerequisites. Learning Outcomes

Exponential Sawtooth

5.2 GRAPHICAL VELOCITY ANALYSIS Polygon Method

7. NETWORK FLOW I. Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley. Last updated on 11/22/17 6:11 AM

Phys 221 Fall Chapter 2. Motion in One Dimension. 2014, 2005 A. Dzyubenko Brooks/Cole

Notes on cointegration of real interest rates and real exchange rates. ρ (2)

Main Ideas in Class Today

Q2.4 Average velocity equals instantaneous velocity when the speed is constant and motion is in a straight line.

Hamilton- J acobi Equation: Explicit Formulas In this lecture we try to apply the method of characteristics to the Hamilton-Jacobi equation: u t

Homework sheet Exercises done during the lecture of March 12, 2014

3.6 Derivatives as Rates of Change

Two Coupled Oscillators / Normal Modes

Algorithms. Algorithms 6.4 MAXIMUM FLOW

Physics Notes - Ch. 2 Motion in One Dimension

16 Max-Flow Algorithms

Transcription:

Algorihm and Daa Srucure 2011/ Week Soluion (Tue 15h - Fri 18h No) 1. Queion: e are gien 11/16 / 15/20 8/13 0/ 1/ / 11/1 / / To queion: (a) Find a pair of ube X, Y V uch ha f(x, Y) = f(v X, Y). (b) Find a differen pair of ube X, Y V uch ha f(x, Y) f(v X, Y). Aner: The poin of hi queion i o ge hinking abou flo beeen e of erice, b appling Lemma 3 of Lecure lide 13-1. Hoeer, i migh be good o hink abou pecific eample of (a), (b) fir, before looking a he deail of ha he paern i. Wha e are aking i: hen i i he cae ha f(x, Y) + f(v X, Y) = 0? Remember from Lemma 3 (par 3) of lide 13-1 ha for an o dijoin e X, Y V, and an oher e Z, and an flo f, e hae f(x, Z ) + f(y, Z ) = f(x Y, Z ). Obere ha for our queion, cerainl X and V X are dijoin e. Hence b Lemma 3 (3), e kno f(x, Y) + f(v X, Y) = f(x (V X), Y) = f(v, Y). So e are eing heher f(v, Y) = 0 for (a), and heher f(v, Y) 0 for (b) - once hi i aified, X can be anhing... To make f(v, Y) = 0, e hould eiher ake Y uch ha Y {, } =, or Y {, } = {, }. Thi can be een b repeaed applicaion of par (3) of Lemma 3 from lide 13-1. To make f(v, Y) 0, e hould ake Y uch ha Y {, } = 1. Here are ome concree eample of hi behaiour: (a) A a concree eample, le Y = {, }. X can be *an* e, ake X = {} a an eample. Then f(x, Y) = + = 8. Then f(v X, Y) = 11 + 8 11 = 8. 1

(b) A a concree eample, ake Y = {}. Take X = {} again. Then e hae f(x, Y) = 0. We hae f(v X, Y) = 11 8 = 1. 2. Queion: eecue he Ford-Fulkeron algorihm (uing he Edmond-Karp heuriic) on he Neork belo: 16 20 13 1 Aner: If e are uing he Edmond-Karp heuriic, hen eer ime e earch for an augmening pah, e mu chooe a hore augmening pah. For our gien neork, e can ee ha on he fir ieraion, he pah p1 = i a hore pah. We hae c(p1) =. Hence e define he flo f1 = f p1 b for e = (, ), (, ), (, ) f1(e) = f p1 (e) = for e = (, ), (, ), (, ) 0 oherie Picoriall, e hae /16 / /20 13 1 The reidual neork N f1 i a follo: 13 1 8 We no eamine N f1 o find a hore augmening pah. We find ha p2 = i a hore augmening pah in N f1, min capaci, ee aboe... We herefore define a ne flo f p2 uch ha uni are hipped along he edge of he 2

pah p2, and - hipped in he backard direcion of p2. Then e define he flo f2 = f1 + f p2. Remember o poin ou hi i poible *onl* becaue f1 i a flo in N and f2 i a flo in he *reidual* neork N f1. Belo i he flo f2 = f1 + f p2 in N. /16 / /20 /13 /1 / Belo i he reidual neork N f2. If e again r he Edmond-Karp rule for finding an augmening pah of hore poible lengh, e find he pah p3 = (hi i of lengh, bu here are no pah of lengh 3 or le in N f2 ). The min capaci along he pah i. 8 We define a ne flo f p3 in N f2 b hipping uni along p3. Then e define he flo f3 in N a f3 = f2 + f p3. The flo look a follo: /16 / 1/20 11/13 11/1 / / We compue he reidual neork N f3, ee belo for a picure. 2 11 3 1 1 11 3

B Ford-Fulkeron algorihm, e no r for a (hore) augmening pah in he N f3. Hoeer, if e eamine N f3, e ee ha here i *no* augmening pah from o - he e of erice acceible from i no {,,, }. Hence e erminae, reurning he flo f3, of alue 23. 3. Queion: Thi queion conider he cenario of dnamicall-eoling capaciie in a neork. We ar ih a fied neork N = (G = (V, E), c,, ), and compue a maimum flo f for N. Hoeer a an ime in he fuure e ma receie noificaion ha he capaci of a paricular arc in he neork i being increaed b 1 (or decreaed b 1). To queion: (a) Suppoe ha he capaci of a ingle edge (u, ) E i increaed b 1. Gie a O( V + E )-ime algorihm hich updae f o obain a ma flo f for he updaed neork. (b) Suppoe ha he capaci of a ingle edge (u, ) E i decreaed b 1. Gie a O( V + E )-ime algorihm hich updae f o obain a ma flo f for he updaed neork. Aner: (fairl hard) (a) Suppoe ha e hae a ma flo f for he neork N, and ha e are old ha a paricular edge (u, ) i haing i capaci increaed b 1. Fir obere ha hi increae canno *decreae* he ma flo of he neork - clearl eer flo in he original neork i a flo in he modified neork. The increae in (u, ) capaci ma or ma no *increae* he ma flo. Le N be he modified neork (ame a N ecep (u, ) ha capaci c(u, ) + 1). Conider he flo f in he neork N, and le N f be he reidual neork. I claim ha f i a ma flo in N if and onl if here i *no* augmening pah in N f. Hence e hae he folloing algorihm o updae he ma flo hen he capaci of an edge i increaed b 1: 1. Take he original ma flo f and compue N f. 2. Search for an augmening pah in N f. 3. If e find an augmening pah p, reurn f + f p a he ma flo for he updae neork. OTHERWISE if e find no augmening pah, reurn f. The algorihm i correc for he folloing reaon. Fir if here i no augmening pah in N f, hen b Corollar 1 of lecure lide 13-1, f i a ma flo. Second, if here i an augmening pah p in N f, hen (i) The capaci c(p) of p in N f i 1 (if i a greaer han hi, f could no hae been a ma flo for N). (ii) Define f = f + f p. Then N f ha no augmening pah (ame reaon a for (i)). Hence in he cae here N f doe hae an augmening pah p, e kno ha f = f+f p i a ma flo of N.

Thi algorihm can be eecued in he ime i ake o conruc he reidual neork O( V + E ), and he ime i ake o find one augmening pah (O( V + E ) b breadh-fir earch). Hence i i O( V + E ) in oal. (b) If e decreae he alue of (u, ) b 1 from i original alue in N, hen he ma flo of he updaed neork N can be no greaer han he ma flo of N (and poibl le). If i i he cae ha he ma flo f of N aifie f(u, ) < c(u, ), hen f ill alo be a flo (and hence he ma flo) in N (here (u, ) ha capaci c(u, ) 1). Hoeer, if e had f(u, ) = c(u, ) in N, hen he ma flo of N migh hae alue ricl le han f. Here i our algorihm. 1. If e had f(u, ) < c(u, ) in N, hen f i a (ma) flo in N. Reurn f. 2. OTHERWISE (if e had f(u, ) = c(u, )). (i). Find a imple pah p1 in N f from u o. (ii). Find a imple pah p2 in N f from o. (iii). Take he pah p2, (, u), p1 in N f, and roue 1 uni of flo from o along hi pah. Adding hi o f, e ge a ne flo f of alue f 1 in N, ih f (u, ) < c(u, ). Hence f i a flo in N alo. (i) Finall perform a earch in N f for an augmening pah. () If e find an augmening pah p in N f, reurn he flo f + f p (of alue f ). (i) Oherie, reurn f. Noe ha a reidual neork onl keep edge ih ricl +e alue (nb for (iii)). The running ime of he algorihm i O( V + E ) (ame reaon a for (a) ecep e ma do 3 breadh-fir earche, in (i), (ii), (i), here).. Queion: A ell-knon problem in graph heor i he problem of compuing a maimum maching in a biparie graph G. Gie an algorihm hich ho ho o ole hi problem in erm of he neork flo problem. Definiion: A (undireced) graph G = (V, E) i biparie if e hae V = L R for o dijoin e L, R, uch ha for eer edge e = (u, ) eacl one of he erice u, lie in L, and he oher in R. A maching in an (undireced) graph G i a collecion M of edge, M E, uch ha for eer ere V, belong o a mo one edge of M. A maimum maching i a maching of maimum cardinali (for a pecific graph). Aner: To ole hi queion, e ill deign a neork, baed on he biparie graph G, here a maimum flo in he neork correpond o a maimum maching in G. Define he ere e V for our neork N o be V = L R {, }, here, are o ne diinguihed erice. 5

Define he (direced) edge e E a follo: E = {(, u) : u L} {(u, ) : u L, R, (u, ) E} {(, ) : R}. noice ha he middle e in he union aboe i ju he edge e E of he original graph, ih all of hee edge no direced from L o R. Define he capaciie of he neork a follo: c(, u) = 1 c(u, ) = 1 c(, ) = 1 for eer u L for eer u L, R, (u, ) E for eer R I no claim ha eer flo of alue k in N correpond o a maching of cardinali k in G. The ma flo = maimum maching follo direcl from hi. Suppoe f i a flo of alue k in N. We aume ihou an lo of generali ha f i an inegral flo (becaue all capaciie are ineger). Recall ha in N, he ere ha L neighboring edge (, u). B definiion of he alue of a flo, k = u V f(, u) = u L f(, u). Therefore eacl k of he (, u) edge carr 1 uni of flo each (ince no (, u) edge can carr more han 1). Moreoer b Lemma 11 in Lecure lide 13-1, eer (S, T) cu in he neork mu be carring flo of alue k. Hence if e ake S = {} L, hen e ee here are eacl k (u, ) edge in he neork hich carr eacl 1 uni of flo from lef o righ (ince no (u, ) edge can carr more han hi). Define M = {(u, ) E : f(u, ) = 1 in N}. Cerainl M = k. I no ho ha M i a maching. For eer u L, he flo coneraion proper mu hold. For hi neork, hi mean ha for eer u L, e require ( R f(u, )) + f(u, ) = 0. Therefore if f(, u) = 0, e require f(u, ) = 0 for eer (u, ) E. If f(, u) = 1 (o f(u, ) = 1), e require f(u, ) = 1 for eacl one (u, ) E (uing our ineger aumpion). Hence eer u L ill appear a mo once in M. We can ue a imilar argumen o ho ha eer R can appear a mo once in M. Hence M i a maching. Thi i eaier. Ju eplain ho he maching of G ge mapped o N and check flo coneraion. Mar Cran 6