Lecture 2: Network Flow. c 14

Similar documents
Graduate Algorithms CS F-18 Flow Networks

CSC 373: Algorithm Design and Analysis Lecture 9

Solutions to assignment 3

Maximum Flow. Flow Graph

Minimum Squared Error

Minimum Squared Error

e t dt e t dt = lim e t dt T (1 e T ) = 1

4.8 Improper Integrals

CS 491G Combinatorial Optimization Lecture Notes

Flow Networks Alon Efrat Slides courtesy of Charles Leiserson with small changes by Carola Wenk. Flow networks. Flow networks CS 445

Released Assessment Questions, 2017 QUESTIONS

1 The Network Flow Problem

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

22: Union Find. CS 473u - Algorithms - Spring April 14, We want to maintain a collection of sets, under the operations of:

ANSWERS TO EVEN NUMBERED EXERCISES IN CHAPTER 2

Network Flows: Introduction & Maximum Flow

REAL ANALYSIS I HOMEWORK 3. Chapter 1

A LOG IS AN EXPONENT.

Contraction Mapping Principle Approach to Differential Equations

The solution is often represented as a vector: 2xI + 4X2 + 2X3 + 4X4 + 2X5 = 4 2xI + 4X2 + 3X3 + 3X4 + 3X5 = 4. 3xI + 6X2 + 6X3 + 3X4 + 6X5 = 6.

Mid-Term Examination - Spring 2014 Mathematical Programming with Applications to Economics Total Score: 45; Time: 3 hours

CS3510 Design & Analysis of Algorithms Fall 2017 Section A. Test 3 Solutions. Instructor: Richard Peng In class, Wednesday, Nov 15, 2017

0 for t < 0 1 for t > 0

Chapter Introduction. 2. Linear Combinations [4.1]

Bipartite Matching. Matching. Bipartite Matching. Maxflow Formulation

Motion. Part 2: Constant Acceleration. Acceleration. October Lab Physics. Ms. Levine 1. Acceleration. Acceleration. Units for Acceleration.

MTH 146 Class 11 Notes

ENGR 1990 Engineering Mathematics The Integral of a Function as a Function

INTEGRALS. Exercise 1. Let f : [a, b] R be bounded, and let P and Q be partitions of [a, b]. Prove that if P Q then U(P ) U(Q) and L(P ) L(Q).

Linear Quadratic Regulator (LQR) - State Feedback Design

18.06 Problem Set 4 Due Wednesday, Oct. 11, 2006 at 4:00 p.m. in 2-106

1 PYTHAGORAS THEOREM 1. Given a right angled triangle, the square of the hypotenuse is equal to the sum of the squares of the other two sides.

Lecture 6: Coding theory

Factorising FACTORISING.

Mathematics 805 Final Examination Answers

Forms of Energy. Mass = Energy. Page 1. SPH4U: Introduction to Work. Work & Energy. Particle Physics:

Section 5: Chain Rule

ALG 5.3 Flow Algorithms:

CIT 596 Theory of Computation 1. Graphs and Digraphs

Exact Minimization of # of Joins

( ) ( ) ( ) ( ) ( ) ( y )

Topics in Combinatorial Optimization May 11, Lecture 22

Designing A Fanlike Structure

Homework 5 for BST 631: Statistical Theory I Solutions, 09/21/2006

I 3 2 = I I 4 = 2A

1. Find a basis for the row space of each of the following matrices. Your basis should consist of rows of the original matrix.

Chapter 2: Evaluative Feedback

Surds and Indices. Surds and Indices. Curriculum Ready ACMNA: 233,

(b) 10 yr. (b) 13 m. 1.6 m s, m s m s (c) 13.1 s. 32. (a) 20.0 s (b) No, the minimum distance to stop = 1.00 km. 1.

1.0 Electrical Systems

More on Magnetically C Coupled Coils and Ideal Transformers

Properties of Logarithms. Solving Exponential and Logarithmic Equations. Properties of Logarithms. Properties of Logarithms. ( x)

Counting Paths Between Vertices. Isomorphism of Graphs. Isomorphism of Graphs. Isomorphism of Graphs. Isomorphism of Graphs. Isomorphism of Graphs

Graph Theory. Simple Graph G = (V, E). V={a,b,c,d,e,f,g,h,k} E={(a,b),(a,g),( a,h),(a,k),(b,c),(b,k),...,(h,k)}

Graphs III - Network Flow

5.1-The Initial-Value Problems For Ordinary Differential Equations

Numbers and indices. 1.1 Fractions. GCSE C Example 1. Handy hint. Key point

