maximum flow
DESCRIPTION
Maximum Flow. Haidong Xue (Haydon ) 10/28/2013. What is a flow network?. A no- selfloop , weak connected directed graph (V, E) Among vertices in V T here is one and only one source vertex There is one and only one sink vertex For each vertex v, there is a path - PowerPoint PPT PresentationTRANSCRIPT
Maximum Flow
Haidong Xue (Haydon)10/28/2013
What is a flow network?
• A no-selfloop, weak connected directed graph (V, E)
• Among vertices in V– There is one and only one source vertex – There is one and only one sink vertex – For each vertex v, there is a path
• No antiparallel edges in E– if
• A Capacity is defined on each edge:
V
E
What is a flow network?
• A flow on a flow network
– i.e. does not exceed (capasity constraint)
– (flow conservation)
Note: In some definition of flow networks, negative flows are allowed;in these slides, we keep consistent with the textbook
What is a flow network?• Are they flow networks with valid flows?
11/16
10/13
1/4
12/12
11/14
4/9 7/7
15/20
4/4
Red: flowGreen: capacity
11/16
8/13
1/4
12/12
4/9
15/2011/16
13/13
6/4
17/12
11/14
4/9 7/7
20/20
4/4
11/16
8/13
1/4
12/12
11/14
4/9 7/7
15/20
4/4
Not connected
Multiple Sinks
Violate the capacity constraint
Violate the flow conservation rule
What is a flow network?• Are they flow networks with valid flows?
Red: flowGreen: capacity
have a self-loop have an antiparallel edge
11/16
8/13
1/4
12/12
11/14
4/9 7/7
15/20
4/4
0/7
11/16
8/13
0/10 1/4
12/12
11/14
4/9 7/7
15/20
4/4
s t
11/16
8/13
1/4
12/12
11/14
4/9 7/7
15/20
4/4
1 source; 1 sink;no self-loop; no antiparallel edge;no flow exceed capacity;for all non-source non-sink vertices, total flow is 0.
Page 710 Fig 26.1(b)
What if the real problem has antiparallel edges or multiple sinks or sources?
v1
v2
10 4
v1
v2
10
4V’
10Add an intermediate vertex to eliminate antiparallel edges
s1
s2
s3
s4
s5
t3
t2
t1
ts
Add a super-source and a super sink
10
12
8
147
11
2
5
3
156
20
13
18
Why do we disallow antiparallel edges?
What is the max-flow problem?
s t
11/16
8/13
1/4
12/12
11/14
4/9 7/7
15/20
4/4
The flow of a flow network, : the net output of the sourcei.e., -
In the above example, = 11+8=19
What is the max-flow problem?
s t
9/16
8/13
1/4
10/12
9/14
2/9 7/7
15/20
2/4
Given a flow network, there could be more than one valid flows:
= 17
s t
11/16
8/13
1/4
12/12
11/14
4/9 7/7
15/20
4/4
= 19
s t
12/16
11/13
4
12/12
11/14
9 7/7
19/20
4/4
= 23 (it is a max-flow)
The maximum-flow problem:Given a flow network, find a valid flow that has the maximum
Find a maximum flow
• Input: a flow network
• Output: a flow net work with max-flow
s t
16
13
4
12
14
9 7
20
4
s t
12/16
11/13
4
12/12
11/14
9 7/7
19/20
4/4
Find a maximum flow- residual networks• What are the possible modifications can be made on
an edge that does not break the capacity constraint?
s t
4/16
4/13
4/4
8/12
4/14
4/9 7
4/20
4/4
Increase it at most by 10 = c-f=14-4;Decrease it at most by 4=f.
To represent a possible modifications, residual networks are introduced
Find a maximum flow - residual networks
s t
𝑣3
𝑣4𝑣2
𝑣111/16
8/13
1/4
12/12
11/14
4/9 7/7
15/20
4/4
A flow network with a valid flow
A residual network of where
s t
𝑣3
𝑣4𝑣2
𝑣15
11
5
83 1
12
5 4
3
11
75
15
4
Find a maximum flow – augmenting paths
s t
𝑣3
𝑣4𝑣2
𝑣111/16
8/13
1/4
12/12
11/14
4/9 7/7
15/20
4/4
s t
𝑣3
𝑣4𝑣2
𝑣15
11
5
83 1
12
5 4
3
11
75
15
4
𝐺 𝐺 𝑓 𝑜𝑓 𝐺An augmenting path is a simple path from s to t in the residual network
s t
𝑣3
𝑣4𝑣2
𝑣15
11
5
83 1
12
5 4
3
11
75
15
4
Find a maximum flow – augmenting paths
An augmenting path is a simple path from s to t in the residual network
s t
𝑣3
𝑣4𝑣2
𝑣15
11
5
83 1
12
5 4
3
11
75
15
4
The residual capacity of an augmenting path:
𝑐 𝑓 (𝑝 )=4
The flow defined by
4/
4/4/
Guaranteed by Corollary 26.3 , modifying according to this flow on does not break the flow conservation rule
Find a maximum flow – augmenting paths
s t
𝑣3
𝑣4𝑣2
𝑣111/16
8/13
1/4
12/12
11/14
4/9 7/7
15/20
4/4
𝐺 h𝑤𝑖𝑡 𝑓 𝐺 𝑓 𝑜𝑓 𝐺 h𝑤𝑖𝑡 h𝑝𝑎𝑡 𝑝𝑎𝑛𝑑 𝑓𝑙𝑜𝑤 𝑓 𝑝
s t
𝑣3
𝑣4𝑣2
𝑣15
11
5
83 1
12
5 4
3
11
75
15
44/
4/4/
Modifyaccording to
s t
𝑣3
𝑣4𝑣2
𝑣111/16
12/13
1/4
12/12
11/14
0/97/7
19/20
4/4
𝐺 h𝑤𝑖𝑡 ↑ { } rsub { } 𝑓 𝑓 𝑝
Find a maximum flow
• Corollary 26.3 guarantees that:– is a valid flow in
• Theorem 26.6 (Max-flow min-cut theorem) further tells that:– If there is no augmenting path in , in is a
maximum flow
Do you have any idea to develop an algorithm to find a max-flow?
Find a maximum flow – the basic Ford-Fulkerson algorithm
FORD-FULKERSON() for each ; while there exist pathfrom toin for each in p if + else
Initialize to 0
Repeatedly find a , and apply the
modification until there is no
augmenting path
Is it correct? What is the time complexity?
Find a maximum flow – Analysis of F-F
• Is it correct in general?– No!
– A counter example:http://en.wikipedia.org/wiki/Ford%E2%80%93Fulkerson_algorithm#Non-terminating_example
• Is it correct with integer capacities?– Yes. – To find a, if using DFS or BFS that is O(|V|+|E|)=O(|E|)– At most, need to it times– Time complexity:
Find a maximum flow – Edmonds-Karp algorithm
EDMONDS-KARP() for each ; while there exist a BFS pathfrom toin for each in p if + else
Find a maximum flow – Analysis of E-K
• Theorem 26.8– The total number of flow augmentations performed by the
algorithm is O(|V||E|)• Time complexity
Find a maximum flow – Example
s t
16
13
4
12
14
9 7
20
4
𝐺
s t
16
13
4
12
14
9 7
20
4
𝐺 𝑓
s t
16
13
4
12
14
9 7
20
4
12/
12/12/
s t
4
13
4
12
14
9 7
8
4
12 12
s t
16
13
4
12
14
9 7
20
4
12/
12/12/
4/4/
4/
s t
4
9
4
12
10
9 7
8
4
12 12
44
Find a maximum flow – Example𝐺 𝐺 𝑓
s t
16
13
4
12
14
9 7
20
4
12/
12/12/
4/4/
4/
s t
4
9
4
12
10
9 7
8
4
12 12
44
s t
16
13
4
12
14
9 7
20
4
12/
12/
4/11/11/
7/
19/
s t
4
2
4
12
3
9 7
1
4
12 19
1111
cannot be reached by A max-flow
Maximum bipartite matching
• A problem can be converted to the max-flow problem
• Bipartite Graph– A undirected graph (V, E)– , – All edges in E go betweenand– Every vertex in V has at least one incident edge
Maximum bipartite matchingRLRLRL
Maximum bipartite matching
RL
A matching ,
RL RL
|𝑀|=1 |𝑀|=2 |𝑀|=3
The maximum bipartite matching problem: find a M with the maximum
Maximum bipartite matchingConvert it to a max-flow problem
RL RL
s t
Set each edge with a capacity of 1
By Lemma 26.9,
Summary
• Max-flow problem– Flow network – The flow of – The residual network – A augmenting path of – , – Ford-Fulkerson, Edmonds-Karps
• Maximum bipartite Matching– Bipartite graph– Matching– Convert a bipartite graph to a flow net work
FYI
• Your next assignment has already been posted• Chaoyang’s will be holding extended office
hours on Wednesdays from 12:00pm-4:00pm
• ACM has an event tomorrowRoom 460, University CenterDistributed Content Delivery Systems with Real Time Route OptimizationFree knowledge, pizza, soda, donut, and a door price
Pop QuizWrite down your official name clearly on the right-top corner in the form: Last Name, First Name. (e.g. Xue, Haidong)