Download presentation
Presentation is loading. Please wait.
Published byAnnice Newman Modified over 8 years ago
1
CS 312: Algorithm Analysis Lecture #27: Network Flow This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.Creative Commons Attribution-Share Alike 3.0 Unported License Slides by: Eric Ringger, with contributions from Mike Jones
2
Announcements Project #5: Gene Sequence Alignment Due: today Homework #19, 20 due HW 20 problem 3 moved to Monday For you, what was the hardest step in formulating the solution to the longest common sub-sequence problem? Project #6: Linear Programming Help session: maybe Monday HW #21: problem formulation for Proj. #6 Due Monday
3
Objectives Review Standard Form (after step #2) Consider the Network Flow problem Work through a Simplex-like algorithm for maximizing flow Understand the intuition behind “slack”
4
Standard Form Step #2 Introduce slack variable s i to produce an equality constraint from the i-th -constraint: What are these slack variables? What do they represent? What is their purpose? We’ll get some intuition by examining network flow …
5
Network Flow Problem Given a weighted DAG. G = {V, E} Weights represent max capacity of an edge. s = source, t = sink V Goal: Maximize flow from s to t Why limited to only one source and one sink? s b d t 46 21 3 We can transform a multiple source problem into a single source problem by adding a “super” source that feeds into the old sources with large weights. Ditto for sinks
6
Network Flow as LP s b d t 46 21 3
8
s b d t 46 21 3 What is the LP problem for this Network Flow Problem? Objective: Constraints:
9
1.Choose a path. 2.Increase flow as much as possible on that path 3.Repeat until no paths remain Toward the Simplex Algorithm for Max Flow s b d t 46 21 3 Let’s try a simple greedy algorithm:
10
Toward the Simplex Algorithm for Max Flow 1.Choose a path. 2.Increase flow as much as possible on that path 3.Repeat until no paths remain Pick s,b,t first s b d t 46 21 3
11
1.Choose a path. 2.Increase flow as much as possible on that path 3.Repeat until no paths remain Toward the Simplex Algorithm for Max Flow Could we have tried another path to begin with? s b d t 46 21 3
12
Toward the Simplex Algorithm for Max Flow 1.Choose a path. 2.Increase flow as much as possible on that path 3.Repeat until no paths remain What if we’d chosen s,d,t first? s b d t 46 21 3
13
Toward the Simplex Algorithm for Max Flow s b d t 4 6 2 1 3 1.Choose a path. 2.Increase flow as much as possible on that path 3.Repeat until no paths remain What if we’d chosen s,b,d,t first?
14
Moral of the Story The above naïve greedy algorithm can lead to sub-optimal results. We would still like to be able to pick any path without any commitment to analyze paths carefully. But we require an algorithm giving optimal flow. We need a way to give back or undo the blocking flow (e.g., from b to d) -- without “back-tracking” s b d t 4 of 43 of 6 0 of 21 of 1 1 of 3
15
Max Flow Algorithm s b d t 1 of 46 0 of 2 1 of 1 1 of 3 What we hadWhat we want s b d t 1 of 41 of 6 1 of 2 1 of 1 1 of 3 1
16
In the Original Graph What really happens in the original graph: flow on (s,b) is re-routed to (b,t) instead of through b,d,t flow from (s,d) is sent along (d,t), but we don’t have to think about re-routing we’re just allocating flow in an updated graph without consideration of what we did before. s b d t 1 of 41 of 6 1 of 2 1 of 1 1 of 3 1
17
Simplex for Max Flow s b d t 1 of 40 of 6 1 of 1 1 of 3 Network after maximizing s,b,d,t 0 of 2
18
Simplex for Max Flow Network after maximizing s,b,d,t Residual (or slack) network s b d t 3 6 2 2 1 0 1 s b d t 1 of 40 of 6 1 of 1 1 of 3 0 of 2
19
Simplex for Max Flow s b d t 1 of 40 of 6 1 of 1 1 of 3 Network after maximizing s,b,d,t 0 of 2 Residual (or slack) network s b d t 3 6 2 2 1 0 Do: Choose new simple path with non-0 capacity on every edge (How?) Take up slack (i.e., residual capacity) along the new path Transform the problem from G to G R Until we find no more slack (i.e., residual capacity) in the network. 1
20
Simplex for Max Flow s b d t 3 6 2 2 1 0 1
21
Flow Schedule Book-keeping: accumulate flow along each original edge OR: just check the reverse edges!
22
Max Flow Algorithm
23
Status We have a working version of a simplex-like algorithm for Max Flow Take up slack Transform the problem Iterate Simplex has these basic steps as well Simplex will focus on one constraint at a time. Next time: more examples
24
Assignment HW #20 Due: Friday Problem #7.10 is a network flow problem Read about “min cut” in order to be able to answer the whole question.
25
Example: Optimum Bandwidth Allocation Communications network between three users A,B, and C with bandwidths as shown:
26
Variables: x AB = short path bandwidth allocated to the connection between A & B x AB ’ = long path bandwidth allocated to the connection between A & B Likewise for BC And AC Example: Optimum Bandwidth Allocation
27
Objective: Constraints on “last mile” network bandwidth: Constraints on Inner network bandwidth: Constraints on Customer bandwidth: Non-negativity constraints: Example: Optimum Bandwidth Allocation
28
Solution (via Simplex) Example: Optimum Bandwidth Allocation
29
Issues: One variable for every possible path between the users. What’s the problem?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.