Project 6: Minigoals Towards Simplifying and Rewriting Expressions

T b a(f) [f ] +. P b a(f) = Conclude that if f is in AC then it is the difference of two monotone absolutely continuous functions.

September 20 Homework Solutions

SOME USEFUL MATHEMATICS

6.5 Improper integrals

Chapter 2 The Derivative Applied Calculus 107. We ll need a rule for finding the derivative of a product so we don t have to multiply everything out.

Global alignment in linear space

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)

Necessary and sucient conditions for some two. Abstract. Further we show that the necessary conditions for the existence of an OD(44 s 1 s 2 )

5. Network flow. Network flow. Maximum flow problem. Ford-Fulkerson algorithm. Min-cost flow. Network flow 5-1

An integral having either an infinite limit of integration or an unbounded integrand is called improper. Here are two examples.

EXERCISE - 01 CHECK YOUR GRASP

CSE 332. Sorting. Data Abstractions. CSE 332: Data Abstractions. QuickSort Cutoff 1. Where We Are 2. Bounding The MAXIMUM Problem 4

Solutions for HW9. Bipartite: put the red vertices in V 1 and the black in V 2. Not bipartite!

Problem Set 9 Due December, 7

Section 1.3 Triangles

Solutions for Assignment 2

Proportions: A ratio is the quotient of two numbers. For example, 2 3

Fall 2014 David Wagner 10/31 Notes. The min-cut problem. Examples

Data Structures LECTURE 10. Huffman coding. Example. Coding: problem definition

dt = C exp (3 ln t 4 ). t 4 W = C exp ( ln(4 t) 3) = C(4 t) 3.

I1 = I2 I1 = I2 + I3 I1 + I2 = I3 + I4 I 3

two values, false and true used in mathematical logic, and to two voltage levels, LOW and HIGH used in switching circuits.

Some basic notation and terminology. Deterministic Finite Automata. COMP218: Decision, Computation and Language Note 1

Main Reference: Sections in CLRS.

Solutions to Problem Set #1

How to Prove the Riemann Hypothesis Author: Fayez Fok Al Adeh.

Some Inequalities variations on a common theme Lecture I, UL 2007

Now we must transform the original model so we can use the new parameters. = S max. Recruits

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

PHYSICS 1210 Exam 1 University of Wyoming 14 February points

for all x in [a,b], then the area of the region bounded by the graphs of f and g and the vertical lines x = a and x = b is b [ ( ) ( )] A= f x g x dx

1. Consider a PSA initially at rest in the beginning of the left-hand end of a long ISS corridor. Assume xo = 0 on the left end of the ISS corridor.

Boyce/DiPrima 9 th ed, Ch 6.1: Definition of. Laplace Transform. In this chapter we use the Laplace transform to convert a

Data Compression Techniques (Spring 2012) Model Solutions for Exercise 4

38 Riemann sums and existence of the definite integral.

Classification of Equations Characteristics

An object moving with speed v around a point at distance r, has an angular velocity. m/s m

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

Review for the Midterm Exam.

Section 2.1 Special Right Triangles

Logarithms LOGARITHMS.

PAIR OF LINEAR EQUATIONS IN TWO VARIABLES

Transcription:

Comp 260: Avne Algorihms Tufs Universiy, Spring 2016 Prof. Lenore Cowen Srie: Alexner LeNil Leure 2: Nework Flow 1 Flow Neworks s 16 12 13 10 4 20 14 4 Imgine some nework of pipes whih rry wer, represene s grph where noes re junions n eges re pipes. Now imgine wer is oming in noe s n I wn o ge s muh wer s possile o. Junions (noes) oviously n sore wer. The ege weighs re flow piies, he volume of wer whih n rverse ny given pipe per uni ime. Then his grph is flow nework, formlly: iree grph G = (V, E) suh h G onins soure noe s n sink noe. every verex v V is on some ph from s o every ege (u, v) hs piy 0 noes hve no sorge piy. Noe: There exis generlizions of his prolem where here is sorge he noes. We ren going o over hem. 1

