network flow - utkweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 ·...
TRANSCRIPT
![Page 1: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/1.jpg)
Network Flow
By:Daniel Pham,
Anthony Huber, Shaazan Wirani
![Page 2: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/2.jpg)
Questions
1. What is a network flow?
2. What is the Big O notation of the Ford-Fulkerson method?
3. How to test if the Hungarian algorithm is optimal?
![Page 3: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/3.jpg)
Anthony Huber
Computer Science senior
Hololens research under Dr. Huang
Hometown: Elizabethton, TN
Interests:
Guitar
Video games with friends and family
Swimming
![Page 4: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/4.jpg)
Daniel Pham
Computer Science senior
Interests:
Gaming
Working out
Hometown: Nashville, TN
![Page 5: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/5.jpg)
Shaazan Wirani
Major: Computer Science
Minor: Mathematics
Originally from India
Interests:
Sports: Football and Basketball
Spending time with my family
Chattanooga, TN
![Page 6: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/6.jpg)
Outline
History of Flow Network
Overview of Flow Network
Definitions of the Algorithms with Applications
Implementations
Open Issues
References
Discussion
![Page 7: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/7.jpg)
History
Ford-Fulkerson Method: First published in
1956 by:
Lester Randolph Ford Jr.
Delbert Ray Fulkerson
Assignment Problem:
1955: Harold Kuhn → Matrix implementation
1987: Harold Gabow and Robert Tarjan
Maximum flow:
1986: Andrew Goldberg and Robert Tarjan
Minimum Cost Circulation:
1972: Jack Edmonds and Richard Karp
1987: Andrew Goldberg, Robert Tarjan and
Orlin
1988: Ravindra Ahuja, Andrew Goldberg, Orlin,
and Robert Tarjan
Generalized Flow:
1989: Vaidya
![Page 8: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/8.jpg)
Network Flow
What is Network Flow:
A network flow is a directed graph where each edge has a capacity and each
edge receives a flow.
The amount of flow on an edge cannot exceed the capacity of the edge.
![Page 9: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/9.jpg)
● A → B → D → E : Sending 2 Mb/s
● We get two new Graphs
![Page 10: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/10.jpg)
Residual Graph and Augmenting Graph
![Page 11: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/11.jpg)
Ford-Fulkerson for Maximum Flow
Greedy algorithm that starts from an empty flow and as long is it can find an
augmenting path, updates the current solution
Each augmenting path can be found in → O(E) time
To find the maximum flow, increasing the flow by an integer 1 for each flow,
but is bounded by the total number of flows which is f → O(f E)
![Page 12: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/12.jpg)
Edmonds-Karp Algorithm
Variation of the Ford-Fulkerson method
The difference between these two methods are that augmenting path is
defined.
O(f E) → Ford-Fulkerson Method
O(V E2) → Edmonds - Karp Method
The augmenting path is the shortest path that has available capacity (the
shortest path in the residual graph)
This path can be found with a BFS
![Page 13: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/13.jpg)
Maximum Bipartite matching
A Bipartite Graph is a graph whose vertices can be divided into two disjoint
sets U and V such that each edge connects a vertex U in one of V
Example :
![Page 14: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/14.jpg)
The Assignment Problem
A general problem layout:
The problem instance has a number of agents and a number of tasks. Any agent can be
assigned to perform any task, incurring some cost that may vary depending on the agent-
task assignment. It is required to perform all tasks by assigning exactly one agent to each
task and exactly one task to each agent in such a way that the total cost of the assignment
is minimized.
![Page 15: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/15.jpg)
The algorithm applies to a given NxN cost matrix to find the optimal assignment.
1. Subtract the smallest entry in each row from all the entries in the row
2. Subtract the smallest entry in each column from all the entries in the column
3. Draw lines through the appropriate rows using the least number of
horizontal and vertical lines to covering the 0’s of the matrix
4. Test for optimality : if the minimum number of lines is N -->found
5. Determine the smallest entry not covered by any line and subtract it from
The Hungarian Algorithm
![Page 16: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/16.jpg)
Example: Matrix Implementation
Example 2: A construction company has four large bulldozers located at four
different garages. The bulldozers are to be moved to four different construction
sites.
How should the bulldozers be moved to the construction sites in order to
minimize the total distance traveled?
![Page 17: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/17.jpg)
Step 1: Subtract the smallest entry in each row from all the entries in the row
![Page 18: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/18.jpg)
Step 2: Subtract the smallest entry in each column from all the entries in the column
![Page 19: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/19.jpg)
Step 3: Draw lines through the appropriate rows using the least number of horizontal and vertical lines to covering the 0’s of the matrix
![Page 20: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/20.jpg)
Step 4: Test for optimality
If the number of vertical and horizontal lines equals N → then the optimized
matrix is found.
Since the minimal number of lines is less than 4, we have to
proceed to Step 5.
![Page 21: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/21.jpg)
Step 5: Determine the smallest entry not covered by any line and subtract it from each uncovered row and add it to each covered column. Then return to step 3
![Page 22: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/22.jpg)
After 2 more iterations
1: Diagonal: 80 + 55 + 95 + 45 = 275
D1 + C2 + B3 + A4
2: Another way: 75 + 65 + 90 + 45 = 275
B1 + D2 + C3 + A4
3: NonZero: 90 + 85 + 90 + 115 = 380
A1 + B2 + C3 + D4
![Page 23: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/23.jpg)
Algorithms/Methods
Ford-Fulkerson
Edmonds-Karp
Maximum Bipartite Matching
Assignment / Hungarian Algorithm
Generalized Network Flow
![Page 24: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/24.jpg)
Ford-FulkersonMore of a method than an algorithm
Find the maximum flow through a graph.
The following is the simple idea of the Ford-Fulkerson algorithm:
1) Start with initial flow as 0.
2) While there is an augmenting path from source to sink.
Add this path-flow to flow.
3) Return flow.
Edmonds-Karp algorithm defines a way to find the augmenting path.
Use BFS finding shortest path with available capacity.
![Page 25: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/25.jpg)
Edmonds-Karp
source
sink
![Page 26: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/26.jpg)
Maximum Bipartite Matching
With a bipartite graph on input, find the maximum matching.
![Page 27: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/27.jpg)
Add a source and sink. Connect the source with all applicants, and connect all jobs with the sink.
Every edge is marked with a capacity of 1.
Using Edmonds-Karp algorithm, find the maximum flow.
![Page 28: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/28.jpg)
Assignment
The problem instance has a number of agents and a number of tasks. Any agent
can be assigned to perform any task, incurring some cost that may vary
depending on the agent-task assignment. It is required to perform all tasks by
assigning exactly one agent to each task and exactly one task to each agent in
such a way that the total cost of the assignment is minimized.
![Page 29: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/29.jpg)
Hungarian Algorithm
Step 0)
A. For each vertex from left part (workers), find the minimal outgoing edge and subtract its weight from all weights
connected with this vertex. This will introduce 0-weight edges (at least one).
B. Apply the same procedure for the vertices in the right part (jobs). Actually, this step is not necessary, but it decreases
the number of main cycle iterations.
![Page 30: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/30.jpg)
Step 1)
A. Find the maximum matching using only 0-weight edges (for this purpose you can use max-flow algorithm, augmenting
path algorithm, etc.).
B. If it is perfect, then the problem is solved. Otherwise find the minimum vertex cover V (for the subgraph with 0-weight
edges only), the best way to do this is to use Köning’s graph theorem (According to this resource).
![Page 31: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/31.jpg)
Step 2) Adjust the weights using the following rule where V is the set of vertices in the vertex cover:
Step 3) Repeat Step 1 until solved.
Time complexity: O(n^4)
![Page 32: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/32.jpg)
Generalized Network Flow
Generalized network flow models are
achieved when the edges have an
associated gain or loss. Most real world
networks will have this behavior. For
example: voltage transportation, water
canal evaporation, currency exchange,
shipping losses, etc.
![Page 33: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/33.jpg)
Implementations
A Ford-Fulkerson algorithm(Red)
Edmonds Karp algorithm(Black)
MIT’s algorithm (Purple)
- At 750 nodes, over 8 times better
- than the other two
![Page 34: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/34.jpg)
![Page 35: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/35.jpg)
Implementations: Ford-Fulkerson/Edmonds Karp
Greedy algorithm checks all paths to find an augmenting path, updates the
total flow
Checks a path, then tries to find a path that maximizes the flow
Takes more time as the size of the graph increases
Recent years, the size of graphs being studied increased
![Page 36: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/36.jpg)
Implementations: MIT’s Algorithm
Finding an efficient way to move through a network (i.e. transportation of
materials, internet traffic) becomes increasingly problematic as the size of
the network increases
Reduces the number of operations
Take less unnecessary actions
![Page 37: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/37.jpg)
Implementations: MIT’s Algorithm
Finds areas of the graph that create a “bottleneck” effect
MIT professors and graduate students viewed the graph like an electric resistor
Divides the graph into clusters of well connected nodes
The paths between these clusters, are the paths that create a “bottleneck”
Focus on higher level problems/structures, less on unimportant decisions
MIT’s algorithm is based off of max flow, with almost linear time operation
According to an MIT representative, the amount of time it would take to solve a problem is
almost directly proportional to number of nodes in the network
Scales well/increases efficiency
![Page 38: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/38.jpg)
Open Issues
Multi-commodity flow problem
Multiple sinks/sources
Real world applications of the algorithms
Correctness of different algorithms(i.e. returning incorrect max flow, preferences)
Optimization
The time to compute
![Page 39: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/39.jpg)
Open Issues: multi-commodity flow
Multiple sources/sinks
How do we know which source to choose first?
Algorithms are already time consuming on large graphs with one source/sink
Even more costly on time and computation to check all paths in a large graph with multiple
sources/sinks
How can this be addressed?
![Page 40: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/40.jpg)
Open Issues: multi-commodity flow
Supersource - vertex connecting all sources
Supersink - vertex connecting all sinks
Not a realistic approach
Infinite amount of flow from one point
![Page 41: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/41.jpg)
Open Issues: Real World Applications
Algorithms don’t take the constraints of the real world
How do we factor cost/efficiency while maximizing flow?
Physical design of the path
Long path with higher capacity vs short path lower capacity
Long path length 10 with 2 capacity or short path length 1 and 1 capacity
![Page 42: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/42.jpg)
References
http://www.geeksforgeeks.org/ford-fulkerson-algorithm-for-maximum-flow-problem/
http://www.geeksforgeeks.org/maximum-bipartite-matching/
http://www.cs.cornell.edu/~eva/network.flow.algorithms.pdf
https://en.wikipedia.org/wiki/Assignment_problem
https://en.wikipedia.org/wiki/Hungarian_algorithm
http://news.mit.edu/2013/new-algorithm-can-dramatically-streamline-solutions-to-the-max-flow-problem-0107
https://lucatrevisan.wordpress.com/2011/02/04/cs261-lecture-9-maximum-flow/
https://en.wikipedia.org/wiki/Ford–Fulkerson_algorithm
![Page 43: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/43.jpg)
Discussions
Any Questions?
![Page 44: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/44.jpg)
Questions
1. What is a network flow?
2. What is the Big O notation of the Ford-Fulkerson method?
3. How to test if the Hungarian algorithm is optimal?
![Page 45: Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the](https://reader033.vdocuments.mx/reader033/viewer/2022053018/5f1ea681a27ac8270e100e91/html5/thumbnails/45.jpg)
Thank You