1 / 22

Network Flow

Network Flow. How to solve maximal flow and minimal cut problems. What is Network Flow?. Network Flow is a subsection of graph theory related specifically to situations where something moves from one location to another.

glustig
Télécharger la présentation

Network Flow

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. Network Flow How to solve maximal flow and minimal cut problems

  2. What is Network Flow? • Network Flow is a subsection of graph theory related specifically to situations where something moves from one location to another. • An easily visualized example of network flow is piping system through which a quantity of water must pass.

  3. Concepts in Network Flow • “Sources” are nodes which supply a commodity • “Sinks” are nodes which use up a commodity • An edge’s capacity is the maximum amount of flow which can pass through it • Graphs are usually directed

  4. An example • What is the maximum flow from A to B? 4 1 4 5 2 3 A 3 B 6 3 2 2 3 1 5

  5. The Ford-Fulkerson method • This is a relatively simple way to find maximum flow through a network: • Find an unsaturated path from the source to the sink • Add an amount of flow to each edge in that path equal to the smallest capacity in it • Repeat this process till no more paths can be found • The total amount of flow added is then maximal

  6. Storing the graph • It is easiest to store, for each edge in the graph, its capacity in both directions, as well as the current flow in each direction. • Thus for a directed graph, the capacity in the reverse direction will start as zero. • When flow is put through the edge, decrease its capacity in the direction and increase the capacity in the opposite direction.

  7. Finding a path • The eventual answer given by this method is not affected by the path chosen, although the algorithm’s speed will be affected • If possible, the shortest path or the path with maximum flow is a good choice, else simply using a DFS works reasonably well

  8. Minimum Cuts • It is sometimes necessary to know the minimum total weight of a cut that splits the graph in two, separating the source and the sink • This will be equal to the maximum flow through the network

  9. To find the minimum cut • First create the maximum flow graph • Select all the nodes that can be reached from the source by unsaturated edges • Cut all the edges that connect these nodes to the rest of the nodes in the graph • This cut will be minimal

  10. An example • Maximal flow in the graph shown earlier 4 1 4 5 2 3 A 3 B 6 3 2 2 3 1 5

  11. An example • Choose a path and put flow through it 4 1 4 5 2 3 A 3 B 6 2 2 2 2 0 5

  12. An example • Current flow = 1 4 1 4 5 2 3 A 3 B 6 2 2 2 2 0 5

  13. An example • Current flow = 3 4 1 4 3 0 3 A 3 B 4 0 2 2 2 0 5

  14. An example • Current flow = 3 4 1 4 3 0 3 A 3 B 4 0 2 2 2 0 5

  15. An example • Current flow = 5 4 1 2 3 0 3 A 1 B 4 0 0 2 0 0 5

  16. An example • Total flow = 5 4 1 2 3 0 3 A 1 B 4 0 0 2 0 0 5

  17. An example • To find a minimal cut 4 1 [2] 2 3 [3] 0 [4] 3 [5] A 1 B [6] [3] 4 0 [2] 0 [3] 2 0 [1] 0 5

  18. An example • Minimal cut = 1 + 2 + 2 = 5 4 1 2 2 2 3 A 2 B 2 3 2 2 3 1 5

  19. Variations on Network Flow • Undirected graphs – give the edge the capacity in both directions, then increase or decrease this capacity as flow changes, as before.

  20. Variations on Network Flow • Multiple sources / sinks – create a “supersource” or “supersink” which connects directly to each of these nodes, and has infinite capacity 3 S 3 5 5

  21. Variations on Network Flow • Node capacity – split the node into an “in” node, an “out” node and an edge 2 1 4 5 3 2 4 1 3 5

  22. Conclusion • Network flow problems can come in a number of forms, usually relating to some commodity being moved from suppliers to where it is needed. • Also look for minimal cut problems, which can be solved easily with graph theory.

More Related