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

Similar documents
Maximum Flow. Flow Graph

CSC 373: Algorithm Design and Analysis Lecture 9

1 The Network Flow Problem

Graduate Algorithms CS F-18 Flow Networks

Solutions to assignment 3

Bipartite Matching. Matching. Bipartite Matching. Maxflow Formulation

LAPLACE TRANSFORMS. 1. Basic transforms

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

4.8 Improper Integrals

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)

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

Reminder: Flow Networks

Section P.1 Notes Page 1 Section P.1 Precalculus and Trigonometry Review

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

Randomized Perfect Bipartite Matching

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

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

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

Chapter Introduction. 2. Linear Combinations [4.1]

graph of unit step function t

Graphs III - Network Flow

Lecture 2: Network Flow. c 14

Algorithmic Discrete Mathematics 6. Exercise Sheet

Transformations. Ordered set of numbers: (1,2,3,4) Example: (x,y,z) coordinates of pt in space. Vectors

Jonathan Turner Exam 2-10/28/03

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

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

EECE 301 Signals & Systems Prof. Mark Fowler

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

CS4445/9544 Analysis of Algorithms II Solution for Assignment 1

1 Motivation and Basic Definitions

Robust Network Coding for Bidirected Networks

0 for t < 0 1 for t > 0

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

Bisimulation, Games & Hennessy Milner logic p.1/32

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

f(x) dx with An integral having either an infinite limit of integration or an unbounded integrand is called improper. Here are two examples dx x x 2

Discussion Session 2 Constant Acceleration/Relative Motion Week 03

Global alignment in linear space

Minimum Squared Error

Minimum Squared Error

Network Flows: Introduction & Maximum Flow

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

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

Mathematics 805 Final Examination Answers

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.

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

REAL ANALYSIS I HOMEWORK 3. Chapter 1

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

8.1. a) For step response, M input is u ( t) Taking inverse Laplace transform. as α 0. Ideal response, K c. = Kc Mτ D + For ramp response, 8-1

t s (half of the total time in the air) d?

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

CSCI565 - Compiler Design

Max-flow and min-cut

Max-flow and min-cut

6.8 Laplace Transform: General Formulas

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

Price Discrimination

Matching. Slides designed by Kevin Wayne.

Positive and negative solutions of a boundary value problem for a

Biol. 356 Lab 8. Mortality, Recruitment, and Migration Rates

Introduction to Congestion Games

Sph3u Practice Unit Test: Kinematics (Solutions) LoRusso

ANSWERS TO EVEN NUMBERED EXERCISES IN CHAPTER 2

ALG 5.3 Flow Algorithms:

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

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

Laplace Transform. Inverse Laplace Transform. e st f(t)dt. (2)

Designing A Fanlike Structure

Algorithm Design and Analysis

Contraction Mapping Principle Approach to Differential Equations

Problem Set 9 Due December, 7

() t. () t r () t or v. ( t) () () ( ) = ( ) or ( ) () () () t or dv () () Section 10.4 Motion in Space: Velocity and Acceleration

Released Assessment Questions, 2017 QUESTIONS

September 20 Homework Solutions

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

Maximum Flow in Planar Graphs

Sample Final Exam (finals03) Covering Chapters 1-9 of Fundamentals of Signals & Systems

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

Physics 240: Worksheet 16 Name

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

How to Solve System Dynamic s Problems

ON DIFFERENTIATION OF A LEBESGUE INTEGRAL WITH RESPECT TO A PARAMETER

18 Extensions of Maximum Flow

PHYSICS 1210 Exam 1 University of Wyoming 14 February points

Introduction to SLE Lecture Notes

Soviet Rail Network, 1955

arxiv: v1 [cs.cg] 21 Mar 2013

Linear Quadratic Regulator (LQR) - State Feedback Design

PSAT/NMSQT PRACTICE ANSWER SHEET SECTION 3 EXAMPLES OF INCOMPLETE MARKS COMPLETE MARK B C D B C D B C D B C D B C D 13 A B C D B C D 11 A B C D B C D

PHYSICS 211 MIDTERM I 22 October 2003

Magnetostatics Bar Magnet. Magnetostatics Oersted s Experiment

How to prove the Riemann Hypothesis

3 Motion with constant acceleration: Linear and projectile motion

Main Reference: Sections in CLRS.

EE Control Systems LECTURE 2

Predator - Prey Model Trajectories and the nonlinear conservation law

