Max flow - PowerPoint PPT Presentation

1 / 33
About This Presentation
Title:

Max flow

Description:

Dinic's Algorithm. Dinic's algorithm is based on the observation that many ... Dinic's algorithm restricts its search for an augmenting paths to those edges ... – PowerPoint PPT presentation

Number of Views:166
Avg rating:3.0/5.0
Slides: 34
Provided by: cadZj
Category:
Tags: dinic | flow | max

less

Transcript and Presenter's Notes

Title: Max flow


1
Max flow
  • Jorsef

2
Definitions
Capacity
7
Sink
Source
3
A flow
3
5
7
2
4
A Cut
5
Capacity/Flow Across A Cut
6
More Definition Residual Graph
5
7
2
5
2
7
  • A path from source to sink in the residual graph
    of a given flow
  • If there is an augmenting path in the residual
    graph, we can push more flow

8
Ford-Fulkerson Method
  • initialize total flow to 0
  • residual graph G G
  • while augmenting path exist in G
  • pick a augmenting path P in G
  • m bottleneck capacity of P
  • add m to total flow
  • push flow of m along P
  • update G

9
Example
3
2
1
3
1
1
3
1
3
1
1
4
3
2
2
1
1
1
2
4
2
4
10
Example
3
2
1
3
1
1
3
1
3
1
1
4
3
2
2
1
1
1
2
4
2
4
11
Example
3
2
1
3
1
1
3
1
3
1
1
4
3
2
2
1
1
1
2
3
1
3
1
1
1
12
Example
3
2
1
3
1
1
3
1
3
1
1
4
3
2
2
1
1
1
2
3
1
3
1
1
1
13
Example
1
2
1
3
1
1
1
1
1
1
1
4
3
2
2
1
1
1
2
3
1
3
1
1
1
14
Example
1
2
1
3
1
1
1
1
1
1
1
4
3
2
2
1
1
1
2
3
1
3
1
1
1
15
Example
1
2
1
3
1
1
1
1
1
1
1
3
3
2
1
1
1
1
2
2
2
2
2
2
16
Answer Max Flow 4
2
2
2
2
2
1
1
1
2
2
2
17
Answer Minimum Cut 4
3
2
1
3
1
1
3
1
3
1
1
4
3
2
2
1
1
1
2
4
2
4
18
Find Augmenting Path
  • initialize total flow to 0
  • residual graph G G
  • while augmenting path exist in G
  • pick a augmenting path P in G
  • m bottleneck capacity of P
  • add m to total flow
  • push flow of m along P
  • update G

19
Maximum Capacity Augmentation
  • One way to select augmenting paths is to select
    one with maximum residual capacity.
  • Maximum capacity augmenting paths can be found
    using a bottleneck version of Dijkstras algorithm

20
Capacity Scaling Algorithm
  • It allows augmenting paths to be found using
    breadth-first search, while still using large
    capacity paths first.
  • The algorithm starts by letting D c where c is
    the maximum edge capacity. It then repeats the
    following step until D lt 1.
  • find a shortest augmenting path in the subgraph
    RD , of the residual graph R, containing edges
    with residual capacity ? D
  • add as much flow as possible to the path
  • if there is no augmenting path, replace D by D/2

21
Augmenting by Shortest Paths
  • Another way to select augmenting paths is to
    augment along a path with the fewest edges. This
    yields an O(m2n) running time.

22
Dinics Algorithm
  • Dinics algorithm is based on the observation
    that many consecutive steps in the shortest path
    version of the augmenting path algorithm involve
    augmenting paths of the same length.
  • We can avoid some redundant effort by ignoring
    edges that cannot possibly appear in augmenting
    paths of the current length.

23
Dinics Algorithm
  • Let G be a graph, f be a flow function on G and
    R the corresponding residual graph.
  • let level(u) be defined as the number of edges in
    a shortest path from s to u in R
  • only edges (u,v) for which level(v) level(u) 1
    can possibly be on a shortest augmenting path
  • Dinics algorithm restricts its search for an
    augmenting paths to those edges for which (u,v)
    for which level(v) level(u) 1.

24
Dinics Algorithm
  • Dinic's algorithm begins by setting f(u,v) to
    zero for all edges in G, computes level(u) for
    all vertices u and then repeats the following
    step as long as level(t)ltn.
  • while there is an augmenting path using edges
    (u,v) with level(v) level(u)1, select such a
    path and saturate it
  • recalculate level(u) for all u

25
Other algorithms
  • Dinics Algorithm with Dynamic Trees
  • Preflow-Push Method
  • The FIFO Algorithm
  • Highest Label Preflow Push algorithm
  • Excess Scaling Algorithm

26
Application Bipartite Matching
  • Marriage Problem

27
A Matching
28
Maximum Matching
29
Maximum Flow Problem
30
Maximum Flow/Matching
31
If we have many sources and sinks?
32
RookAttack problem
33
thank you
Write a Comment
User Comments (0)
About PowerShow.com