Flow networks 2 5 How much flow can
- Slides: 29
Flow networks 2 5 How much flow can we push through from s to t ? (Numbers are capacities. ) 1 4 7 3 5 2
2 Flow networks 5 s 1 4 7 3 5 Def: t 2 A flow network is a directed graph G=(V, E) where edges have capacities c: E->R+. There are two specified vertices s (source) and t (sink). A flow f: E->R must satisfy: • Capacity constraint: for every edge e: f(e) · c(e) • Flow conservation : for every v in V-{s, t}: e out of v f(e) = e into v f(e) The value of the flow is: e out of s f(e)
Maximum flow problem 2 Input: a flow network G=(V, E), with capacities c, the source s and sink t Output: a maximum-value flow Algorithm ? 5 s 1 4 7 3 5 t 2
Maximum flow problem – Ford-Fulkerson “Def”: 2 Given a flow f, an augmenting path is a path s=v 1, v 2, …, vk=t such that s f(vi, vi+1) < c(vi, vi+1) for i=1, …, k-1 5 1 4 2 3 5 Ford-Fulkerson ( G=(V, E), c, s, t ) 1. Initialize flow f to 0 2. While exists augmenting path p do 3. Augment flow f along p 4. Return f t 7
Maximum flow problem – Ford-Fulkerson 2 “Def”: Given a flow f, an augmenting path is a path s=v 1, v 2, …, vk=t such that s f(vi, vi+1) < c(vi, vi+1) for i=1, …, k-1 5 1 4 2 3 5 How to find augmenting paths ? Ford-Fulkerson ( G=(V, E), c, s, t ) 1. Initialize flow f to 0 2. While exists augmenting path p do 3. Augment flow f along p 4. Return f t 7
Maximum flow problem – Ford-Fulkerson “Def”: Given is G=(V, E), c, f. The residual graph has edges s weighted by the residual capacities, i. e. cf(e) = c(e)-f(e) 2 5 1 4 2 3 Ford-Fulkerson ( G=(V, E), c, s, t ) 1. Initialize flow f to 0 2. While exists augmenting path p do 3. Augment flow f along p 4. Return f 5 t 7
Maximum flow problem – Ford-Fulkerson 2 “Def”: Given is G=(V, E), c, f. The residual graph has edges s weighted by the residual capacities, i. e. cf(e) = c(e)-f(e) 5 1 4 2 3 Idea: Find an s-t path in the residual graph! Ford-Fulkerson ( G=(V, E), c, s, t ) 1. Initialize flow f to 0 2. While exists augmenting path p do 3. Augment flow f along p 4. Return f 5 t 7
Maximum flow problem – Ford-Fulkerson Consider this input: 1000 s 1 1000 Ford-Fulkerson ( G=(V, E), c, s, t ) 1. Initialize flow f to 0 2. While exists augmenting path p do 3. Augment flow f along p 4. Return f t 1000
Maximum flow problem – Ford-Fulkerson Consider this input: 1000 Need to refine the definition of augmenting paths and residual graph. s 1 1000 Ford-Fulkerson ( G=(V, E), c, s, t ) 1. Initialize flow f to 0 2. While exists augmenting path p do 3. Augment flow f along p 4. Return f t 1000
Maximum flow problem – Ford-Fulkerson Refined def: Given is G=(V, E), c, f. The residual graph Gf=(V, E’) contains the following edges: • forward edge: if e 2 E and f(e) < c(e) then include e in E’ with weight cf(e) = c(e)-f(e), • backward edge: if e=(u, v) 2 E with f(e)>0 then include (v, u) in E’ with weight cf(v, u) = f(v, u). 1000 s 1 1000 t 1000
Maximum flow problem – Ford-Fulkerson 1000 s 1 1000 t 1000
Maximum flow problem – Ford-Fulkerson ( G=(V, E), c, s, t ) 1. For every edge e let f(e)=0 2. Construct the residual graph Gf 3. While exists s-t path in Gf do 4. Let p be an s-t path in Gf 5. Let d=mine in p cf(e) 6. For every e on p do 7. If e is a forward edge then 8. f(e)+=d 9. else 10. f(reverse(e))-=d 11. Update Gf (construct new Gf) 12. Return f
Maximum flow problem – Ford-Fulkerson ( G=(V, E), c, s, t ) 1. For every edge e let f(e)=0 2. Construct the residual graph Gf 3. While exists s-t path in Gf do 4. Let p be an s-t path in Gf 5. Let d=mine in p cf(e) 6. For every e on p do 7. If e is a forward edge then 8. f(e)+=d 9. else 10. f(reverse(e))-=d 11. Update Gf (construct new Gf) 12. Return f Running time:
Maximum flow problem – Ford-Fulkerson Lemma: 2 5 Ford-Fulkerson works. s 1 4 1 3 5 Ford-Fulkerson ( G=(V, E), c, s, t ) 1. Initialize flow f to 0 2. While exists augmenting path p do 3. Augment flow f along p 4. Return f t 7
Maximum flow problem – Ford-Fulkerson 2 Lemma: 5 Ford-Fulkerson works. s Def: Given G=(V, E), c. An s-t cut of G is a subset of vertices S s. t. s 2 S and t 2 SC. Its value is e out of S c(e) 1 4 7 3 5 t 2
Maximum flow problem – Ford-Fulkerson 2 Lemma: 5 Ford-Fulkerson works. s Let min-cut(G) be the minimal value of an s-t cut of G. Then: iff 4 7 3 The Max-flow min-cut theorem: f is a maximum flow 1 5 value(f)=min-cut(G) t 2
Improving Ford-Fulkerson Can find better paths to reduce the running time? 2 5 s 1 4 7 3 5 Ford-Fulkerson ( G=(V, E), c, s, t ) 1. Initialize flow f to 0 2. While exists augmenting path p do 3. Augment flow f along p 4. Return f t 2
Improving Ford-Fulkerson Can find better paths to reduce the running time? - many ways, will discuss one: BFS 2 5 s 1 4 7 3 5 t 2 Edmonds-Karp ( G=(V, E), c, s, t ) 1. Initialize flow f to 0 2. While exists augm. path p (check with BFS) do 3. Augment flow f along p 4. Return f
Improving Ford-Fulkerson 2 Can find better paths to reduce the running time? - many ways, will discuss one: BFS 5 s 1 4 7 3 5 t 2 Thm: Edmonds-Karp takes O(|V||E|) iterations. Running time of Edmonds-Karp: Edmonds-Karp ( G=(V, E), c, s, t ) 1. Initialize flow f to 0 2. While exists augm. path p (check with BFS) do 3. Augment flow f along p 4. Return f
Applications of Network Flows • multiple sources, multiple sinks s 1 t 1 s 2 t 2 s 3 t 4
Applications of Network Flows • how to find minimum cut 2 5 s 1 4 7 3 5 t 7
Applications of Network Flows • maximum number of edge-disjoint s-t paths s t
Applications of Network Flows • maximum bipartite matching
Applications of Network Flows • maximum weighted (perfect) bipartite matching 7 5 2 3 4 4 1 6 3 8
Introduction to Linear Programming Let’s write maximum flow as a math problem…
Introduction to Linear Programming The Diet Problem – another example of LP Input: m types of food F 1, …, Fm with unit costs b 1, …, bm n types of nutrients N 1, …, Nn with min. daily requirements c 1, …, cn ai, j amount of nutrient Nj contained in one unit of food Fi Objective: get the required nutrients at minimum cost
Introduction to Linear Programming A linear program looks like this: Find x 1, x 2, …, xm which • maximize c 1 x 1 + c 2 x 2 + … + c m x m • and satisfy these constraints: a 1, 1 x 1 + a 1, 2 x 2 + … + a 1, mxm · b 1 a 2, 1 x 1 + a 2, 2 x 2 + … + a 2, mxm · b 2 … an, 1 x 1 + an, 2 x 2 + … + an, mxm · bn
Introduction to Linear Programming A linear program in compressed form: Given a vector c in Rm, a vector b in Rn and a matrix A in Rn x m, find a vector x in Rm which satisfies x. AT · b and maximizes cx. T.
Introduction to Linear Programming A linear program in compressed form: Given a vector c in Rm, a vector b in Rn and a matrix A in Rn x m, find a vector x in Rm which satisfies x. AT · b and maximizes cx. T. Thm: Exists a polynomial-time algorithm solving linear programs. Caveat: Sometimes need integer programs (no algorithm for integer programs is likely to exist) !
- Virtual circuit vs datagram
- Basestore iptv
- How much caffeine is too much
- To whom much is given much is required meaning
- How much is too much plagiarism
- How much can they safely carry
- How much weight can a motor lift
- Can fanny play violin much worse
- How much can industry
- How much leaves and twigs an adult elephant can eat
- How much can you remember about last year
- Hedera: dynamic flow scheduling for data center networks
- If you can imagine it you can achieve it
- You can tell harris about it just ____(easily) as i can
- If you think you can you can poem
- If you cant measure it you cant improve it
- If you can't measure it you can't control it
- Can can body percussion
- The arrangement of element of curriculum is known as
- You can tell harris about it just ____(easily) as i can
- How to be more impressive 1+1=2
- You can speak english
- Look at the pictures and complete with can or can't
- The jean
- I know nothing is impossible
- You can t manage what you can t measure
- Talk en futuro
- Any fool can write code that a computer can understand
- Figure of speech in sonnet 18
- Was ist langfristiges fremdkapital