P a g e 5 1 of R e p o r t P B 4 / 0 9

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

MTH 146 Class 11 Notes

Transcription:

CS 7 Algorihm Fll 24 Dvid Wgner /3 Noe The min-u problem Le G = (V,E) be direed grph, wih oure verex V nd ink verex V. Aume h edge re lbelled wih o, whih n be modelled o funion : E N h oie non-negive inegrl o (e) o every edge e E. A (,)-u (L,R) i wy of priioning he verie ino wo dijoin e L nd R, o h L R = V, L, nd R. (From here on, we will imply ll hi u.) The o of u i he um of he o of he edge from L o R: (L,R) = u L,v R (u,v) E The min-u problem i o find minimum-o u in G. Exmple (u,v). Conider he following grph: b Here i minimum-o u in h grph: b CS 7, Fll 24, /3 Noe

Thi u i (L,R), where L = {,,b} nd R = {,}. The o of hi u i, ine i u he edge (b,), whih h o. Here i noher wy o look i. Conider he following phyil nlogy. We n hink of eh o- edge hough i were pring h rie o onr, nd eh o- edge hough i were n infiniely rehy eli bnd, like hi: b Now imgine king verex in your lef hnd, nd verex in your righ hnd, nd pulling hem pr from eh oher fr poible (leving he oher verie o flo freely). Wh going o hppen? Well, due o he igh pring onneing nd, verex will ry o y loe o poible. Similrly, verex will ry o y loe o. Thi pull lefwrd nd righwrd. Finlly, when we drw u down he middle, we ll ge piure like hi: b The pring onneing nd rie o mke nd y on he me ide of he u; ine i fored o be on he lef ide, hi i equivlen o ying h i rie o mke be on he lef ide of he u. Similrly, he pring beween nd rie o pull owrd he righ ide of he u. And h exly wh hppen. So, peking looely, we n hink of he min-u problem hough we hve nework of pring. Eh edge orrepond o pring of ome peifi enion: An edge lbelled wih o ple no onrin ll. I like he edge in preen ll. An edge wih poiive o i like pring of erin enion h rie o keep boh edge of he pring on he me ide of he u. The lrger he o, he hrder he pring pull, i.e., he lrger he o on n edge, he hrder we ry o keep boh end of he edge on he me ide of he u. CS 7, Fll 24, /3 Noe 2

Here i noher exmple, o illure hee priniple. On he lef i flow nework (we ue double-rrowed line beween nd o repreen wo direed edge, one from o b nd one in he revere direion, boh wih he me o), nd on he righ i orreponding pring nework: b b In hi exmple, we n ee h he pring beween nd rie o pull owrd he lef ide of he u; nd he pring beween nd b rie o keep hee wo edge on he me ide of he u, hu pulling b owrd he lef ide of he u. Th i exly wh hppen when we ompue he miniml-o u. However, one word of uion bou he pring nlogy i in order. In he ul min-o problem, he direion of eh edge mer, ine we only oun edge h go ro he u from lef o righ owrd he ol o of he u. Spring don hve direion, nd o n model h pe of he min-u problem. So he pring nlogy i reonble rough-pproximion wy o hink of he problem, bu only fir guide o he inuiion; i doen pure everyhing h i going on in he min-u problem. The overll inuiion i: when you hve n edge (u,v) wih poiive o, i rie o void puing u on he lef ide of he u nd v on he righ ide, ine doing o would inur o. Pu noher wy, n edge (u,v) of poiive o rie o eiher () pu boh u nd v on he me ide of he u, if poible, or (2) pu u on he righ ide of he u nd v on he lef ide, if poible. Of oure in grph wih mny edge i my no be poible o ify ll of hee ompeing demnd, bu he minimum-o u omehow rie o ify mny of hem poible. Algorihm There i righforwrd wy o ompue he min-o u, uing nework flow lgorihm. We re he o on eh edge piy, re he grph hough i were nework of oil pipeline, nd find he mximum flow from o in he grph. By he mx-flow-min-u heorem, he mximum-vlue flow orrepond o minimum-piy u, whoe piy will be he me he vlue of he flow. The proof of he mx-flow-min-u heorem ell u how o expliily idenify minimum-piy u. We ompue he reidul grph G r, find ll of he verie h re rehble from in he reidul grph (vi ome equene of edge of poiive reidul piy), nd pu hem on he lef ide of he u. All he oher verie go on he righ ide of he u. We proved erlier h hi form miniml-piy u. Finlly, noe h he piy of he u i equl o he o of he u ( defined erlier). Therefore, hi provide n effiien lgorihm for he min-u problem. CS 7, Fll 24, /3 Noe 3