1.1 Flow Funions Definiion 1.1.1. A flow f in nework G is funion h ssigns rel numers o iree eges numers suh h he following onsrins re sisfie: Cpiy Consrin: I n pu more suff in he pipes hn will fi, i.e. for ll (u, v) E, f(u, v) (u, v) (where is piy). Skew Symmery: for ll (u, v) E, f(u, v) = f(v, u) Flow Conservion: for ll (u, v) whih re no s or, u v f(u, v) = 0 Definiion 1.1.2. The vlue of flow f, f = v V f(s, v) = u V f(u, ) Definiion 1.1.3. We n lso efine he flow ross ses of noes. If X n Y re ses of noes: f(x, Y ) = f(x, y) x X y Y Lemm 1.1.4. f(x, X) = 0 Lemm 1.1.5. f(x, Y ) = f(y, X) Lemm 1.1.6. if X Y = hen f((x Y ), Z) = f(x, Z) + f(y, Z) f(z, X Y ) = f(z, X) + f(z, Y ) Now imgine he following flow: (Cn you improve i?) s /16 /12 0/10 0/4 11/13 0/ / 16/20 11/14 4/4 2

The vlue of he ove flow f = 20. We inuiively know we n improve his flow. The es flow is elow: s 10/16 12/12 2/10 0/4 13/13 0/ / 1/20 11/14 4/4 The vlue of his flow is 23. We know we n o eer hn 24 sine he egree of he inoming eges o is 24, u i urns ou 23 is our mximum. For lrger neworks, where inuiion is iffiul, we use lgorihms. To explin his lgorihm, we nee o inroue noher kin of flow nework. 1.2 Resiul Neworks Consier he firs of he wo flows, he su-opiml flow. Imgine flow nework whih ouns he ville flow lef in he originl flow nework: s 2 10 4 3 4 3 An furher imgine we e kwrs negive eges o inie wh flow oul e reverse if nee e. 3

s 11 16 11 4 Definiion 1.2.1. : G f (V, E f ) suh h The resiul nework is flow nework, enoe E f = {(u, v) C f (u, v) > 0} where C f (u, v) = (u, v) f(u, v) Sine he resiul nework is kin of flow nework, i lso ies y he properies of flow neworks. Le s visulize he enire resiul nework. s 11 3 16 2 10 4 4 11 4 3 There exiss simple rule for improving flow using resiul neworks: If G f onsins ph p from s o hen p is n ugemening ph wih respe o he flow h forme G f. If we fin suh n ugmening ph, we n inrese he vlue of f [f]+(p) where (p) = min{ f (u, v)for(u, v) p}. 4

1.3 Grph Cuing When we si we n o eer hn 24, we were looking he inoming piy for. In some sense, we were uing he grph, sepring from he reminer of he nework, n exmining he mximum possile flow ross he ounry. Formlly: Definiion 1.3.1. A u of G(V, E) is priion of V ino S n T suh h s S is on one sie of u n T is on he oher sie of he u. S T = V ; S T = This efiniion egs he quesion: how muh n I push ross ounry? Definiion 1.3.2. The piy of u (S, T ), (S, T ) = w S v T (u, v) We look muliple us of our exmple nework n mesure he piy of eh u. I s usully in he mi-20s or upper-20s. A is minimum, i s 23. We n lso exmine, given flow, he flow over he u (s oppose o he mximum flow piy of h u). Clim 1.3.3. Any u sepring s from hs he ol flow from s o s he flow over he u. Clim 1.3.4. Any priion of he flow nework (even non-oninuous us), hs he ol flow from s o s he flow over he priion. Try i wih he flows we efine ove. I s unnny. 5

1.4 Mx-Flow, Min-Cu Theorem 1.4.1. Mx-Flow Min-Cu Theorem: Given nework G(V, E) n flow f, he following re equivlen: 1. f is mximum flow in G 2. The resiul nework G f onsins no ugmening phs 3. u suh h he vlue of he flow equls he piy of he u: f = (S, T ) This implies h he minimum u n he mximum flow mee in he mile. This is prigm lle uliy, whih is exremely powerful in lgorihms. This prolem is speil euse we n ge i in polynomil ime. A lo of hese sors of prolems re NP-hr. Proof. Proof sruure: 1 2. 2 3. 3 1. This will prove hey re ll equivlen. 1 2: If here were n ugmening ph, we n inrese he flow. Hene if f is he mximum flow, hen here oes no exis n ugmening ph. 2 3: If G f hs no ugmening ph, here is no onnee ph from s o in G f. Le S = {v V v is rehle from s G f }. Le T = V S. Th s he u. Noie h s S u / S. Then he flow over he u is he vlue of he flow: u S, v T, f(u, v) = (u, v) f = f(s, T ) = f(u, v) = (u, v) = (S, T ) u U v V u U v V 6

