1 / 27

Announcements

Learn about the maximum flow problem in network flow graphs and how it can be solved using the Ford-Fulkerson algorithm. Review types of networks, such as internet, telephone, and electrical power, and understand how to maximize flow from sources to destinations.

parchibald
Download Presentation

Announcements

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

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

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

  4. 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 www.topcoder.com

  5. Network Flow • A Network is a directed graph G • Edges represent pipes that carry flow • Each edge <u,v> has a maximum capacity c<u,v> • A source node sin which flow arrives • A sink node t out which flow leaves Goal: Max Flow

  6. Network Flow 12 • 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 b 20 16 9 4 10 7 s t 4 c d 14 Each edge stands for the capacity of that edge.

  7. Network Flow 12 • 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 b 20 16 9 4 10 7 s t 4 c d 14 Each edge stands for the capacity of that edge.

  8. Network Flow 12 • 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 b 12/12 a b 20 16 19/20 12/16 0/9 9 4 10 7 s t 0/4 0/10 s t 7/7 13 4 11/13 4/4 c d c d 14 11/14 This graph contains the capacities of each edge in the graph. Here is an example of a flow in the graph.

  9. 12 12/12 a b a b 20 19/20 16 12/16 0/9 9 4 0/4 10 7 0/10 s t s t • 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. 7/7 13 4 11/13 4/4 c d c d 14 11/14 capacities flow

  10. 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. 0/12 a b 0/20 0/16 Using the notation: used / capacity. Residual Capacity: capacity - used. 0/9 0/4 0/10 s t 0/7 0/4 0/13 c d 0/14

  11. 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. 0/12 a b 0/20 0/16 Using the notation: used / unused. Residual Capacity: unused - used. 0/9 0/4 0/10 s t 0/7 0/4 0/13 c d 0/14

  12. 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. • Residual capacity of a path – the minimum of the residual capacities of the edges on that path. 0/12 a b 0/20 0/16 0/9 • 4 in this case, which is the limiting factor for this path’s flow. 0/4 0/10 s t 0/7 4/4 0/4 4/13 0/13 c d 4/14 0/14

  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 • Residual capacity of a path – the minimum of the residual capacities of the edges on that path. 12/12 0/12 a b 12/20 0/20 12/16 0/16 0/9 • 12 in this case, which is the limiting factor for this path’s flow. 0/4 0/10 s t 0/7 4/4 4/13 c d 4/14

  14. 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 • Residual capacity of a path – the minimum of the residual capacities of the edges on that path. 12/12 a b 12/20 12/16 19/20 0/9 • 7 in this case, which is the limiting factor for this path’s flow. 0/4 0/10 s t 0/7 7/7 4/4 4/13 11/13 c d 4/14 11/14

  15. 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 = 19 + 4 = 23 12/12 a b 19/20 12/16 0/9 0/4 0/10 s t 7/7 11/13 4/4 c d 11/14

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

  17. Cuts of Flow Networks

  18. The Net Flow through a Cut (S,T) • f(S,T) = 12 – 4 + 11 = 19

  19. The Capacity of a Cut (S,T) • c(S,T)= 12+ 0 + 14 = 26

  20. Network Flow • Value of the cut, example on the board…

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

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

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

  24. 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: • f is a maximum flow in G. • The residual network Gf contains no augmented paths. • |f| = f(S,T) for some cut (S,T) (a min-cut).

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

  26. 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 list of how many of each position the orchestra needs. • 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.

  27. References • Slides adapted from Arup Guha’s Computer Science II Lecture notes: http://www.cs.ucf.edu/~dmarino/ucf/cop3503/lectures/ • 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

More Related