A minor uion: hi lgorihm erhe for (,)-u, i.e., u h re onrined o ple he oure on he lef ide of he u nd re onrined o ple he ink on he righ ide of he u. (Reerher hve lo udied u problem where here i no oure or ink verex, nd where we wn o look ll u, regrdle of where ny verex end up; h i differen problem nd he be lgorihm for h problem urn ou o be prey differen. We won onider h problem ny furher here.) Appliion: imge egmenion Here i ne ppliion of he min-u problem. We hve m n pixel imge, I[..m,..n], where I[i, j] denoe he olor of he pixel row i nd olumn j. The piure inlude foreground obje (y, ree), in fron of bunh of bkground enery (ky, gr, e.). We re wriing n imge proeing ool, nd we wn o idenify he e of pixel oied wih he foreground obje. Thi k urn ou o be quie hllenging o do in purely uomed fhion, bu i beome eier if we k humn o help u. We k he uer o mrk he re of he foreground obje, hin. Le H[..m,..n] be m n boolen rry, where H[i, j] = rue for eh pixel (i, j) h he uer h mrked pr of he foreground obje. The uer hin re no perfe, bu we n ume h hey re orre for he overwhelming mjoriy of pixel. Alo, we n ume h if wo neighboring pixel hve pproximely he me olor, hen hey re likely pr of he me obje, nd hu likely eiher boh pr of he foreground, or boh pr of he bkground. The obje i o lify eh pixel eiher foreground or bkground, in wy h i onien poible wih he uer hin nd lo wih he me-olor informion. We n repreen hi lifiion m n boolen mrix F[..m,..n], where F[i, j] = rue if pixel (i, j) i lified pr of he foreground, or fle if h pixel i lified pr of he bkground. Bed upon he hin bove, we ll define he o of lifiion he um of he following hrge: I o $ for eh pixel (i, j) where our lifiion digree wih he uer hin, i.e., where F[i, j] H[i, j]. I o $ for eh pir of neighboring pixel (i, j),(i, j ) h hve imilr olor bu re lified differenly, i.e., where I[i, j] I[i, j ] bu F[i, j] F[i, j ]. The imge egmenion problem i follow: given I nd H, find he lifiion F whoe o i miniml. Here i oluion. We build grph wih one verex for eh pixel (i, j) in he imge. We lo dd peil oure verex nd ink verex v, o h he grph h nm + 2 verie in ll. We dd he following edge: For eh pixel (i, j) h he uer hined i pr of he foreground (i.e., where H[i, j] = rue), we dd n edge from o (i, j) of o. For eh pixel (i, j) h he uer hined i pr of he bkground (i.e., where H[i, j] = fle), we dd n edge from (i, j) o of o. CS 7, Fll 24, /3 Noe 4

