Network Flow - PowerPoint PPT Presentation

About This Presentation
Title:

Network Flow

Description:

Network Flow The Maximum Flow Problem and The Ford-Fulkerson Algorithm Types of Networks Internet Telephone Cell Highways Rail Electrical Power Water Sewer Gas – PowerPoint PPT presentation

Number of Views:110
Avg rating:3.0/5.0
Slides: 21
Provided by: Sarah
Learn more at: http://www.cs.ucf.edu
Category:
Tags: flow | network | soviet | union

less

Transcript and Presenter's Notes

Title: Network Flow


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

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

3
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
4
Network Flow
  • A Network is a directed graph G
  • Edges represent pipes that carry flow
  • Each edge ltu,vgt has a maximum capacity cltu,vgt
  • A source node s in which flow arrives
  • A sink node t out which flow leaves

Goal Max Flow
5
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.

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

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

8
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
7/7
13
4
4/4
11/13
c
d
c
d
14
11/14
capacities
flow
  • 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.

9
Network Flow
  • In order to determine the maximum flow of a
    network, we will use the following terms
  • Residual capacity is simply an edges 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
10
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
11
Ford-Fulkerson Algorithm
  • While there exists an augmenting path
  • Add the appropriate flow to that augmenting path
  • So were going to arbitrarily choose 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 paths flow.

0/4
0/10
s
t
0/7
4/4
0/4
4/13
0/13
c
d
4/14
0/14
12
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 paths flow.

0/4
0/10
s
t
0/7
4/4
4/13
c
d
4/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,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 paths flow.

0/4
0/10
s
t
0/7
7/7
4/4
4/13
11/13
c
d
4/14
11/14
14
Ford-Fulkerson Algorithm
  • While there exists an augmenting path
  • Add the appropriate flow to that augmenting path
  • Are there any more augmenting paths?
  • No! Were 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
4/4
11/13
c
d
11/14
15
Ford-Fulkerson Algorithm - Runtime
  • While there exists an augmenting path
  • Add the appropriate flow to that augmenting path
  • We can check the existence of an augmenting path
    by doing a graph traversal on the network (with
    all full capacity edges removed.)
  • This graph, a subgraph with all edges of full
    capacity removed is called a residual graph.
  • It is difficult to analyze the true running time
    of this algorithm because it is unclear exactly
    how many augmenting paths can be found in an
    arbitrary flow network.
  • In the worst case, each augmenting path adds 1 to
    the flow of a network, and each search for an
    augmenting path takes O(E) time, where E is the
    number of edges in the graph.
  • Thus, at worst-case, the algorithm takes O(fE)
    time, where f is the maximal flow of the
    network.

16
Edmonds-Karp Algorithm
  • This algorithm is a variation on the
    Ford-Fulkerson method which is intended to
    increase the speed of the first algorithm.
  • The idea is to try to choose good augmenting
    paths.
  • In this algorithm, the augmenting path suggested
    is the augmenting path with the minimal number of
    edges.
  • (We can find this using BFS, since this finds all
    paths of a certain length before moving on to
    longer paths.)
  • The total number of iterations of the algorithm
    using this strategy is O(VE). Thus, its total
    running time is O(VE2).

17
Network Flow
  • Consider a network flow problem where the goal
    was to figure out how to change the capacities to
    increase the maximum flow in the network.
  • This might be applicable if you wanted to get a
    greater throughput of data in a network and you
    wanted to figure out where in the network you
    needed to add a router that could handle more
    data per unit of time.

18
Network Flow
  • How to increase the maximum flow of a network.
  • Lets say you restrict your search in your
    network (that is already at max flow) to paths
    that have at most one edge that is being used to
    capacity.
  • For example, s? v1 ? v2 ? ? vn ? t, where each
    edge has extra capacity EXCEPT for the edge vi ?
    vi1.
  • What is a simple fix to add extra capacity to one
    of the edges that will add maximum flow to the
    network?
  • How much will this simple fix add?

19
Network Flow
  • Take a look at the extra capacity available
    through each of the other edges
  • s ? v1, v1 ? v2, , vi-1 ? vi, vi1 ? vi2, , vn
    ? t.
  • Take the minimum of these values.
  • Then, add this much capacity to the edge vi ?
    vi1.
  • Adding more than this would do no good, because
    then some other edge would become the bottleneck.
  • This just adds enough capacity so that the
    original edge is no more of a bottleneck than the
    second worst edge in this particular path.

20
References
  • Slides adapted from Arup Guhas 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 Elders Network Flow slides, York University
Write a Comment
User Comments (0)
About PowerShow.com