45
Network Flow By: Daniel Pham, Anthony Huber, Shaazan Wirani

Network Flow - UTKweb.eecs.utk.edu › ... › presentations › network-flow.pdf · 2017-03-30 · Generalized Network Flow Generalized network flow models are achieved when the

  • Upload
    others

  • View
    8

  • Download
    0

Embed Size (px)

Citation preview

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

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

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

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

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

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

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

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

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

● 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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Thank You