3 1: Assume h I hve u whose piy is he vlue of he flow; f = (S, T ) This is he u where our es flow uses ll he piy ross h u, mening he resiul nework is ionnee long his u. We know he flow from s o is oune ove y he piy of his u: f (S, T ) u we lso know h f = (S, T ). Le f e flow h hieves he mximum possile vlue. Then: f f (S, T ) hen f = f 1.5 For-Fulkerson Algorihm Algorihm: Inpu: G, s, 1. Iniie flow f o 0. 2. While here exiss n ugmening ph p in G f : Augmen f long p. 3. Reurn f. This lgorihm lwys ermines n lwys eermines he mx flow, u i isn h effiien. Complexiy of fining n ugmening ph is oune ove y O(E) (BFS). The while loop ourrs O( f ) imes mos, mening he omplexiy of his lgorihm is O(E f ) This n hve runime in he se where here re oh lrge n smll flow piies in he sme nework. Here s onrive exmple h emonsres when For-Fulkerson migh e hevily su-opiml.

s 1M 1M 1 1M 1M If we hoose he ugmening ph from s o h psses hrough ege (, ) we only inrese he flow y 1. We n hen hoose he ugmening ph hrough (, ) n inrese he flow y 1 gin. Alerning in his wy, i will ke us M seps o ge up o he mx flow of M. Noie if we h gone irely from s hrough o we woul hve goen o M in one sep! Cn we hoose he es ugmening ph inse of jus n ugmening ph? Wh if we lwys hoose he shores ugmening ph firs? where shores is he les numer of eges irregrless of ege weigh. 1.6 Emons-Krp Algorihm Algorihm: Inpu: G, s, 1. Iniie flow f o 0. 2. While here exiss n ugmening ph p in G f : Augmen f long he shores of he ugmening phs, oune in numer of hops. 3. Reurn f. Clim: If his lgorihm is run on flow nework wih soure s n sink, hen for ll veries v V {s, }, he shores ph isne from s o v n only inrese in he resiul nework. 8

Proof. Proof y onriion: Suppose No. Consier f f, he firs ime he resiul nework isne from s o v ereses in n ierion of Emons-Krp. Wihou loss of generliy, le v e loses verex o s for whih his ours, n le u e he immeie preeessor of v in he new shores ph in E f. s...... u v If he resiul nework isne (numer of hops) from s o v lowere in n ierion, hen n ege mus hve ppere in he resiul nework whih ypsse some numer of eges whih use o e pr of he shores ph from s o v. So (u, v) E f u (u, v) / E f euse he shores ph from s o u in f n f re ienil in lengh (oherwise we woul hve hosen u o e our v). So Ef (s, u) = Ef (s, u). Suppose (u, v) exise in E f. Then Ef (s, v) Ef (s, u) + 1 = Ef (s, v), u we ssume he isnes from s o v ws GREATER in E f, onriion! Now, s resul of his propery of Emons-Krp, we n mke sserions ou is sympoi performne. Bu firs, we ll nee noher efiniion: Definiion 1.6.1. We sy ege (u, v) in resiul nework G f is riil on ugmening ph p, if he resiul piy of p is he resiul piy of (u, v). Theorem 1.6.2. Emons-Krp is oune ove y O( V E ) ierions. Proof. Le u, v e veries in V onnee y n ege in E. We lim h: From he ime (u, v) is riil o he ime i s riil gin, he isne o s mus inrese y 2 eges. Le f e he flow where (u, v) is firs riil. Th mens (u, v) is on he shores ph, hen i vnishes. I n ome k unil v, u is on he shores ph, u if v, u is on he shores ph, hen s v is reple wih s u.

Le E f e he resiul nework for flow f where (u, v) goes riil. Then (u, v) is missing in E f ; for i o repper in some ler f s ugmening ph, hen some ugmening ph pushes flow from v o u, i.e. (v, u) mus e on he shores ph from s o in E f, in oher wors E f (s, u) = E f (s, v)+1. (*) Bu, y he lim ove, sine isnes only inrese in he resiul neworks, we hve E f (s, u) Ef (s, u) so susiuing ino (*) we ge Ef (s, u) E f (s, v) + 1 so Ef (s, u) E f (s, u) + 2. Sine he isne from s o u inreses y les wo eges every ime (u, v) eomes riil, hen he ege n eome riil mos V /2 1 imes. If eh ege n eome riil mos O( V ) imes, hen he runime of Emons-Krp is oune ove y O( V E ). Emons-Krp is jus one wy o speify whih ugmening ph you ke eh ime, so in some sense i s merely speifi wy of running For- Fulkerson. However, epening on he relive sizes of f n V, eiher he oun O(E f ) from our originl nlysis of For-Fukerson or our new oun of O( V E ) on he numer of ierions migh e eer oun on he performne of Emons-Krp, epening on how lrge he mximum flow vlue ully is. 10