Network Flow.

Slides:



Advertisements
Similar presentations
Maximum flow Main goals of the lecture:
Advertisements

COMP 482: Design and Analysis of Algorithms
Max Flow Problem Given network N=(V,A), two nodes s,t of V, and capacities on the arcs: uij is the capacity on arc (i,j). Find non-negative flow fij for.
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
MAX FLOW APPLICATIONS CS302, Spring 2013 David Kauchak.
Chapter 10: Iterative Improvement The Maximum Flow Problem The Design and Analysis of Algorithms.
1 Maximum Flow w s v u t z 3/33/3 1/91/9 1/11/1 3/33/3 4/74/7 4/64/6 3/53/5 1/11/1 3/53/5 2/22/2 
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
The Shortest Path Problem
MAX FLOW CS302, Spring 2013 David Kauchak. Admin.
Maximum Flow Chapter 26.
Network Flow How to solve maximal flow and minimal cut problems.
1 COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf.
Network Flow. Network flow formulation A network G = (V, E). Capacity c(u, v)  0 for edge (u, v). Assume c(u, v) = 0 if (u, v)  E. Source s and sink.
MAX FLOW APPLICATIONS CS302, Spring 2012 David Kauchak.
Max Flow – Min Cut Problem. Directed Graph Applications Shortest Path Problem (Shortest path from one point to another) Max Flow problems (Maximum material.
Chapter 7 April 28 Network Flow.
Chapter 7 May 3 Ford-Fulkerson algorithm Step-by-step walk through of an example Worst-case number of augmentations Edmunds-Karp modification Time complexity.
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
1 Network Flow CSC401 – Analysis of Algorithms Chapter 8 Network Flow Objectives: Flow networks –Flow –Cut Maximum flow –Augmenting path –Maximum flow.
Fall 2003Maximum Flow1 w s v u t z 3/33/3 1/91/9 1/11/1 3/33/3 4/74/7 4/64/6 3/53/5 1/11/1 3/53/5 2/22/2 
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
1 CPSC 320: Intermediate Algorithm Design and Analysis July 14, 2014.
A directed graph G consists of a set V of vertices and a set E of arcs where each arc in E is associated with an ordered pair of vertices from V. V={0,
Instructor Neelima Gupta Edited by Divya Gaur(39, MCS '09) Thanks to: Bhavya(9), Deepika(10), Deepika Bisht(11) (MCS '09)
Maximum Flow Chapter 26.
Shortest Paths.
The Maximum Network Flow Problem
Maximum Flow c v 3/3 4/6 1/1 4/7 t s 3/3 w 1/9 3/5 1/1 3/5 u z 2/2
Max-flow, Min-cut Network flow.
CS4234 Optimiz(s)ation Algorithms
Maximum Flow 9/13/2018 6:12 PM Presentation for use with the textbook, Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 2015.
CSCI 3160 Design and Analysis of Algorithms Tutorial 8
Network Flow.
Max Flow min Cut.
Special Graphs: Modeling and Algorithms
Bipartite Matching and Other Graph Algorithms
Graph Algorithm.
Max-flow, Min-cut Network flow.
Network Flow 2016/04/12.
Instructor: Shengyu Zhang
Maximum Flow c v 3/3 4/6 1/1 4/7 t s 3/3 w 1/9 3/5 1/1 3/5 u z 2/2
CSE Algorithms Max Flow Problems 11/21/02 CSE Max Flow.
Maximum Flow c v 3/3 4/6 1/1 4/7 t s 3/3 w 1/9 3/5 1/1 3/5 u z 2/2
Network Flow and Connectivity in Wireless Sensor Networks
Lecture 10 Network flow Max-flow and Min-cut Ford-Fulkerson method
Shortest Paths.
Richard Anderson Lecture 23 Network Flow
Richard Anderson Lecture 23 Network Flow
Richard Anderson Lecture 21 Network Flow
Flow Networks General Characteristics Applications
Flow Networks and Bipartite Matching
Max Flow Problem Given network N=(V,A), two nodes s,t of V, and capacities on the arcs: uij is the capacity on arc (i,j). Find non-negative flow fij for.
Algorithms (2IL15) – Lecture 7
Network Flow CSE 373 Data Structures.
EE5900 Advanced Embedded System For Smart Infrastructure
Max Flow / Min Cut.
Maximum Flow c v 3/3 4/6 1/1 4/7 t s 3/3 w 1/9 3/5 1/1 3/5 u z 2/2
Text Book: Introduction to algorithms By C L R S
Network Flow.
Lecture 21 Network Flow, Part 1
Richard Anderson Lecture 22 Network Flow
Shortest Paths.
Lecture 21 Network Flow, Part 1
Maximum Flow Neil Tang 4/8/2008
Special Graphs: Modeling and Algorithms
Network Flow.
Maximum Bipartite Matching
Richard Anderson Lecture 22 Network Flow
Presentation transcript:

Network Flow

Graph for Network Flow Source(s) – nodes with no incoming edge Sink(s) – nodes with no outgoing edge Edges in graph – no parallel edges Indicate maximum capacity that can flow through that edge Could be directed or not Max Flow: what is the maximum amount that can flow from the source to the sink? Min Cut: what is a cut through edges to partition the graph into two, where the sum of cut edges is minimized?

Floyd Fulkerson Max Flow Algorithm Basic idea: Find a path from source to sink Find minimum edge weight on that path Reduce all edges on path by that weight, add that amount to total flow BUT, this greedy strategy does not completely work! So, each time we reduce edge weights, we add (or increase weight of) a reverse edge showing “residual” capacity i.e. how much capacity could flow backward along that edge compared to best so far Now, can follow algorithm to completion

Max Flow: 19 4 10 10 2 8 6 10 10 9 Example from course found at algo.is

Greedy only (no new back edges) Total Flow: 0 4 10 10 2 8 6 10 10 9

Greedy only (no new back edges) Total Flow: 8 4 10 2 2 6 2 10 9

Greedy only (no new back edges) Total Flow: 8 4 10 2 2 6 2 10 9

Greedy only (no new back edges) Total Flow: 10 4 10 6 10 7

Greedy only (no new back edges) Total Flow: 10 4 10 6 10 7

Greedy only (no new back edges) Total Flow: 16 We are stuck, but max was 19! 4 4 4 1

Floyd Fulkerson Total Flow: 0 4 10 10 2 8 6 10 10 9

Floyd Fulkerson Total Flow: 8 4 10 2 8 2 6 8 8 2 10 9

Floyd Fulkerson Total Flow: 10 4 10 10 2 6 8 10 10 7 2

Floyd Fulkerson Total Flow: 16 4 4 10 6 2 6 8 10 6 4 1 8

Floyd Fulkerson Total Flow: 18 2 2 2 10 8 6 2 8 10 8 2 1 8

Floyd Fulkerson Total Flow: 19 1 1 3 10 9 1 6 2 7 10 9 1 9

Creating good implementations Want to try to pick good paths, or it can take a while to solve Fewest number of edges (Floyd Fulkerson) Large bottleneck capacity For bottleneck (wanting “good” but not “best” route): Can keep a “scale” factor: eliminate all edges from the residual graph that have weight less than the scale factor. Ensures only paths that are “large enough” are found. Decrease scale factor (e.g. by factor of 2) if nothing found – eventually scale gets down to 1 (minimum edge capacity), so you are solving the whole thing.

Edmonds Karp: Improving Floyd Fulkerson Idea is to use BFS to find the fewest edges needed to get from source to sink. Avoids problems where you follow the same link in opposite direction each time (and only increase flow by a small amount) will tend to get more flow more quickly Only needs to be run O(VE) times See book for an implementation Another improvement: Dinic’s Algorithm

Min Cut A byproduct of Max Flow After computing max flow, the set of vertices reachable from source is one set, the remainder are the other set The min cut is all edges from one set to the other. It will equal the max flow!

Variations: Multi-source/multi-sink Vertex capacities Create a “super source” and “super sink” that have edges going to all sources or from all sinks. Capacity of these is infinite Then, just run from super-source to super-sink Vertex capacities If limits at the vertices, split vertices in two, A and B A gets all incoming edges B gets all outgoing edges One edge from A to B with capacity equal to vertex capacity

Flow graph modeling Often, recognizing a task as network flow is biggest challenge. Example: Some number of users brings a set of applications (label ‘A’ to ‘Z’) to be run. There are 10 computers that can run applications (1 per day). Applications can only run on certain computers Create nodes for each application, each computer Create single source and single sink Create edge from source to each application node Set weight as the number of that application submitted by users Create edge from application node to computer nodes that can run it Weight can be 1, since only 1 program can run per computer Create edge from computer nodes to the sink Weight is 1, since each can run one program.

Another example (UVA problem 11380) – Titanic sinking Grid of values: water (impassible) – ice with a person on it (will disappear once they leave), ice a person can move to (but will sink once they leave), iceberg (can hold people but not permanently), large wood (can hold people for safety, but only limited number) Create graph connecting adjacent nodes, high edge capacity Set node capacity for ice to 1 Create a source to all nodes with starting people (high edge weight) Create a sink from all wood nodes with weight equal to max. wood capacity.