Upload
sonal
View
230
Download
0
Embed Size (px)
Citation preview
8/14/2019 Flow Network,Ford Fulkerson Method Notes
http://slidepdf.com/reader/full/flow-networkford-fulkerson-method-notes 1/32
0 1 2 3 4 5 6 7 2 8 4 1 2 4 9 2 4 3 4
9 2 4 3 4 8 1 5 1 7 5 3 1 7 4 3 2 4 3 ! " 3 4 # 3 4 3 4 6 1 5 7 8 2 4
8 2 5 5 8 3 7 2 5 3 8 2 2 4 7 8 3 2 8 7 $ 2 % & ' 3 2 ( ) 8 7 1 4 8 1 7 4 # 8 1 5 )
1 5 2 % * + , 3 2 ( ) 8 7 1 4 4 6 2 4 8 1 5 ! - 7 4 1 1 2 8 4 1 ) 2 4 6 3 7 3 2 ( 8 6 6 5
. 1 5 2 8 1 3 2 ( 5 / !
" 2 4 3 6 6 4 8 2 8 $ 2 3 3 6 1 7 4 6 1 7 2 8 4 1 1 4 5 8 1 2 3 1 5 6 1 7 4
8 5 8 1 2 3 7 4 1 1 7 2 8 1 2 6 1 7 2 8 4 1 ! " 8 8 4 1 4 2 3 2 4 4 4 1
2 3 8 5 8 3 7 2 5 ! 7 8 4 ' ' * 2 8 2 4 2 5 ) 3 3 1 2 8 1 2
# ( 8 # 6 # # 4 6 1 2 4 2 3 2 2 7 1 4 2 3 4 6 2 8 ! 8 1 ) 4 6 3 1 8 1 1 8 2 # 4 6 1 2 4
2 3 8 1 2 4 2 4 6 3 7 3 2 ( ! " 3 4 # 8 2 4 1 5 2 * & : ; 4 2 3 < 2 # ( 8 # 6 #
# 4 6 1 2 4 2 3 2 2 8 4 2 4 2 8 1 ! - 4 8 1 ( # 4 1 2 4 3 4 3 $
= > ? = > @ = > A = > @ = > ? B C
D
E
8 6 3 F $ G 8 # 1 2 4 3 4 3 ! " 3 3 7 6 3 3 1 2 1 4 2 3 4 8 1 !
0 2 8 8 3 2 4 2 2 2 # ( 8 # 6 # 4 8 1 2 4 6 3 8 H ! I 7 1 4 J 6 1 8 2 4 2 3
3 4 # . K L K / ) J 6 1 8 2 4 2 3 3 4 # . K M K L K / ) 1 5 J 6 1 8 2 4 2 3 3 4 # . K M K / ! " 8
8 4 4 H 1 5 8 1 7 8 1 7 4 # 8 1 5 2 4 2 8 1 3 2 6 3 2 5 ) 2 8 8 8 1 5 5 2 # ( 8 # 6 #
4 ! 9 4 2 2 2 8 1 2 ( # ) 1 4 2 8 3 2 6 3 2 5 8 2 2 3 !
N O P O & , % + Q R P
0 2 2 4 2 4 6 28 4 1 8 1 2 4 ( # ) 6 2 4 5 4 1 5 2 4 6 28 4 1 8 1 1 3 S T 1
8 5 8 2 4 1 5 8 1 2 3 4 # . 2 4 / 4 1 8 8 7 2 8 4 # 7 7 8 2 8 3 # 81 81 1 5
8/14/2019 Flow Network,Ford Fulkerson Method Notes
http://slidepdf.com/reader/full/flow-networkford-fulkerson-method-notes 2/32
0 1 2 3 1 4
0 1 0 3 1 4 0 1 2 5 6
7
8
9 ! " #
$ % & ' ( ) (
" # ) ( ! # * + ( , - % % . ' &
( & # / , ' ( , & & & * ,
& * ' .
& , % ( & *
+ % ' ( & #
& % / ( ( & ! " # ! # ,
& ( " : # ; < * $ ( & " #
( / (
= > ?
@ > @
A > = @ > @ = > ? B C
D
E
9 % F *
G ' ) ( ! " # %
& & & ( H * G ( ( ' ' % . , '
( " , I J K L M N O P ( ( & " ! , . '
8/14/2019 Flow Network,Ford Fulkerson Method Notes
http://slidepdf.com/reader/full/flow-networkford-fulkerson-method-notes 3/32
0 1 2 3 1 4
0 1 0 3 1 4 0 1 2 5 6
7
8
9
!
" # $ % 9 &
! ' ( ) * $ + ,
' % &
- . / / - ) * #
' $ % (
: ; < = : . > ? < @ ; A ; = '
B ; < C D E D F G H I J K J L M N O P Q R K P S I T U V H P M V L V U W U K J P O R W J V H M V R S P H I X H I J V Y J I P Z J G U O V N H I J W P [ \
M W O W ] U Y ^
C D E B _ ; > ` a - = b = ; = @ c d - < e > / ; <
! ' 9 9 ( f #
9 $ ' g 9 " h 9 " # i
' ( # ' ! !
$ j k l m n o ' l ! n $
% ! ! ( j k l o #
% ! p 9 ' ! 9 9 (
f q
( # r '
& ) '
i g 9 " # ' ( b = ; = @ c d - < e > / ; <
i ' j k s l t
o '
8/14/2019 Flow Network,Ford Fulkerson Method Notes
http://slidepdf.com/reader/full/flow-networkford-fulkerson-method-notes 4/32
0 1 2 2 3 4 5 6 7 8 9 3 7 1 6 1 3 7 8 6 5 7 7 8 3 3 9 3
9 9 3 6 9
1 6 7 9 7 6
6 1 7 8 3 3 3 7 8 1 8 7 1 7 3 7 8 3 2 9 7 1 1 ! 6 7 3 9 2 3 2 5 6 3 7 8 3
" # $ % & " ' ( ) * $ + # , - ( . # $ /
8 3 1 5 3 6 1 1 7 8 6 3 9 5 7 3 9 7 5 9 3 6 7 9 7 2 7 8 1 : 1 2 9 7 9
7 8 9 7 6 2 7 8 3 3 ;
< = >
6 3 7 3 5 9 7 1 ? 8 3 2 3 @ 2 8 9 7 6 9 3 9 A B C D E F G H F C I A G J
K 1 7 8 3 6 1 5 3 7 1 7 8 3 6 8 6 6 9 6 7 6 9 6 9 9 7 8 K 1 7 8 3 6 1 5 3 7 1 7 8 3 6 7 8 9 7
8 9 6 3 3 6 6 9 9 7 3 7 8 3 @ 5 3 1 5 7 8 1 2 5 8 1 3 2 3 1 5 3 1 2 7 8 9 7 9 7 8
9 9 7 8 6 7 1 7 8 3 : 1 2 2 3 9 3 5
3 2 9 7 8 3 9 1 7 8 7 1 7 8 3 3 7 2 1 K 1 5 3 L 3 6 7 9 7 2 7 8 7 8 3 : 1 2 6 3 7
3 5 9 7 1 ? 3 3 2 8 3 3 M
N
O L
P Q
?
?
?
?
?
?
?
?
?
0 1 2 2 3 3 3 7 1 @ 9 9 5 3 7 9 7 8 8 3 3 9 3 1 6 1 K 7 8 3 R 2 3 9 3
1 7 3 9 7 1 6 ! 1 5 7 6 S T 3 7 7 9 3 7 8 3 9 7 8 O U P U L 7 1 6 7 9 7 2 7 8 0 1 2 2 3
8 9 3 7 1 @ 5 3 1 5 7 2 8 9 7 8 1 2 5 8 1 3 6 7 5 V 2 3 9 3 1 2 7 8 6 1 5 7 3 8 3 3 K 1
O U P 8 9 6 9 9 7 W R X
Y = Z
[ W S 9 6 5 3 7 ? R ;
Y = Z
[ ? 8 7 1 2 S 6 1 7 1 5
3 W 1 3 8 3 3 K 1 P U L 8 9 6 9 9 7 9 6 5 3 7 ? 6 1 7 1 5
3 1 3 3 9 1 3 7 8 3 5 1 K 7 8 3 6 3 5 3 6 6 1 2 3 2 1 3 9 3 7 1
6 3 5 7 6 1 K 6 7 5 V 1 2 7 8 6 9 7 8
8 3 2 3 5 9 7 3 7 8 3 : 1 2 M
N
O L
?
?
?
?
?
8/14/2019 Flow Network,Ford Fulkerson Method Notes
http://slidepdf.com/reader/full/flow-networkford-fulkerson-method-notes 5/32
0 1 2 3 1 4 2 5 0 2 3 0 2 6 3 7 5 8 9 2 3 1 4 0 2 1 1 2 3 1
1 4 2 7 1 2 1 1 2 2 9 4 4 0 7 1 0 2 0 2 1 1 2
3 0 8 1 0 0 2 0 2 1 1 2 7 3 1 ! 5 3 1 5 0 ! 1 7 3 0 " 7 5 5 3 2 3 3 7 5
# 0 7 5
$
8 0 % 7 4 1 7 3 0 4 1 9 & 8 0 & 1 3 ' 3 8 0 0 ! 1 6 0 $ ' 3 0 0 2 0
2 1 1 2 0 7 % 3 0 0 1 4 2 1 4 0 $ 1 4 0 0 2 ( 0 7 3 0 8 7 5 0 2 1 0 7 5 3
5 1 ' 3 0 9 1 0 " 7 5
$
) ! & 0 & 1 0 3 1 4 0 4 7 7 1 9 & 8 0 & 1 3 7 5 # 9 3 0 4 0 ! 1 0 1 7 0 8 7 4 0
$ ' * 0 3 1 ( 0
1 4 2 7 1 2 1 1 2 2 9 4 4 0 7 1 0 2 0 2 1 1 2
8/14/2019 Flow Network,Ford Fulkerson Method Notes
http://slidepdf.com/reader/full/flow-networkford-fulkerson-method-notes 6/32
0 1 2 3 3 1 4 5 3 6 1 7 6 5 8 9 7 3 8 4 8 2 6 4 3 6 4 5 6 1 2 3 7 6 1 0 1 8 7 6 8 4 5 2 3
4 5 5 8 8 7 7 2 6 4 8 6 2 6 3 4 6 1 8 3 4 9 8 6 4 6 1 8 3 2 6 ! 2 3 6 1 8 " 8 3 6 5 8
9 7 4 #
$ % & ' % ( ) * % & & + , * ' % ( - . , / % * ,
0 2 6 4 4 8 3 6 4 6 1 8 3 4 9 8 6 4 6 1 8 3 2 8 8 3 8 9 1 4 6 1 8 7 6 1 3 4
6 1 8 3 4 9 8 6 4 6 1 8 3 2 6 2 3 8 8 3 4 6 1 8 5 7 3 2 5 1 2 9 1 6 1 4 3 8 7 6 1 3 9 7 " 8 9 6 4
, * % * : ; < = > ? > @ < A B C D E B C F ; G < ? H = I C ? J K L = G ? G @ < B M ? C : G G ; : K < K ? < = M < K @ N ? C @
C @ O B P @ H Q < K @ C @ = G > B < J ? < K M C B O < K @ G B ; C : @ < B < K @ G = > D R
S 4 8 T 7 U 8 ! 6 1 8 7 3 1 8 7 9 3 2 4 7 1 " 8 U 4 5 8 8 3 8 6 7 9 6 3 2 9 8 8 4 2
6 1 8 U 8 7 8 3 4 7 6 1 3 4 6 1 8 3 4 9 8 6 4 6 1 8 3 2 V 4 6 8 6 1 7 6 4 7 8 > B < 7 U U 4 5 8 6 4
4 W W W W ! " 8 9 7 3 8 6 1 8 4 7 8 6 7 8 3 2 6 1 8 W 7 9 2 6 1 8 5 4
2 8 9 6 2 4 X
Y 8 5 2 U U 8 8 6 4 8 7 3 8 1 4 5 9 1 3 6 9 4 U 4 5 6 1 4 1 7 U U 6 1 8 7 9 3 2 7 9 6 Z
8/14/2019 Flow Network,Ford Fulkerson Method Notes
http://slidepdf.com/reader/full/flow-networkford-fulkerson-method-notes 7/32
0 1 2 3 4 5 6 7 6 5 8 2 9 6 7 3 4 0 3 6 5 6 7 6 5 8 2 9
0 4 6 4 4 6 9 0 2 3 4 8 2 3 4 0 4 3 8 5 3 8 2 4 3 4 1 4 6 4 0 1 4 8 1 2 3 4
! 0 " ! # 4 0 1 $ 0 8 2 3
% & ' ( ) ' * + , - . / ( - % & ' ( ) ' * : ; < = > = ? @ < = A B C ? D E A F = G H I J G K G L C B
= M K H N O A F = G J < J G K G P H Q H P J A @ C R H P K A S
T 3 8 2 3 4 0 4 6 7 0 U 4 8 1 8 1 4 7 4 1 4 1 2 9 9 ! 0 6 1 ! # 4 0 1 6 1 9 ! 4 "
8 1 2 4 8 1 6 1 V 3 6 1 1 0 1 T 3 4 7 0 0 9 ! 0 6 1 ! # 4 0 1 4 2 3 4 8 6 0 8 2 3 8 6 U 4 9
2 6 8 3 2 " 0 6 6 9 T 3 4 2 3 4 0 4 5 6 1 6 0 4 7 0 U 4 9 6 7 7 9 2 3 4 W 6 8 2 9 T 3 4 0 4
0 X 8 1 4 6 Y 0 6 8 1
T 3 4 0 1 9 7 0 4 8 2 3 2 3 4 Z 6 [ " ! 0 Z 8 1 " \ 2 T 3 4 0 4 8 2 3 6 2 2 3 4 2 0 ] 6 1 2 8 2 8 4 8 2
6 9 6 4 4 ] 6 6 4 0 2 3 3 6 2 0 4 2 6 3 6 1 4 0 1 ^ 2 8 2 8 1 8 5 4 2 0 # 1 0 2 3 6 2 8 9 0 5 6 1
_ 1 6 ` 0 6 1 6 5 2 8 2 3 2 3 4 6 4 U 6 4 9 0 6 4 0 1 4 T 3 6 2 8 9 0 3 6 U 4 0 1 2 3 4 4 2
` 0 7 0 8 4 0 2 3 6 2 1 4 2 0 #
a 3 6 2 6 0 2 0 4 [ 6 7 4 b W 8 4 _ 1 2 3 4 4 2 ` 0 7 0 8 4 b a 4 4 4 4 6 4 2 0
7 7 1 8 2 0 2 3 4 0 5 4 2 0 2 3 4 8 1 # c 0 4 U 4 2 3 4 5 2 4 0 1 3 6 5 6 7 6 5 8 2 9 0
2 3 4 4 2 4 8 2 3 4 4 6 4 2 2 4 ` 0 0 6 6 4 5 2 X 4 2 d # 4 4 7 7 6 9 8 1 6 0 1 8 2 3 2 3 4
5 2 0 6 3 8 4 6 1 4 4 8 4 5 6 1 6 # 4 6 4 2 2 4 0 1 4
c 4 4 d 6 5 2 8 2 3 5 6 7 6 5 8 2 9 e
8/14/2019 Flow Network,Ford Fulkerson Method Notes
http://slidepdf.com/reader/full/flow-networkford-fulkerson-method-notes 8/32
0 1 2 3 4 5 4 6 7 8 1 9 3 4 5 3 8 8
1 8 3 4 5 4 6 7 8 5 3 8 8
9 4 ! 9 1 2 8 " 9 3 8 5 8 1 7 9 5 4 2 1 7 8 1 2 8 3 8 3 8 2 8 8 # $ 3 4
% 8 & ' 9 % 1 ' ( ) 3 4 9 5 4 * 4 3 8 + 4 ! 9 1 2 3 4 , 4 7 " 9 9 7 7 , 4 8 1 2 4 8 1 7 9 #
- . /
4 6 7 7 9 7 4 1 9 3 8 3 4 8 8 5 8 3 7
8/14/2019 Flow Network,Ford Fulkerson Method Notes
http://slidepdf.com/reader/full/flow-networkford-fulkerson-method-notes 9/32
0 1 2
3
4 5
6
7
7 4
4
4
8 9 1 1 1 9 2 9 9 1 9 9 0 1 2 1
1 9 1 1 9 9 9 9 9 2 1 ! 9
" 1 2 9 # 9 9 1 1 1 9 ! 1 9 $ % & 1 2 $ % ' 9 " 1 (
2 1 # 9 1 9 4 9 9 2 1 9 1 0 1 2 (
8 9 1 9 1 9 4 ( " 9 2 ! 9 3
3
4 5
6
4
4
4
4
4
" $ % & 1 2 $ % ' 9 " 1 9 9 9 9 9 9 9 9 0 1 2 ( )
1 9 9 * 9 1 # 9 9 0 1 2 9 1 * 9 9 ! 1 9 9 9 ( "
1 9 1 2 1 2 2 1 + 9 0 1 2 2 +
" 2 9 9 2 9 9 9 9 1 9 2 1 2 1 2
, 8 1 2 9 9 9 9 1 4 - 6 - 3 - 5 ( . 9 1 2 2 9 !
9 1 9 1 9
/ 1 9 9 ! 1 1 9 9 9 2 1 9 9 2
1
9 1 9 9 9 1 9
4 - 6 4 7 4
8/14/2019 Flow Network,Ford Fulkerson Method Notes
http://slidepdf.com/reader/full/flow-networkford-fulkerson-method-notes 10/32
0 1 2 3 4 1 2 5 4 1 2 6 7 1 8 3 9 2 4 1 8 4 1 2 3 2 8 4 2 4 1 2 5 2 8 4 1 2 3 2 8 5 3 4 4 5
4 1 2 8 6 7 4 1 8 4 2 2 3 4 5 3 3 4 1 2 6 9 1 4 6 2 7 4 5 3 2 2 5 6 2 4 2 4 1 2 3 2
8 5 3 4 6 5 4 1 2 8 6 7 4 1 8 4 2 2 3 4 5 3 4 1 2 6 5 3 9 8
3 4 1 7 8 2 5 6 3 2 5
!
" #
$
"
" % & "
% & "
" ' "
5 6 8 4 2 6 3 9 (
!
" #
$
"
" "
"
%
0 1 1 8 3 5 3 7 6 2 8 2 5 6 4 5 4 8 5 4 5 ! 8 3 3 7 2 2 8 6 2 8 5 3 8 7 4 5 7 8 8 7 4
! 4 1 2 ) 8 * + , 5 ) 3 + - 4 0 1 2 5 6 2 4 2 4 1 8 4 2 8 6 2 5 3 2
0 1 2 6 2 8 6 2 4 5 8 4 5 4 1 3 8 5 4 1 2 8 6 2 8 5 2 4 5 2 3 4 . 4 1 2 6 5 3 9 8
5 3 8 2 , 6 4 2 9 1 4 / 4 5 2 6 2 4 1 8 4 3 8 3 9 4 1 2 8 9 2 3 4 3 9 8 4 1 3 4 1 2
8 3 3 2 6 3 1 7 1 2 / 4 2 6 2 8 8 3 5 4 1 2 6 2 5 6 5 + 4 1 8 4 5 6 3 2
5 4 8 4 2 " ! 8 3 $
0 1 2 5 4 1 2 6 8 4 5 4 1 3 8 5 4 4 4 1 8 4 3 4 2 8 5 2 3 3 9 4 . 4 1 2 6 5 3 9 8 2
2 6 2 6 2 8 / 4 6 5 3 9 5 . 4 . 5 3 5 3 2 2 5 4 1 2 8 6 7 8 3 4 1 2 3 4 2 3 9 4 1 2 6 2 5 8 4 1
4 5 2 8 2 4 4 . 5 3 4 1 2 5 4 1 2 6 2 5 4 1 2 8 6 7 3 5 6 2 * 8 2 3 5 6 3 4 8 5 2 2 6 2
3 9 " 3 4 6 5 " 4 5 ! 4 5 $ 4 5 # 1 2 3 2 2 3 4 4 5 8 4 1 2 3 2 8 4 1 1 8 4 2 8
4 5 4 1 2 5 8 4 1 8 2 6 3 9 5 3 2 3 4 6 5 " 4 5 $ 5 5 7 8 3 4 8 2 4 1 8 4 4 5 # 8 3 1 2
5 5 3 2 8 3 9 8 3 4 8 4 ! 5 4 1 8 4 2 7 8 3 7 4 8 3 4 8 2 4 4 5 #
8/14/2019 Flow Network,Ford Fulkerson Method Notes
http://slidepdf.com/reader/full/flow-networkford-fulkerson-method-notes 11/32
0
1
2
3
4 5 6 4
4 5 7 4
4 5 8 4
4 5 7 4
4 5 6 4
0
1
2
3
6 4
7 4
8 4
7 4
6 4
9 1 ÿ 0
1 1 ÿ 0
3 ÿ 0 1 2 3
2 3 3 ÿ ÿ 6 4
0
1
2
3
6 4 5 6 4
4 5 7 4
6 4 5 8 4
4 5 7 4
6 4 5 6 4
0
1
2
3
7 4
7 4
3 ÿ 0 2 1 3
2 3 3 ÿ ÿ 7 4
7 4
6 4
6 4
6 4
0
1
3
6 4 5 6 4
7 4 5 7 4
7 4 5 8 4
0
1
3
6 4 7 4
6 4 7 4
9 9 0 ÿ 1
! 3 ! 1 " # ÿ 3 ÿ $ ÿ ! 0 ÿ 4 ÿ % ÿ 1 ÿ 0 &
' ( ) ÿ + , - ÿ . ) / - , ÿ ' ( ) ÿ ) : ÿ ; < ( ÿ
=
8/14/2019 Flow Network,Ford Fulkerson Method Notes
http://slidepdf.com/reader/full/flow-networkford-fulkerson-method-notes 12/32
0 1 2 3 4 5 6 7 8 9 6 4 1 3 0 1 2 3 4 5 6 7 8 9
! " # # ! $ % & % ' ( # # % & ) " ) *
+ % , , - + . , / ) " % % # - + + % , % '
: ; < = > ? @ ; A @ ; @ B C D E F " G H I J K L
M , N # % . . ! + O + % & , , # + P O % & , , ' ? = Q R S : ; R @ T D R @ U A M , V % W G H I I I L
1 3 0 1 2 3 4 5 6 7 8 9
X Y Z
[ \ ] ^ _ \ ` a b c a _ d ` ^ e f g h i j k l m c f ^ c _ n a o p n c b n p c ^ \ p q n c f ^ p a _ d a r s t ^ p _ \ c o ` a u a ` o ^ v t s r k ^ p _ w ] ^
b ^ e ^ b \ c x y z p b c \ n p { | l } ~
[ n ` ^ p x n y z p b c \ n p | l } ~
k c f a r { { \ o _ a w p a _ ^ o
{
i r s t m h
{ i r s t m i r s t m \ y r s t l
i t s r m \ y t s r l
n c f a ` \ o a
f a r g
h i j k l
m k f a ` a l
\ o c f a o a c n y a _ d a o f n o a p n p a ` n ` a o \ _ z ^ v b ^ e ^ b \ c x \ o e n o \ c \ u a
¡ ¢ = <
@ ; < £ ¤ £ ; Q
g
; @ ¤ ¤ R ; ¥ £ ; Q
g
¦
~ p c f a v ^ o c v a b c z ` a k a e ` n u a _ c f a § ^ ] n § \ p b z c f a n ` a ¨ | © ª ª « { ª « ¬ - ®
t r ¬ ¯ ° ¯ r ¯ i k m ± ² ¬ « ³ r ¬ { { ¬ ¯ ª ¯ r ¯ i k m ± { r ´ f a e ` n n y n y c f a
c f a n ` a ¨ \ o b n p o c ` z b c \ u a ~ y c f a ` a o \ _ z ^ v d ` ^ e f b n p c ^ \ p o ^ e ^ c f y ` n ̈ c n k c f a p a b ^ p \ p b ` a ^ o a c f a n
q x c f a ¨ \ p \ ¨ z ¨ b ^ e ^ b \ c x n y c f a a _ d a o n p c f \ o e ^ c f k o n a ¨ z o c p n c f ^ u a c f a ¨ ^ ] \ ¨ z ¨ n µ c f a ` \ o a k
a b ^ p _ a w p a ^ b z c i ¶ k · m f n o a b ^ e ^ b \ c x \ o c f a o ^ ¨ a ^ o c f a n k o z b f c f ^ c a u a ` x a _ d a y ` n ̈¶ c n · \ o
o ^ c z ` ^ c a _ ^ p _ a u a ` x a _ d a y ` n ̈· c n ¶ \ o a ¨ e c x k f \ b f \ ¨ e v \ a o c f ^ c \ o ^ ¨ ^ ] \ ¨ z ¨ n ^ p _ i ¶ k · m \ o ^
¨ \ p \ ¨ z ¨ b z c
¼
º »
¼ À ¼
8/14/2019 Flow Network,Ford Fulkerson Method Notes
http://slidepdf.com/reader/full/flow-networkford-fulkerson-method-notes 13/32
0 1 2 3 4 5 6 7 8 9 6 4 1 3 0 1 2 3 4 5 6 7 8 9
3 4 1 4 9 3
! " # $ % ! $ & # ' ( ) & " # " ( * $ ! ! + $ # ' # & # ' , ! ( , , & % ( # & ' - ! # # ' . ! $ ( " , / 0 $ % & 1 & ' ! * & % 2 -
3 ! $ % # % 3 4 ' 5 & $ ! ( " & 6 7 8 9 : ; # $ ( . < ( " " & ) & $ ! = ! < / $ & * & # & % ' - # 4 . , & " & = ! < # ' ! . >
* # " ? @ A ( " & $ & ( % # ' . $ # * " / ( ' " & $ & ( ! B " * # " C
+ & 1 & $ - & % . & B # * # B ( - ( # ( & . & $ / " & & 1 & $ - # 4 . , & # ( ! & * ( B $ & # & " & 1 # ' 4 & ! + " & = ! < 2 -
# * ! ( ( 1 & ( & . & $ C D " 4 / " & # ' . ! $ ( " , " # ' # + & $ E F
G
E ( & $ # ( ! / < " & $ & F
G
( " & # B 4 # ' , # H ( , 4 , = ! < C
I # B " ( & $ # ( ! $ & J 4 ( $ & K L M N ( , & / ! B $ & # & " & $ & ( % 4 # ' . $ # * " O
F
# % * & $ + ! $ , # < " # & 1 & $ P 0 $ P & # $ B " !
0 % # # 4 . , & ( . * # " C D " 4 / ( " & < ! $ % B # & / " & 3 ! $ % P 3 4 ' 5 & $ ! # ' . ! $ ( " , $ 4 ( Q R S T U
V
T W ( , & C
+ < & , 4 ' ( * ' - # ' ' " & B # * # B ( ( & 2 - " & # , & X * ! ( ( 1 & Y B ! # / " & , # H ( , 4 , = ! < ( B $ & # &
& 1 & $ - < " & $ & 2 - " & # , & B ! # + # B ! $ C + ! ' ' ! < " # ( + # ' ' " & & % . & B # * # B ( ( & # $ & Z [ A \ ] ^ [ _ / " & " &
3 ! $ % P 3 4 ' 5 & $ ! # ' . ! $ ( " , & 1 & 4 # ' ' - " # ' C ` ! < & 1 & $ / ( + < & # ' ' ! < ( $ $ # ( ! # ' B # * # B ( ( & / " & # ' . ! $ ( " , B #
' ! ! * + ! $ & 1 & $ / # ' < # - 0 % ( . , # ' ' & $ # % , # ' ' & $ # 4 . , & ( . * # " C a ! $ & - & / " ( ( 0 ( & & J 4 & B &
! + # 4 . , & # ( ! , # - ! & 1 & B ! 1 & $ . & ! " & , # H ( , 4 , = ! < b c & $ " # * " & ( , * ' & & H # , * ' & ! + " (
& + + & B < # % ( B ! & $ & % - d $ ( e < ( B C
f ! ( % & $ " & . $ # * " " ! < 2 & ' ! < / < ( " ( H 1 & $ ( B & # % ( & & % . & C ; ( H ! + " & & % . & " # 1 & ! , & ' # $ . &
( & . & $ B # * # B ( - g / < ! " # 1 & B # * # B ( - 6 / # % ! & " # B # * # B ( - h i L
j
k 6 N l m n 9 C o 6 p 9 q r / B " ! & !
" # 6 k h i h
m
C D ! * $ ! 1 & " # " & 3 ! $ % P 3 4 ' 5 & $ ! # ' . ! $ ( " , B # . & 4 B 5 / < & B # < # B " " & $ & ( % 4 # '
B # * # B ( ( & ! + " & " $ & & " ! $ ( ) ! # ' & % . & # " & # ' . ! $ ( " , * $ ! . $ & & C X D " & $ & ( % 4 # ' B # * # B ( ( & ! + " & ! " & $
( H & % . & < ( ' ' # ' < # - & # ' & # g k q C Y
s
t u
u
u
u u
u
v w
w
x y z
{ | } ~ } | } } | }
D " & 3 ! $ % P 3 4 ' 5 & $ ! # ' . ! $ ( " , # $ 2 - B " ! ! ( . " & B & $ # ' # 4 . , & ( . * # " / " ! < ( " & ' # $ . &
0 . 4 $ & # 2 ! 1 & C D " & " $ & & " ! $ ( ) ! # ' & % . & ( ! $ % & $ + $ ! , ' & + ! $ ( . " / ! < " # 1 & $ & ( % 4 # ' B # * # B ( ( & 6 / 9 /
h C ; 4 * * ! & ( % 4 B ( 1 & ' - " # " & " ! $ ( ) ! # ' $ & ( % 4 # ' B # * # B ( ( & # $ & h
k
/ 9 / h
+ ! $ ! , & ! P & . # ( 1 &
( & . & $ C
8/14/2019 Flow Network,Ford Fulkerson Method Notes
http://slidepdf.com/reader/full/flow-networkford-fulkerson-method-notes 14/32
8/14/2019 Flow Network,Ford Fulkerson Method Notes
http://slidepdf.com/reader/full/flow-networkford-fulkerson-method-notes 15/32
0 1 2 3 4 5 6 7 8 9 6 4 1 3 0 1 2 3 4 5 6 7 8 9
5 5 6 9 8 3 9 4 7 3 4 6 ! 5 9
" # $ % $ & ' ( ) * ) + ' ( ) % , - . / 0 # $ 1 / 2 % 3 2 & 4 . % . & 3 1 . 5 5 6 0 / ' 0 ' % $ ) 7 6 8 ' / ) . ( ) 8 1 5 9 $ / % ' ( 2 ( 3 # $ 2 / ' / 2 : 2 ( . 5
+ . ; , < ' 4 0 . 0 $ / = . ( ) > / % 3 . ( . 5 6 ? $ ) 7 6 3 # $ @ 1 % % 2 . ( + . 3 # $ + . 3 2 & 2 . ( A 2 ( 2 3 % B % ' + $ 3 2 + $ % 3 / . ( % 5 2 3 $ / . 3 $ ) A 2 ( 2 & C
2 ( D E F G H * ) + ' ( ) % . ( ) - . / 0 0 1 7 5 2 % # $ ) 3 # $ 2 / 2 ( ) $ 0 $ ( ) $ ( 3 . ( ) % 5 2 : # 3 5 6 4 $ . 9 $ / . ( . 5 6 % 2 % 2 ( D E F I H J '
( . / . = . + ' % $ K $ / ' ( $ / $ L $ / % ' # % . : ' / # + . % M * ) + ' ( ) % , - . / N H
I O # ' ' % $ # $ . : + $ ( ( : . # # L $ $ % $ ) : $ % H
" # $ & ' / / $ & 3 0 . 3 # & . ( 7 $ L ' 1 ( ) 2 ( P Q R S 3 2 + $ 7 6 / 1 ( ( 2 ( : 7 / $ . ) 3 # , > / % 3 % $ . / & # 2 ( 3 # $ / $ % 2 ) 1 . 5 : / . 0 # H T ' / $
% 1 / 0 / 2 % 2 ( : 5 6 = 3 # $ . 5 : ' / 2 3 # + # . 5 3 % . L 3 $ / . 0 ' 5 6 ( ' + 2 . 5 ( 1 + 7 $ / ' L 2 3 $ / . 3 2 ' ( % = 2 ( ) $ 0 $ ( ) $ ( 3 ' L 3 # $ . & 3 1 . 5 $ ) : $
& . . & $ % U
" # $ / ' ' L ' L # % $ / ' ( ) / $ $ % ' ( ' ' % $ / K . ' ( % . ' # $ $ K ' ' ( ' L # $ / $ % ) . : / . # H
V $ 3 W
X
7 $ 3 # $ & 1 / / $ ( 3 < ' 4 . L 3 $ / X . 1 : + $ ( 3 . 3 2 ' ( % 3 $ 0 % = 5 $ 3 Y
X
7 $ 3 # $ & ' / / $ % 0 ' ( ) 2 ( : / $ % 2 ) 1 . 5 : / . 0 # H Z (
0 . / 3 2 & 1 5 . / = W
G
2 % ? $ / ' $ K $ / 6 4 # $ / $ . ( ) Y
G
[ Y H 8 ' / $ . & # K $ / 3 $ ; \ = 5 $ 3 ] ^ \ ^ ]
X
Q \ S ) $ ( ' 3 $ 3 # $ 1 ( 4 $ 2 : # 3 $ )
% # ' / 3 $ % 3 0 . 3 # ) 2 % 3 . ( & $ L / ' + _ 3 ' \ 2 ( Y
X
= ' / $ ` 1 2 K . 5 $ ( 3 5 6 = 3 # $ ] ^ \ ^ ] ' L \ 2 ( . 7 / $ . ) 3 # , > / % 3 % $ . / & # 3 / $ $ ' L Y
X
/ ' ' $ ) . _ H
a / > / % ' % $ / K . ' ( % # . # $ % $ $ K $ % & . ( ' ( ( & / $ . % $ ' K $ / + $ H
8 8 ] ^ \ ^ ]
X b D
Q \ S c ] ^ \ ^ ]
X
Q \ S d e f g h h i j f k l m j n \ g o p l o k j q j f n X r
! 4 3 3 s " # $ & 5 . 2 + 2 % 3 / 2 K 2 . 5 L ' / \ [ _ = % 2 ( & $ ] ^ \ ^ ]
X
Q _ S [ G L ' / . 5 5 X H O # ' ' % $ . ( . / 7 2 3 / . / 6 K $ / 3 $ ; \ t [ _ = . ( )
5 $ 3 _ u v v v u w u \ 7 $ . % # ' / 3 $ % 3 0 . 3 # L / ' + _ 3 ' \ 2 ( Y
X b D
H B Z L 3 # $ / $ 2 % ( ' % 1 & # 0 . 3 # = 3 # $ ( ] ^ \ ^ ]
X b D
Q \ S [ x =
. ( ) 4 $ N / $ ) ' ( $ H C y $ & . 1 % $ 3 # 2 % 2 % . % # ' / 3 $ % 3 0 . 3 # = 4 $ # . K $ ] ^ \ ^ ]
X b D
Q \ S [ ] ^ \ ^ ]
X b D
Q w S b D = . ( ) 3 # $ 2 ( ) 1 & 3 2 K $
# ' # $ % % + $ % # . ] ^ \ ^ ]
X b D
Q w S c ] ^ \ ^ ]
X
Q w S H
z $ ( ' 4 # . K $ 3 4 ' & . % $ % 3 ' & ' ( % 2 ) $ / H Z L w u \ 2 % . ( $ ) : $ 2 ( Y
X
= 3 # $ ( ] ^ \ ^ ]
X
Q \ S { ] ^ \ ^ ]
X
Q w S b D = 7 $ & . 1 % $
# $ $ K $ % . / $ ) $ > ( $ ) / $ . ) # , > / % / . K $ / % . H
a ( 3 # $ ' 3 # $ / # . ( ) = 2 L w u \ 2 % ( ' 3 . ( $ ) : $ 2 ( Y
X
= 3 # $ ( \ u w + 1 % 3 7 $ . ( $ ) : $ 2 ( 3 # $ X 3 # . 1 : + $ ( 3 2 ( : 0 . 3 # H
" # 1 % = \ u w + 1 % 3 5 2 $ ' ( 3 # $ % # ' / 3 $ % 3 0 . 3 # L / ' + _ 3 ' | 2 ( Y
X
= 4 # 2 & # 2 + 0 5 2 $ % 3 # . 3 ] ^ \ ^ ]
X
Q \ S [ ] ^ \ ^ ]
X
Q w S } D {
] ^ \ ^ ]
X
Q w S b D H
Z ( ' # & . % $ % = $ # . K $ ] ^ \ ^ ]
X b D
Q \ S [ ] ^ \ ^ ]
X b D
Q w S b D c ] ^ \ ^ ]
X
Q w S b D c ] ^ \ ^ ]
X
Q \ S H ~
z # $ ( $ K $ / 4 $ . 1 : + $ ( 3 3 # $ < ' 4 = 3 # $ 7 ' 3 3 5 $ ( $ & 9 $ ) : $ 2 ( 3 # $ . 1 : + $ ( 3 2 ( : 0 . 3 # ) 2 % . 0 0 $ . / % L / ' + 3 # $
/ $ % 2 ) 1 . 5 : / . 0 # = . ( ) % ' + $ ' 3 # $ / $ ) : $ 2 ( 3 # $ ^ \ ^ _ ] ' L 3 # $ . 1 : + $ ( 3 2 ( : 0 . 3 # + . 6 B / $ , C . 0 0 $ . / H a 1 / % $ & ' ( )
' % $ / K . ' ( % # . . ( $ ) : $ & . ( ( ' . $ . / ' / ) % . $ . / ' ' + . ( + $ % H
8 8 f l o q k j j j m k l e o e d k j l o l k n p e o p n g f g h q e f l k g o j p q j w u \ p l n g j g f n d f e
k j f j n l p g h q f g Y
W
g k e n k I k l j n r
! 4 3 3 s J 1 0 0 ' % $ w u \ 2 % 2 ( 3 4 ' / $ % 2 ) 1 . 5 : / . 0 # % Y
X
. ( ) Y
b D
= 7 1 3 ( ' 3 2 ( . ( 6 ' L 3 # $ 2 ( 3 $ / + $ ) 2 . 3 $ / $ % 2 ) 1 . 5
: / . 0 # % Y X b D
= H H H = Y
= L ' / % ' + $ X H " # $ ( w u \ + 1 % 3 7 $ 2 ( 3 # $ X 3 # . 1 : + $ ( 3 2 ( : 0 . 3 # = % ' ] ^ \ ^ ] X
Q \ S [
8/14/2019 Flow Network,Ford Fulkerson Method Notes
http://slidepdf.com/reader/full/flow-networkford-fulkerson-method-notes 16/32
Maximum Flow Networks
CONTENTS
• Network flows on directed ac clic ra hs
• Ford‐Fulkerson Algorithms
‐Residual networks
• Min cut Max flow theorem
• Max Bipartite matching
Network flows on directed acyclic graphs• DAG is a directed graph with no cycles.
• Flow network: a flow network G = (V,E) is a directed graphin which each edge (u,v) E has a nonnegative capacityc(u,v) >= 0. if (u,v) E , we assume that c(u,v) = 0.
We distinguish two vertices in flow network , source s andsink t.
• The source produces the material at a steady rate .e s n consumes e ma er a a a s ea y ra
Objective : how much of material can be imposed throughnetwork that network can handle
• Flow:A flow in G is a real-valued function f : V × V→ R thatsatisfies three properties:
1. Capacity constraint : For all u,v V, we require f(u,v) ≤ c(u,v).The net flow from one vertex to another must not exceed the givencapacity.
2. Skew symmetry : For all u,v V, we require f(u,v) = -f(v,u).
The net flow from a vertex u to a vertex v is the negative of the netflow in the reverse direction
3. Flow conservation : For all u V - {s,t}, we require∑ f(u,v) = 0.v V
The quantity f(u,v),which can be positive or negative , is called thenet flow from vertex u to v.The value of the flow is defined as | f | = ∑ f(s,v) that is the totat
net Flow out of the source. v V
Residual Networks
• Given a flow network and a flow, residual network consists of edges that can admit more flow.
• before exceeding the capacity c(u,v) is the residual capacity of
(u,v), given by
Cf (u,v) - f(u,v)
• Given a flow network G=(V,E) and a flow f, the residual network of G induced by f is Gf =(V,E) and a flow f, the ResidualNetwork of G
Ef ={(u,v) V×V : cf (u,v)>0}
That is, each edge of residual network , or residual edge, canadmit a flow that is greater than 0.
8/14/2019 Flow Network,Ford Fulkerson Method Notes
http://slidepdf.com/reader/full/flow-networkford-fulkerson-method-notes 17/32
Augmenting Paths
• Given a flow network and a flow f, an augmenting
network Gf .
• Residual capacity of path p is defined as the
maximum amount by which we can increase the flow
on each edge of p, given by
cf p =m n cf u,v : u,v s on p
• Cut(S,T) of flow network G=(V,E) is a partition of V
- suc .
• If f is a flow, then the net flow across the cut(S,T) is
defined to be f(S,T).
• The capacity of the cut (S,T) is c(S,T)
• A minimum cut of a network is a cut whose capacity
is minimum over all cuts of the network
s t
v1 v311/16 15/20
101/4
4/9
7/7
12/12
v4v28/13 11/14
4/4
•The net flow across (S,T) is f(s,t)=19, and the capacity is c(S,T)=26
• e ne ow across cu s
f(v1,v3) + f(v2,v3) + f(v2,v4) = 12+(-4)+11= 19
•Capacity is
c(v1,v3)+c(v2,v4) = 12 + 14 = 26
Ford-Fulkerson-Method(G,s,t)
1. Initialize flow f to 0
2. W e t ere ex sts an augment ng pat p
3. Do augment flow f along p
4. Return f
8/14/2019 Flow Network,Ford Fulkerson Method Notes
http://slidepdf.com/reader/full/flow-networkford-fulkerson-method-notes 18/32
Ford Fulkerson algorithm• The Ford Fulkerson method is iterative,
• Starts with f(u,v) for (u,v) V, initial flow of value 0.
• The method is based on the augmenting path which is
defined as a path from s to t along which we can push
more flow and then augment flow along this path.
Procedure Ford_Fulkerson_method(G,s,t):
1. For each edge (u,v) E[G]
. ,
3. f[v,u] 0
4. While there exists path p from s to t in residual network Gf
5. do cf (p)min{ cf (u,v):(u,v) is in p}
6. for each edge (u,v) in p
7. do f u v f u v + c. , ,
8. f[v,u] -f[u,v]
• Running time for this algorithms is O(E * |f*|) where f* is the
maximum flow found by algorithm.
• First three Lines take time θ(E).
• The while loop of last five lines is executed at most |f*| times,
since the flow value increases by at least one unit in each
iteration.
s t
v1 v216
12
20
104
9
7
I/P Residual network
v4v313
14
4
v1 v24/16
4/12
20
s t
v4v3
13 4/14
4/4
104
4/9
7
Flow network
8/14/2019 Flow Network,Ford Fulkerson Method Notes
http://slidepdf.com/reader/full/flow-networkford-fulkerson-method-notes 19/32
8/14/2019 Flow Network,Ford Fulkerson Method Notes
http://slidepdf.com/reader/full/flow-networkford-fulkerson-method-notes 20/32
Max flow min cut theorem
• This theorem tell us that a flow is max. if and only if its residual
network contains no augmenting path.
Theorem states that ,
If f is a flow in a flow network, G = (V,E) with the source and sink t
then, the following conditions are equivalent:
1. F is a max. flow in G.
2. The residual network G1 contains no augments paths.
3. |F| = c(S,T) for some cut (S,T) of G.
Maximum Bipartite Matching
• Given an undirected graph G=(V,E), matching is a subset of
edges M is subset of E such that for all vertices v ∈ V, at most
one edge of M is incident on v.
• We say that a vertex v ∈V is matched by matching M if some
edge in M is incident on v; otherwise, v is unmatched.
• A maximum matching is a matching of maximum cardinality,
that is, a matching M such that for any matching M’, we have|M|>= |M’|.
A bipartite graph G=(V,E) with vertex partition V= L U R
A matching with
Cardinality 2
A matching with
Cardinality 3
• We can solve the maximum match finding problemusing flow networks.
• Put source and sink on the graph such that sourceconnects a t e vert ces on e t s e o t e grap
with single edge to each vertex and do the same forthe sink. Now assign weight 1 to all the edges in thegraph.
• Run ford Fulkerson al orithm to find max flow.
• Max. cardinality = Max flow
Maximum Flow and Minimum Cut
8/14/2019 Flow Network,Ford Fulkerson Method Notes
http://slidepdf.com/reader/full/flow-networkford-fulkerson-method-notes 21/32
Princeton University • COS 226 • Algorithms and Data Structures • Spring 2004 • Kevin Wayne • http://www.Princeton.EDU/~cos226
Max Flow, Min Cut
Minimum cut
Maximum flow
Max-flow min-cut theorem
Ford-Fulkerson augmenting path algorithm
Edmonds-Karp heuristics
Bipartite matching
2
n Network reliability.
n Security of statistical data.
n Distributed computing.
n Egalitarian stable matching.
n Distributed computing.
n
Many many more . . .
Max flow and min cut.
n Two very rich algorithmic problems.
n Cornerstone problems in combinatorial optimization.
n Beautiful mathematical duality.
Nontrivial applications / reductions.
n Network connectivity.
n Bipartite matching.
n Data mining.
n Open-pit mining.
n Airline scheduling.
n
Image processing.n Project selection.
n Baseball elimination.
3
Soviet Rail Network, 1955
Source: On the history of the transportation and maximum flow problems .Alexander Schrijver in Math Programming, 91: 3, 2002.
4
Network: abstraction for material FLOWING through the edges.
n Directed graph.
n Capacities on edges.
n Source node s, sink node t.
Min cut problem. Delete "best" set of edges to disconnect t from s.
Minimum Cut Problem
capacity
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10154
4
sinksource
Cuts Cuts
8/14/2019 Flow Network,Ford Fulkerson Method Notes
http://slidepdf.com/reader/full/flow-networkford-fulkerson-method-notes 22/32
5
A cut is a node partition (S, T) such that s is in S and t is in T.
n capacity(S, T) = sum of weights of edges leaving S.
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10154
4
Capacity = 30
S
6
A cut is a node partition (S, T) such that s is in S and t is in T.
n capacity(S, T) = sum of weights of edges leaving S.
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10154
4S
Capacity = 62
7
A cut is a node partition (S, T) such that s is in S and t is in T.
n capacity(S, T) = sum of weights of edges leaving S.
Min cut problem. Find an s-t cut of minimum capacity.
Minimum Cut Problem
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10154
4S
Capacity = 28
8
Network: abstraction for material FLOWING through the edges.
n Directed graph.
n Capacities on edges.
n Source node s, sink node t.
Max flow problem. Assign flow to edges so as to:n Equalize inflow and outflow at every intermediate vertex.
n Maximize flow sent from s to t.
Maximum Flow Problem
same input as min cut problem
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10154
4capacity
sinksource
Flows Flows
8/14/2019 Flow Network,Ford Fulkerson Method Notes
http://slidepdf.com/reader/full/flow-networkford-fulkerson-method-notes 23/32
9
A flow f is an assignment of weights to edges so that:
n Capacity: 0 £ f(e) £ u(e).
n Flow conservation: flow leaving v = flow entering v.
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10154
4
4
0
0
0
0 0
0 4 4
0
4 0
00
Value = 4
except at s or t
0
capacityflow
10
A flow f is an assignment of weights to edges so that:
n Capacity: 0 £ f(e) £ u(e).
n Flow conservation: flow leaving v = flow entering v.
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10154
4
10
6
6
11
1 10
3 8 8
0
4 0
00
Value = 2411
capacityflow
except at s or t
11
Max flow problem: find flow that maximizes net flow into sink.
Maximum Flow Problem
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10154
4
10
9
9
14
4 10
4 8 9
1
0 0
00
Value = 2814
capacityflow
12
Observation 1. Let f be a flow, and let (S, T) be any s-t cut. Then, thenet flow sent across the cut is equal to the amount reaching t.
Flows and Cuts
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10154
4
10
6
6
0 10
4 8 8
0
4 0
00S 10
10 Value = 24
Flows and Cuts
Flows and Cuts
8/14/2019 Flow Network,Ford Fulkerson Method Notes
http://slidepdf.com/reader/full/flow-networkford-fulkerson-method-notes 24/32
13
10
6
6
10 0 10
4 8 8
0
4 0
0
Observation 1. Let f be a flow, and let (S, T) be any s-t cut. Then, thenet flow sent across the cut is equal to the amount reaching t.
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10154
4
S
0
10 Value = 24
14
10
6
6
10
0 10
4 8 8
0
4 0
0
Observation 1. Let f be a flow, and let (S, T) be any s-t cut. Then, thenet flow sent across the cut is equal to the amount reaching t.
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10154
4 0
S10
Value = 24
15
Observation 2. Let f be a flow, and let (S, T) be any s-t cut. Then thevalue of the flow is at most the capacity of the cut.
Flows and Cuts
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10154
4S
Cut capacity = 30 Þ Flow value £ 30
16
Max Flow and Min Cut
Observation 3. Let f be a flow, and let (S, T) be an s-t cut whose capacityequals the value of f. Then f is a max flow and (S, T) is a min cut.
Cut capacity = 28 Þ Flow value £ 28
Flow value = 28
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10154
4
10
9
9
15
4 10
4 8 9
1
0 0
00S 15
Max-Flow Min-Cut Theorem Towards an Algorithm
8/14/2019 Flow Network,Ford Fulkerson Method Notes
http://slidepdf.com/reader/full/flow-networkford-fulkerson-method-notes 25/32
17
Max-flow min-cut theorem. (Ford-Fulkerson, 1956): In any network,the value of max flow equals capacity of min cut.
n Proof IOU: we find flow and cut such that Observation 3 applies.
Min cut capacity = 28Û
Max flow value = 28
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10154
4
10
9
9
15
4 10
4 8 9
1
0 0
00S 15
18
Find s-t path where each arc has f(e) < u(e) and "augment" flow along it.
s
4
2
5
3 t
4
0 0
0 0 0
0
40
44
10 13 10
Flow value = 0
flowcapacity
19
Towards an Algorithm
Find s-t path where each arc has f(e) < u(e) and "augment" flow along it.
n Greedy algorithm: repeat until you get stuck.
s
4
2
5
3 t
4
0 0
0 0 0
0
40
44
10 13 10
10 10 10X X X
Flow value = 10
Bottleneck capacity of path = 10
flow
capacity
20
Towards an Algorithm
Find s-t path where each arc has f(e) < u(e) and "augment" flow along it.
n Greedy algorithm: repeat until you get stuck.
n Fails: need to be able to "backtrack."
s
4
2
5
3 t10 13 10
4
4 4
10 6 10
4
44
44
Flow value = 10
Flow value = 14
s
4
2
5
3 t
4
0 0
0 0 0
0
40
44
10 13 10
10 10 10X X X
flow
capacity
Residual Graph Augmenting Paths
8/14/2019 Flow Network,Ford Fulkerson Method Notes
http://slidepdf.com/reader/full/flow-networkford-fulkerson-method-notes 26/32
21
Original graph.
n Flow f(e).
n Edge e = v-w
Residual edge.
n Edge e = v-w or w-v.
n "Undo" flow sent.
Residual graph.
n All the edges that havestrictly positive residual capacity.
v w176
capacity = u(e)
v w11
6
residual capacity = u(e) – f(e)
residual capacity = f(e)
flow = f(e)
22
Augmenting path = path in residual graph.
n Increase flow along forward edges.
n Decrease flow along backward edges.
s
4
2
5
3 t10 13 10
4
0 0
10 10 10
0
40
44
s
4
2
5
3 t10 10 10
44
44
3
4 4
6
4
4
X
X
X
X
Xoriginal
residual
23
Augmenting Paths
Observation 4. If augmenting path, then not yet a max flow.
Q. If no augmenting path, is it a max flow?
Flow value = 14
s
4
2
5
3 t10 6 10
44
44
7
residual
s
4
2
5
3 t10 13 10
40 0
10 10 10
0
404
4original4 4
6
4
4
X
XX
X
X
24
Ford-Fulkerson Augmenting Path Algorithm
Ford-Fulkerson algorithm. Generic method for solving max flow.
Questions.
n Does this lead to a maximum flow? yes
n How do we find an augmenting path? s-t path in residual graph
n How many augmenting paths does it take?
n How much effort do we spending finding a path?
while (there exists an augmenting path) {
Find augmenting path P
Compute bottleneck capacity of PAugment flow along P
}
Max-Flow Min-Cut Theorem Proof of Max-Flow Min-Cut Theorem
8/14/2019 Flow Network,Ford Fulkerson Method Notes
http://slidepdf.com/reader/full/flow-networkford-fulkerson-method-notes 27/32
25
Augmenting path theorem. A flow f is a max flow if and only if thereare no augmenting paths.
We prove both simultaneously by showing the following are equivalent:
(i) f is a max flow.
(ii) There is no augmenting path relative to f.
(iii) There exists a cut whose capacity equals the value of f.
(i) Þ (ii) equivalent to not (ii)Þ not (i), which was Observation 4
(ii) Þ (iii) next slide(iii) Þ (i) this was Observation 3
Max-flow min-cut theorem. The value of the maxflow is equal to the capacity of the min cut.
26
(ii) Þ (iii). If there is no augmenting path relative to f, then thereexists a cut whose capacity equals the value of f.
Proof.
n Let f be a flow with no augmenting paths.
n Let S be set of vertices reachable from s in residual graph.
– S contains s; since no augmenting paths, S does not contain t
– all edges e leaving S in original network have f(e) = u(e)
– all edges e entering S in original network have f(e) = 0
T)(S,
)(
)()(
ofout
toinofout
capacity
e u
e f e f f
S e
S e S e
=
=
-=
å
åå
s
t
residual network
S T
27
Max Flow Network Implementation
Edge in original graph may correspond to 1 or 2 residual edges.
n May need to traverse edge e = v-w in forward or reverse direction.
n Flow = f(e), capacity = u(e).
n Insert two copies of each edge, one in adjacency list of v and one in w.
public class Edge {
private int v , w; // from, to
private int cap; // capacity from v to w
private int flow; // flow from v to w
public Edge(int v , int w, int cap) { ... }
public int cap() { return cap; }
public int flow() { return flow; }
public boolean from (int v ) { return this. v == v ; }
public int other(int v ) { return from ( v ) ? this.w : this. v ; } public int capRto(int v ) { return from ( v ) ? flow : cap - flow; }
public void addflowRto(int v , int d ) { flow += from ( v ) ? -d : d ; }
}
28
Ford-Fulkerson Algorithm: Implementation
Ford-Fulkerson main loop.
// while there exists an augmenting path, use it
while (augpath()) {
// compute bottleneck capacity
int bottle = INFINITY;
for (int v = t; v != s; v = ST( v ))
bottle = Math. min( bottle, pred [ v ].capRto( v ));
// augment flow
for (int v = t; v != s; v = ST( v ))
pred [ v ].addflowRto( v , bottle);
// keep track of total flow sent from s to t
value += bottle;
}
Ford-Fulkerson Algorithm: Analysis Choosing Good Augmenting Paths
8/14/2019 Flow Network,Ford Fulkerson Method Notes
http://slidepdf.com/reader/full/flow-networkford-fulkerson-method-notes 28/32
29
Assumption: all capacities are integers between 1 and U.
Invariant: every flow value and every residual capacities remain aninteger throughout the algorithm.
Theorem: the algorithm terminates in at most | f * | £ V U iterations.
Corollary: if U = 1, then algorithm runs in £ V iterations.
Integrality theorem: if all arc capacities are integers, then thereexists a max flow f for which every flow value is an integer.
not polynomialin input size!
30
1000
0
1
100
100
0
0
0
Use care when selecting augmenting paths.
100
Original Network
s
4
2
t
31
1000
0s
4
2
t1
100
100
0
0
0
Choosing Good Augmenting Paths
Use care when selecting augmenting paths.
100
1
1
1
X
X
X
Original Network
32
1001
100
1
0
Choosing Good Augmenting Paths
Use care when selecting augmenting paths.
100
100
1
10
Original Network
s
4
2
t
Choosing Good Augmenting Paths Choosing Good Augmenting Paths
8/14/2019 Flow Network,Ford Fulkerson Method Notes
http://slidepdf.com/reader/full/flow-networkford-fulkerson-method-notes 29/32
33
1001
s
4
2
t1
100
100
1
0
Use care when selecting augmenting paths.
100
1
0
1
X
X
X
10
Original Network
34
s
4
2
t1
100
100 100
100
0
1
1 1
1
Use care when selecting augmenting paths.
200 iterations possible!
Original Network
35
Choosing Good Augmenting Paths
Use care when selecting augmenting paths.
n Some choices lead to exponential algorithms.
n Clever choices lead to polynomial algorithms.
n Optimal choices for real world problems ???
Design goal is to choose augmenting paths so that:
n Can find augmenting paths efficiently.
n Few iterations.
Choose augmenting path with: Edmonds-Karp (1972)
n Fewest number of arcs. (shortest path)
n Max bottleneck capacity. (fattest path)
36
Shortest Augmenting Path
Shortest augmenting path.
n Easy to implement with BFS.
n Finds augmenting path with fewest number of arcs.
while (!q .isEmpty()) {
int v = q .dequeue();
IntIterator i = G.neighbors( v );
while(i.hasNext()) {
Edge e = i.next();
int w = e.other( v );
if (e.capRto(w) > 0) { // is v-w a residual edge?
if (wt[w] > wt[ v ] + 1) {
wt[w] = wt[ v ] + 1;
pred [w] = e; // keep track of shortest path
q .enqueue(w);
}
}}
}
return (wt[t] < INFINITY); // is there an augmenting path?
Shortest Augmenting Path Analysis Fattest Augmenting Path
8/14/2019 Flow Network,Ford Fulkerson Method Notes
http://slidepdf.com/reader/full/flow-networkford-fulkerson-method-notes 30/32
37
Length of shortest augmenting path increases monotonically.
n Strictly increases after at most E augmentations.
n At most E V total augmenting paths.
n O(E2 V) running time.
38
Fattest augmenting path.
n Finds augmenting path whose bottleneck capacity is maximum.
n Delivers most amount of flow to sink.
n Solve using Dijkstra-style (PFS) algorithm.
Finding a fattest path. O(E log V) per augmentation with binary heap.
Fact. O(E log U) augmentations if capacities are between 1 and U.
v w10residual capacity
12 9X 10
if (wt[w] < Math. min(wt[ v ], e.capRto(w)) {
wt[w] = Math. min(wt[ v ], e.capRto(w));
pred [w] = v ;}
39
Choosing an Augmenting Path
Choosing an augmenting path.
n Any path will do Þ wide latitude in implementing Ford-Fulkerson.
n Generic priority first search.
n Some choices lead to good worst-case performance.
– shortest augmenting path
– fattest augmenting path
– variation on a theme: PFS
n Average case not well understood.
Research challenges.
n Practice: solve max flow problems on real networks in linear time.
n Theory: prove it for worst-case networks.
40
History of Worst-Case Running Times
Dantzig
Discoverer
Simplex
Method Asymptotic Time
E V2 U †1951
Year
Ford, Fulkerson Augmenting path E V U †1955
Edmonds-Karp Shortest path E2 V1970
Dinitz Improved shortest path E V21970
Edmonds-Karp, Dinitz Capacity scaling E2 log U †1972
Dinitz-Gabow Improved capacity scaling E V log U †1973
Karzanov Preflow-push V31974
Sleator-Tarjan Dynamic trees E V log V1983
Goldberg-Tarjan FIFO preflow-push E V log (V2 / E)1986
. . . . . . . . .. . .
Goldberg-Rao Length function E3/2
log (V2
/ E) log U†
EV2/3 log (V2 / E) log U †1997
Edmonds-Karp Max capacity E log U (E + V log V) †1970
† Arc capacities are between 1 and U.
An Application Bipartite Matching
8/14/2019 Flow Network,Ford Fulkerson Method Notes
http://slidepdf.com/reader/full/flow-networkford-fulkerson-method-notes 31/32
41
Jon placement.
n Companies make job offers.
n Students have job choices.
Can we fill every job?
Can we employ every student?
Alice-Adobe
Bob-Yahoo
Carol-HP
Dave-AppleEliza-IBM
Frank-Sun
42
Bipartite matching.
n Input: undirected and bipartite graph G.
n Set of edges M is a matching if each vertex appears at most once.
n Max matching: find a max cardinality matching.
1
3
5
A
C
E
2
4
B
D
Matching M
1-B, 3-A, 4-E
RL
43
Bipartite Matching
Bipartite matching.
n Input: undirected and bipartite graph G.
n Set of edges M is a matching if each vertex appears at most once.
n Max matching: find a max cardinality matching.
1
3
5
A
C
E
2
4
B
D
Matching M
1-A, 2-B, 3-C, 4-D
RL
44
Reduces to max flow.
n Create a directed graph G'.
n Direct all arcs from L to R, and give infinite (or unit) capacity.
n Add source s, and unit capacity arcs from s to each node in L.
n Add sink t, and unit capacity arcs from each node in R to t.
Bipartite Matching
RL
s
1
3
5
A
C
E
t
2
4
B
D
1 1
¥1
3
5
A
C
E
2
4
B
D
G'G
Bipartite Matching: Proof of Correctness Bipartite Matching: Proof of Correctness
8/14/2019 Flow Network,Ford Fulkerson Method Notes
http://slidepdf.com/reader/full/flow-networkford-fulkerson-method-notes 32/32
45
Claim. Matching in G of cardinality k induces flow in G' of value k.
n Given matching M = { 1-B, 3-A, 4-E } of cardinality 3.
n Consider flow f that sends 1 unit along each of 3 paths:s-1-B-t s-3-A-t s-4-E-t.
n
f is a flow, and has cardinality 3.
RL
s
1
3
5
A
C
E
t
2
4
B
D
1 1
¥1
3
5
A
C
E
2
4
B
D
G'G46
Claim. Flow f of value k in G' induces matching of cardinality k in G.
n By integrality theorem, there exists 0/1 valued flow f of value k.
n Consider M = set of edges from L to R with f(e) = 1.
– each node in L and R incident to at most one edge in M
– |M| = k
RL
s
1
3
5
A
C
E
t
2
4
B
D
1 1
¥1
3
5
A
C
E
2
4
B
D
G'G
47
Reduction.
n Given an instance of bipartite matching.
n Transform it to a max flow problem.
n Solve max flow problem.
n Transform max flow solution to bipartite matching solution.
Issues.
n How expensive is transformation? O(E + V)
n Is it better to solve problem directly? O(E V1/2) bipartite matching
Bottom line: max flow is an extremely rich problem-solving model.
n Many important practical problems reduce to max flow.
n We know good algorithms for solving max flow problems.
Reduction