For eh pir of neighboring pixel (i, j),(i, j ) wih imilr olor (i.e., where I[i, j] I[i, j ]), we dd n edge from (i, j) o (i, j ) of o, nd n edge in he revere direion lo of o. Finlly, we find he miniml-o u (L, R) in hi grph. Thi u yield lifiion: we lify eh pixel in L foreground, nd lify eh pixel in R bkground. Noe h he o of ny priulr u i he me he o of he orreponding lifiion, due o he wy we hve onrued he grph. For inne, if he u pu nd (i, j) on oppoie ide of he u, where he uer hined h (i, j) i foreground (i.e., where H[i, j] = rue), hi will inree he ol o of he u by, ine i u he edge from o (i, j). Thi orrepond o hrge of $ for lifying pixel (i, j) bkground when he uer h hined i hould be pr of he foreground. And o on. Conequenly, he miniml-o u i he me he miniml-o lifiion. The inuiion behind hi lgorihm i imple. The oure verex repreen he foreground, nd he ink verex repreen he bkground. When we wn pixel o be pr of he foreground, we dd n edge beween nd h pixel. The effe will be o ry o keep hem on he me ide of he u ( hough hey hd pring pulling hem ogeher), nd in priulr, o pull h pixel o he foreground ide of he u. When we wn pixel o be pr of he bkground, we dd n edge beween h pixel nd, whih h he effe of rying o pull hem boh o he bkground ide of he u. Finlly, when we wn wo neighboring pixel o be lified he me, we pu n edge beween hem, whih h he effe of rying o keep hem on he me ide of he u ( hough hey hd pring beween hem). Conequenly, he grph repreen he onrin we re rying o ify, nd he miniml-o u repreen he be oluion h obey mny of he onrin poible. Imge re-izing The bonu queion on Homework 9 (Q6) inrodued he imge re-izing problem: ke lrge imge, nd hnge i pe rio by mking i kinnier, wihou mking everyhing look unnurl nd wihou ropping ou imporn pr of he imge. The homework problem hllenged you o find oluion uing dynmi progrmming. I will how you noher oluion o hi problem, bed upon nework flow nd minimum u. You probbly remember he problem emen. We hve n imge I[..m,..n]. A er i equene of pixel h form onneed ph from he op of he imge o he boom of he imge. Conneed men h he pixel row i + i mo one poiion o he righ or lef of he pixel row i (i.e., he pixel row i + i eiher ouhe, ouh, or ouhwe of he pixel row i). Deleing er will re-ize he imge o m (n ) imge, yielding new imge h i one pixel nrrower. For eh pixel (i, j), we re given he o of deleing h pixel, nmely, o(i, j). The o of er i he um of he o of he pixel deleed. The gol i o find le-o er. To olve i, we ll define grph where he miniml-o u orrepond o he miniml-o er. The grph i grid wih one verex for eh pixel, long wih peil oure verex nd ink verex. The bi bkbone of he grph look like hi: CS 7, Fll 24, /3 Noe 5

Eh red edge i inended o repreen n edge whoe o i. The effe of red (infinie-o) edge from u o v i preven he u from puing u on he lef ide nd v on he righ (ine h would innly mke he o of he u be infinie); ny finie-o u will eiher pu u on righ, or v on he lef, or boh. If you look he pern of he red edge hown bove, i urn ou h hi men h he u will be onneed ph: when i goe from row i o row i +, i n move o he lef or righ by mo one pixel. For inne, onider hi hypoheil u, hown in blue: u v Noie h he edge from u o v ( lbelled in he piure) goe from he lef ide of he u o he righ ide of he u. Alo h edge h infinie o, whih men h he hypoheil u hown in blue h infinie o. Of oure, no infinie-o u n ever be miniml if here exi ny finie-o u, o he blue u hown bove will be exluded. On he oher hnd, he u below i no exluded by he red edge, nd indeed, i orrepond o onneed ph h doe no jump more hn poiion o he lef or righ in eh row: CS 7, Fll 24, /3 Noe 6

In ummry, he red edge enfore he onrin h er n only jump lef or righ by one poiion in eh row. To omplee he grph we dd n edge from eh pixel o he neighbor on i righ, hown in blk below. In oher word, we hve dded n edge from eh pixel (i, j) o i neighbor (i, j + ) o he immedie righ. We ign o o hi edge ording o he o of deleing pixel (i, j), i.e., he o of hi edge i o(i, j). (In he e of pixel on he righmo olumn of he imge, nmely pixel (i,n), we ign hi o o he edge from (i,n) o.) Finlly, we ompue he miniml-o u in hi grph. The miniml-o u mu hve he following form. In he fir row, i ple he lefmo x pixel, for ome vlue x, on he lef ide of he u, nd he remining pixel on he righ. In he eond row, i ple he lefmo x 2 pixel on he lef nd he reminder on he righ, for ome x 2. And o on. A rgued bove, we hve x x 2, nd generlly, x i x i+. Conequenly, eh u orrepond o vlid er, where he er i defined o be he e of pixel immediely o he lef of he er line (one pixel per row). The o of he u i he um of he righ-going edge h i u, whih orrepond o he um of he o of he pixel in he er. Conequenly, he miniml-o u in hi grph i exly he miniml-o er. Thi how how lgorihm for he minimum-u problem n be ued o reize imge uomilly. Even more beuifully, hi ide n be exended in righforwrd wy o reizing of video. We ry o find er in eh frme of video, uh h he wo er in wo oneuive frme re CS 7, Fll 24, /3 Noe 7

hifed from eh oher by mo ± poiion in eh row. Thi n be enoded minimum-u problem in grph where he pixel form 3-dimenionl ube (rher hn 2-dimenionl grid). I urn ou h hi provide pril nd effiien wy o uomilly reize video, whih i prey nify. CS 7, Fll 24, /3 Noe 8