Announcements Network Flow today, depending on how far we get, we will do String Matching on Wednesday Then Review for Final next Monday This week’s lab.

Slides:



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

Lecture 5: Network Flow Algorithms Max-Flow Min-Cut Single-Source Shortest-Path (SSSP) Job Sequencing.
1 Maximum flow sender receiver Capacity constraint Lecture 6: Jan 25.
Introduction To Algorithms CS 445 Discussion Session 8 Instructor: Dr Alon Efrat TA : Pooja Vaswani 04/04/2005.
MAXIMUM FLOW Max-Flow Min-Cut Theorem (Ford Fukerson’s Algorithm)
The Maximum Network Flow Problem. CSE Network Flows.
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 
Advanced Algorithm Design and Analysis (Lecture 8) SW5 fall 2004 Simonas Šaltenis E1-215b
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2001 Lecture 4 Tuesday, 2/19/02 Graph Algorithms: Part 2 Network.
1 Maximum flow problems. 2 - Introduction of: network, max-flow problem capacity, flow - Ford-Fulkerson method pseudo code, residual networks, augmenting.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Lecture 4 Tuesday, 10/2/01 Graph Algorithms: Part 2 Network.
Maximum Flows Lecture 4: Jan 19. Network transmission Given a directed graph G A source node s A sink node t Goal: To send as much information from s.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2004 Lecture 5 Wednesday, 10/6/04 Graph Algorithms: Part 2.
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
MAX FLOW CS302, Spring 2013 David Kauchak. Admin.
Maximum Flow Chapter 26.
Introduction to Operations Research
Section 2.9 Maximum Flow Problems Minimum Cost Network Flows Shortest Path Problems.
CS774. Markov Random Field : Theory and Application Lecture 13 Kyomin Jung KAIST Oct
Lecture 5: Network Flow Algorithms Single-Source Shortest-Path (SSSP) (Dijkstra's Algorithm) Max Flow - Min Cut (Ford-Fulkerson) Job Sequencing.
Yangjun Chen 1 Network Flow What is a network? Flow network and flows Ford-Fulkerson method - Residual networks - Augmenting paths - Cuts of flow networks.
Single Source Shortest-Path: The General Case (with negative edges) Bellman-Ford algorithm. Iteratively relax all edges |V|-1 times Running time? O(VE).
Max Flow – Min Cut Problem. Directed Graph Applications Shortest Path Problem (Shortest path from one point to another) Max Flow problems (Maximum material.
Maximum Flow Problem (Thanks to Jim Orlin & MIT OCW)
Maximum Flow Chapter 26. Flow Concepts Source vertex s – where material is produced Sink vertex t – where material is consumed For all other vertices.
CS223 Advanced Data Structures and Algorithms 1 Maximum Flow Neil Tang 3/30/2010.
15.082J and 6.855J March 4, 2003 Introduction to Maximum Flows.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 25.
1 CS612 Algorithms for Electronic Design Automation CS 612 – Lecture 8 Lecture 8 Network Flow Based Modeling Mustafa Ozdal Computer Engineering Department,
Announcements Finish up Network Flow today Then Review for Final on Monday ◦ HW#5 is due on Monday, let me or the TA’s know if you have trouble starting.
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.
CSEP 521 Applied Algorithms Richard Anderson Lecture 8 Network Flow.
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.
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,
Maximum Flow Problem Definitions and notations The Ford-Fulkerson method.
CS 312: Algorithm Design & Analysis Lecture #29: Network Flow and Cuts This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported.
Instructor Neelima Gupta Edited by Divya Gaur(39, MCS '09) Thanks to: Bhavya(9), Deepika(10), Deepika Bisht(11) (MCS '09)
The Maximum Network Flow Problem
TU/e Algorithms (2IL15) – Lecture 8 1 MAXIMUM FLOW (part II)
Maximum Flow Chapter 26.
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.
Richard Anderson Lecture 23 Network Flow
Lecture 22 Network Flow, Part 2
CSCI 3160 Design and Analysis of Algorithms Tutorial 8
Max-flow, Min-cut Network flow.
Edmonds-Karp Algorithm
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
Lecture 10 Network flow Max-flow and Min-cut Ford-Fulkerson method
Flow Networks Topics Flow Networks Residual networks
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
Algorithms (2IL15) – Lecture 7
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
Lecture 21 Network Flow, Part 1
Richard Anderson Lecture 22 Network Flow
Lecture 21 Network Flow, Part 1
Maximum Flow Neil Tang 4/8/2008
Lecture 22 Network Flow, Part 2
Richard Anderson Lecture 22 Network Flow
Maximum Flow Problems in 2005.
Presentation transcript:

Announcements Network Flow today, depending on how far we get, we will do String Matching on Wednesday Then Review for Final next Monday This week’s lab will be review of Network Flow and other material.

Network Flow The Maximum Flow Problem and The Ford-Fulkerson Algorithm

Types of Networks Internet Telephone Cell Highways Rail Electrical Power Water Sewer Gas …

Maximum Flow Problem How can we maximize the flow in a network from a source or set of sources to a destination of set of destinations? The problem reportedly rose to prominence in relation to the rail networks of the Soviet Union, during the 1950's. The US wanted to know how quickly the Soviet Union could get supplies through its rail network to its satellite states in Eastern Europe. In addition, the US wanted to know which rails it could destroy most easily to cut off the satellite states from the rest of the Soviet Union. ◦ It turned out that these two problems were closely related, and that solving the max flow problem also solves the min cut problem of figuring out the cheapest way to cut off the Soviet Union from its satellites. The first efficient algorithm for finding the maximum flow was conceived by two Computer Scientists, named Ford and Fulkerson. The algorithm was subsequently named the Ford-Fulkerson algorithm, and is one of the more famous algorithms in computer science. Source: lbackstrom, The Importance of Algorithms, at

A Network is a directed graph G Edges represent pipes that carry flow Each edge has a maximum capacity c A source node s in which flow arrives A sink node t out which flow leaves Goal: Max Flow Network Flow

The network flow problem is as follows: ◦ Given a connected directed graph G  with non-negative integer weights,  (where each edge stands for the capacity of that edge), ◦ 2 different vertices, s and t, called the source and the sink,  such that the source only has out- edges and the sink only has in- edges, ◦ Find the maximum amount of some commodity that can flow through the network from source to sink. a s c b d t Each edge stands for the capacity of that edge

Network Flow One way to imagine the situation is imagining each edge as a pipe that allows a certain flow of a liquid per second. ◦ The source is where the liquid is pouring from, and the sink is where it ends up. ◦ Each edge weight specifies the maximal amount of liquid that can flow through that pipe per second. ◦ Given that information, what is the most liquid that can flow from source to sink per second, in the steady state? a s c b d t Each edge stands for the capacity of that edge

Network Flow The flow of the network is defined as the flow from the source, or into the sink. For the situation above, the network flow is 23. a s c b d t This graph contains the capacities of each edge in the graph Here is an example of a flow in the graph. 13 a s c b d t 12/12 12/16 0/9 0/4 0/10 11/14 4/4 7/7 19/20 11/13

The Conservation Rule: ◦ In order for the assignment of flows to be valid, we must have the sum of flow coming into a vertex equal to the flow coming out of a vertex, for each vertex in the graph except the source and the sink. The Capacity Rule: ◦ Also, each flow must be less than or equal to the capacity of the edge. The flow of the network is defined as the flow from the source, or into the sink. ◦ For the situation above, the network flow is 23. a s c b d t capacities flow 13 a s c b d t 12/12 12/16 0/9 0/4 0/10 11/14 4/4 7/7 19/20 11/13

Network Flow In order to determine the maximum flow of a network, we will use the following terms: ◦ Residual capacity – is simply an edge’s unused capacity.  Initially none of the capacities will have been used, so all of the residual capacities will be just the original capacity. a s c b d t 0/12 0/16 0/9 0/4 0/10 0/14 0/7 0/20 0/4 0/13 Using the notation: used / capacity. Residual Capacity: capacity - used.

Network Flow ◦ Residual capacity of a path – the minimum of the residual capacities of the edges on that path, which will end up being the max excess flow we can push down that path. ◦ Augmenting path – defined as one where you have a path from the source to the sink where every edge has a non-zero residual capacity. a s c b d t 0/12 0/16 0/9 0/4 0/10 0/14 0/7 0/20 0/4 0/13 Using the notation: used / unused. Residual Capacity: unused - used.

Ford-Fulkerson Algorithm While there exists an augmenting path Add the appropriate flow to that augmenting path So we’re going to arbitrarily choose an the augmenting path s,c,d,t in the graph below: ◦ And add the flow to that path. a s c b d t 0/12 0/16 0/9 0/4 0/10 0/14 0/7 0/20 0/4 0/13 ◦ Residual capacity of a path – the minimum of the residual capacities of the edges on that path. ◦ 4 in this case, which is the limiting factor for this path’s flow. 4/14 4/4 4/13

Ford-Fulkerson Algorithm While there exists an augmenting path Add the appropriate flow to that augmenting path Choose another augmenting path ( one where you have a path from the source to the sink where every edge has a non-zero residual capacity.) ◦ s,a,b,t a s c b d t 0/12 0/16 0/9 0/4 0/10 0/7 0/20 ◦ Residual capacity of a path – the minimum of the residual capacities of the edges on that path. ◦ 12 in this case, which is the limiting factor for this path’s flow. 4/14 4/4 4/13 12/12 12/16 12/20

Ford-Fulkerson Algorithm While there exists an augmenting path Add the appropriate flow to that augmenting path Choose another augmenting path ( one where you have a path from the source to the sink where every edge has a non-zero residual capacity.) ◦ s,c, d, b, t a s c b d t 12/12 12/16 0/9 0/4 0/10 0/7 12/20 ◦ Residual capacity of a path – the minimum of the residual capacities of the edges on that path. ◦ 7 in this case, which is the limiting factor for this path’s flow. 4/14 4/4 4/13 7/7 19/20 11/14 11/13

Ford-Fulkerson Algorithm While there exists an augmenting path Add the appropriate flow to that augmenting path Are there any more augmenting paths? ◦ No! We’re done ◦ The maximum flow = = 23 a s c b d t 12/12 12/16 0/9 0/4 0/10 11/14 4/4 7/7 19/20 11/13

Network Flow Another example of the Ford Fulkerson Algorithm on the board…

Cuts of Flow Networks

The Net Flow through a Cut (S,T) f(S,T) = 12 – = 19

The Capacity of a Cut (S,T) c(S,T)= = 26

Network Flow Value of the cut, example on the board…

Augmenting Paths – example The maximum possible flow through the cut = = 23 The network has a capacity of at most 23. This is called a minimum cut. Flow(2) cut

Net Flow of a Network The net flow across any cut is the same and equal to the flow of the network |f|.

Bounding the Network Flow The value of any flow f in a flow network G is bounded from above by the capacity of any cut of G.

Max-Flow Min-Cut Theorem If f is a flow in a flow network G=(V,E), with source s and sink t, then the following conditions are equivalent: 1.f is a maximum flow in G. 2.The residual network G f contains no augmented paths. 3.|f| = f(S,T) for some cut (S,T) (a min-cut).

Example In a department there are n courses and m instructors. Every instructor has a list of courses he or she can teach. Every instructor can teach at most 3 courses during a year. The goal: find an allocation of courses to the instructors subject to these constraints.

Network Flow – Optional Homework Problem An orchestra is trying to fill all of its positions. For different instruments, it needs a different number of players. ◦ For example, it might need 20 violinists but only 3 trumpet players. Each potential candidate for the orchestra can play some set of instruments. ◦ For example, one player might be able to play either a violin or a viola, while another might be able to play a trumpet, trombone or tuba. Given the following information: a)A list of how many of each position the orchestra needs. b)A list of each candidate and which instruments they can play. Determine whether or not the orchestra can fill all its positions. Describe how to solve this problem using network flow.

References Slides adapted from Arup Guha’s Computer Science II Lecture notes: ctures/ ctures/ Additional material from the textbook: Data Structures and Algorithm Analysis in Java (Second Edition) by Mark Allen Weiss J Elder’s Network Flow slides, York University