You are on page 1of 17

Theoretical Improvements in Algorithmic Efficiency

for Network Flow Problems


J ACK E DMONDS
University of Waterloo, Waterloo, Ontario, Canada
AND
RI CHARD M. KARP
University of California, Berkeley, California
ABSTRACT. Thi s pa pe r pr e s e nt s new a l gor i t hms f or t h e ma x i mu m flow pr obl e m, t he Hi t chcock
t r a n s p o r t a t i o n pr obl e m, a nd t h e gener al mi n i mu m- c o s t flow pr obl e m. Up p e r bounds on t he
numbe r s of s t eps i n t he s e a l gor i t hms ar e de r i ve d, a nd are s hown t o c ompa l e f a v o r a b l y wi t h
uppe r bounds on t h e n u mb e r s of s t eps r e qui r e d by ear l i er a l gor i t hms .
Fi r s t , t he pa pe r s t a t e s t he ma x i mu m flow pr obl e m, gi ves t he Fo r d - Fu l k e r s o n l a be l i ng me t hod
f or i t s s ol ut i on, a nd poi nt s out t h a t an i mpr ope r choi ce of flow a u g me n t i n g p a t h s can l ead t o
s ever e c o mp u t a t i o n a l di f f i cul t i es. Th e n r ul es of choi ce t h a t a voi d t hes e di f f i cul t i es are gi ven.
We s how t h a t , if e a c h flow a u g me n t a t i o n is ma de al ong an a u g me n t i n g p a t h h a v i n g a mi n i mu m
n u mb e r of arcs, t h e n a ma x i mu m flow i n an n- node ne t wor k wi l l be o b t a i n e d a f t e r no mor e t h a n
~(n a - n) a u g me n t a t i o n s ; a nd t h e n we s how t h a t if e a c h flow change is chos en t o pr oduce a
ma x i mu m i ncr eas e i n t he flow va l ue t he n, pr ovi de d t he capaci t i es are i nt e gr a l , a ma x i mu m flow
will be d e t e r mi n e d wi t h i n a t mos t 1 + logM/(M--1) i f (t , S) a u g me n t a t i o n s , wheref*(t, s) is t he
va l ue of t he ma x i mu m flow a nd M is t he ma x i mu m n u mb e r of ar cs acr oss a cut .
Ne x t a new a l g o r i t h m is gi ven for t he mi n i mu m- c o s t flow pr obl e m, i n whi c h all s h o r t e s t - p a t h
c o mp u t a t i o n s are pe r f or me d on ne t wor ks wi t h al l wei ght s nonne ga t i ve . I n pa r t i c ul a r , t hi s
a l g o r i t h m sol ves t he n X n a s s i gmne nt pr obl e m i n O(n 3) s t eps . Fol l owi ng t h a t we expl or e a
" s c a l i n g " t e c h n i q u e f or s ol vi ng a mi n i mu m- c o s t flow pr obl e m by t r e a t i n g a s equence of der i ved
pr obl e ms wi t h " s c a l e d d o wn " capaci t i es . I t is s hown t h a t , us i ng t hi s t e c hni que , t he s ol ut i on of
a I i i t c h c o c k t r a n s p o r t a t i o n pr obl e m wi t h m s our ces a nd n s i nks , m ~ n, a nd ma x i mu m flow B,
r equi r es at mos t (n + 2) log2 (B/n) flow a u g me n t a t i o n s . Si mi l ar r es ul t s are al so gi ven f or t he
gener al mi n i mu m- c o s t flow pr obl e m.
An a b s t r a c t s t a t i n g t he ma i n r es ul t s of t he pr e s e nt pa pe r was pr e s e nt e d a t t he Cal gar y
I n t e r n a t i o n a l Conf er ence on Co mb i n a t o r i a l St r u c t u r e s a nd Th e i r Appl i c a t i ons , J u n e 1969.
I n a pa pe r b y l ) i ni c (1970) a r e s ul t cl osel y r e l a t e d t o t he ma i n r e s ul t of Sect i on 1.2 is obt a i ne d.
Di ni c shows t h a t , i n a ne t wor k wi t h n nodes a nd p ar cs, a ma x i mu m flow can be c omput e d i n
0 (n2p) p r i mi t i v e ope r a t i ons b y an a l gor i t hm whi c h a u g me n t s al ong s h o r t e s t a u g me n t i n g pat hs .
KEY WOll)S AND PHP~ASES: ne t wor k flows, t r a n s p o r t a t i o n pr obl em, anal ys i s of a l gor i t hms
CR CATEGOI{.IES: 5.3, 5.4, 8.3
Co p y r i g h t 1972, As s oci at i on f or Co mp u t i n g Ma c hi ne r y, I nc.
Ge ne r a l pe r mi s s i on t o r e publ i s h, b u t not f or pr of i t , al l or p a r t of t hi s ma t e r i a l is gr ant ed,
pr ovi de d t h a t r ef er ence is ma de t o t hi s publ i c a t i on, t o i t s da t e of i ssue, a nd t o t he f act t h a t
r e p r i n t i n g pr i vi l eges wer e g r a n t e d by pe r mi s s i on of t he As s oci at i on f or Co mp u t i n g Ma c hi ne r y.
Aut hor s ' addr es s es : J . Edmonds , De p a r t me n t of Combi na t or i c s a nd Opt i mi z a t i on, Uni ve r s i t y
of Wat er l oo, Wa t e r l oo, Ont a r i o, Ca n a d a ; R. M. Ka r p, Col l ege of Engi ne e r i ng, Ope r a t i ons
Re s e a r c h Ce nt e r , Un i v e r s i t y of Cal i f or ni a, Ber kel ey, CA 94720; t he l a t t e r a u t h o r ' s r es ear ch has
be e n p a r t i a l l y s u p p o r t e d by t he Na t i o n a l Sci ence Fo u n d a t i o n r ai der Gr a n t GP-15473 wi t h t he
Un i v e r s i t y of Cal i f or ni a.
Jc~urnal of the Association for Computing Machinery, Vol. 19, No. 2, Apri| 1972. pp. 248-264.
Theoretical I mprovements i n Algorithmic E~ c i enc y for Net work Fl ow Problems 249
1. The Max i m u m Fl ow Problem
1.1. THE LABELING METHOD. A network N is a f i ni t es et {u, v, - } cal l ed the nodes
and a s ubs et of t h e or de r e d pai r s (u, v), u # v, cal l ed the arcs. Ne t wo r k N has a
special return arc (t, s). No d e s is cal l ed t he source in N a nd node t is cal l ed t he
sink in N. Th e set of all ar cs of N, except (t, s), we de not e b y A. Fo r each (u, v) ~ A
there is gi ven a n u mb e r c(u, v) > 0 cal l ed t h e capacity of ar c (u, v).
A nonne ga t i ve f unc t i on f ( u , v), r a ngi ng ove r all ar cs (u, v) of N, is cal l ed a flow
in N if
(i) f or e ve r y (u, v) C A, f ( u , v) < c(u, v) ; a nd
(ii) f or e ve r y node u,
f ( u , v) - - ~ f ( v, u ) = O,
v v
where each s um is ove r e ve r y v f or whi ch t he s u mma n d is defi ned.
For each ar c (u, v) of N, f ( u , v) r epr esent s t he a mo u n t of fl ow i n ar c (u, v), a nd
also r epr es ent s t he net a mo u n t of fl ow f r om v t o u i n t he r est of t he ne t wor k
" N - ( u , v ) . "
The ma x i mu m ne t wor k fl ow pr obl e m is t o fi nd a flow f i n N such t h a t f ( t , s) , t he
net a mo u n t of fl ow i n N - (t, s) f r om s t o t, is ma x i mu m.
Let u~, u2, , u , be a s equence of di s t i nct nodes such t ha t , f or each i = l , 2,
. . , p - 1, ei t her (u~, u~+~) or (u~+~, u~) is a n arc. Si ngl i ng out , f or each i, one of
these possi bi l i t i es, we cal l t he r es ul t i ng s equence of ar cs a path f r o m Ul t o Up. Ar cs
(u~, u~+~) t h a t bel ong t o t he p a t h ar e cal l ed f orward ares of t he p a t h ; t he ot he r ar cs
of t he p a t h ar e cal l ed reverse arcs.
Rel at i ve t o a n y gi ven flow f i n N, a (fl ow) augme~ti~tg path is a p a t h f r om s t o t
such t h a t :
Case (a): I f ( u i , ui+l) C A and ( ui +i , ui ) ~ A, t he n
~i ~" C( Ui , Ui + i ) - - f ( u i , ui +l ) > 0;
Case (b): I f ( u i , ui+l) C A and (ui+l, u i ) C A, t he n
ei = f ( u i +l , ui ) > 0;
Case (c): I f (u,., ui +l ) ~ A a nd ( ui +l , u,.) C A, t he n
~i = e ( u i , n i T 1 ) - - f ( u i , Ui +1 ) - ~ f ( u i +, , u~) > O.
For a gi ven a u g me n t i n g p a t h P, l et e = r ai n e, > 0. Cal l each ar c ( ui , u~+~) or
(u~+~, u~) i n P s uch t h a t ei = e a bottleneck arc r el at i ve t o P a nd t he fl ow f .
No w al t er t he fl ow f as fol l ows I : i ncr ease f b y e on t he r e t u r n ar c (t, s) ; i n Cas e
( a) , i ncr ease t he fl ow on ar c ( ui , Ui+l) b y e; i n Case (b), decr eas e t he flow on ar c
(ui+~, u~) b y e; i n Case (c), i ncr ease t he flow on ar c ( u i , ui +i ) b y
mi n (e, c ( u i , ui +i ) - f ( u l , ui +l )) and decr ease t he flow on ar c ( ui +l , u i ) b y
max (0, e - c ( u i , u~+l) + f ( u i , ui +l )). I t is easi l y checked t ha t t h e f ~ t hus defi ned
is a flow i n N. Thus , si nce f~ (t, s) = f ( t , s) + e, t he flow f is not ma x i mu m. I t can
1 The method of augment at i on presented here differs [in Case (c)] from the met hod originally
given by Ford and Fulkerson (cf. [5]). The results of this paper apply, with minor changes, t o
the Ford-Fulkerson method as well.
J our na l of t he Associ at i on for Co mp u t i n g Macl ai nery, Vol. 19, No. 2, Apr i l 1972
2 5 0 J . E DMONDS AND R. M. KARP
be shown t hat , conversely, a flow f in N is not maxi mum onl y if t here is an
augment i ng pat h wi t h respect to f.
The labeling method const ruct s a sequence F = fo, fl , f2, . . . of flows in N, st ar t i ng
wi t h, say, t he zero flow, by finding an augment i ng pat h wi t h respect to f if one exists,
and t hen augment i ng to obt ai n fk+l. The sequence t er mi nat es onl y when a maxi mum
flow has been obt ai ned.
Assumi ng t hat all t he capacities c (u, v) are integers, t hen clearly for any aug-
ment i ng pat h P rel at i ve to any i nt eger-val ued flow f , e is a positive integer. Thus,
since f0 is i nt eger-val ued, all t he l at er flows fk in t he sequence F are integer-valued.
I t follows t ha t t he sequence t er mi nat es aft er a number of labelings not great er t han
t he final val ue of f (t, s).
The following example i l l ust rat es t ha t t hi s upper bound on t he number of label-
ings can act ual l y occur.
11
s t
V
Suppose t ha t t he arc (u, v) has capaci t y 1, and t he capaci t y of each of t he ot her arcs
in A is M, a positive integer. Then t he maxi mum val ue of f (t , s) is 2M, and 2M
labelings will be requi red if t he labeling process al t ernat es bet ween selecting
(s, u) ( u, v)(v, t) and (s, v)(v, u ) ( u , t) as an augment i ng pat h. For, in each case,
ei t her (u, v) or (v, u) is a bot t l eneck arc, and e = 1.
Assumi ng t ha t all t he capacities are mut ual l y commensurabl e, we can obt ai n an
equi val ent i nt eger-val ued probl em by mul t i pl yi ng all t he capacities by a large con-
st ant . Thus, in t hi s case also, t he sequence F is finite.
For d and Ful kerson show by an exampl e t ha t if t he capacities are not com-
mensurabl e t hen t he sequence F need not t er mi nat e, and in fact , may converge to a
nonmaxi mum flow.
Since numeri cal comput at i on is al ways, in practice, performed on number s ex-
pressed to a finite precision, t hi s nonfiniteness is not from a pract i cal vi ewpoi nt a
ver y serious mat t er . I t does serve as anot her i ndi cat i on of t he t endency of t he
number of augment at i ons to grow as t he precision to which t he capacities are ex-
pressed increases.
We will show t ha t these t heoret i cal difficulties, which could concei vabl y be a
pract i cal l y serious mat t er , can be avoided. I n part i cul ar, by maki ng a cert ai n re-
fi nement of t he labeling met hod which is so simple t hat i t is likely to be i ncorporat ed
Journal of t he Associ at i on for Computing Machinery, Vol. 19, No. 2, Apri l 1972
Theoretical hnprovements in, Algorithmic E~ c i enc y for Net work Fl ow Problems 251
innocently i nt o a c o mp u t e r i mpl e me nt a t i on, we get a b o u n d of at mo s t ~ ( Q - n )
terms in t he s equence F ( r egar dl ess of c o mme n s u r a b i l i t y ) , wher e n is t he n u mb e r of
nodes. I n addi t i on, a s econd r ef i nement of t he l abel i ng me t h o d is s hown t o yi el d a
bound on t he l engt h of F, appl i cabl e onl y i n t he case of i nt eger capaci t i es, of 1
10gM/(M--:) f *(t , S), wher e f *( t , s) is t he val ue of a ma x i mu m flow, a nd M < n2/2.
1.2. A REFINEMENT. Th e l abel i ng me t h o d r equi r es as a s ubr out i ne a labeling
process f or f i ndi ng, if one exi st s, a n a u g me n t i n g p a t h P r el at i ve t o a gi ven fl ow f i n
N. This is essent i al l y a me t h o d f or f i ndi ng, i n a c e r t a i n n e t wo r k N I h a v i n g t he s a me
nodes as N, a di r ect ed p a t h f r o m s t o t. A directed path f r o m s t o t is a p a t h s uch
that all arcs ar e f or wa r d arcs. Th e or de r e d pai r (u, v) is an ar c of N I if a nd onl y if
either
( u , v ) C A a nd c ( u , v ) - f ( u , v ) > 0
or
( v , u ) ~ A a nd f ( v , u ) > 0.
The arcs of a n y di r ect ed p a t h p I f r o m s t o t i n N i ar e i n one- one cor r es pondence wi t h
the arcs of an a u g me n t i n g p a t h P i n N r el at i ve t o f . Th e ar c of p I c or r e s pondi ng t o a
bottleneck ar c of P is al so r ef er r ed t o as a bot t l e ne c k arc.
The l abel i ng pr ocess f or f i ndi ng a di r ect ed p a t h i n N I f r om s t o t is as f ol l ows:
First s get s " l a be l e d. " Th e n a t each successi ve st ep of t he pr ocess some l abel ed b u t
"uns canned" node get s s canned. To scan a l abel ed node u me a ns t o l abel e ve r y node
v not al r eady l abel ed a nd such t h a t t he ar c (u, v) is i n N I. I f v get s l abel ed wh e n u is
scanned, t h e n u is t he predecessor of v i n t he l abel i ng.
As soon as t he si nk t get s l abel ed, t h e n t, t he pr edeces s or of t, t he pr edeces s or of
t hat pr edecessor , a nd so on ba c k t o s, is t he r ever se s equence of a di r ect ed p a t h i n
N I f r om s t o t. On t he ot he r ha nd, if e ve r y l abel ed node get s s c a nne d wi t h o u t t get -
ting l abel ed, t h e n t her e is e vi de nt l y no di r ect ed p a t h i n N I f r o m s t o t. Cl ear l y t he
labeling pr ocess t e r mi na t e s i n one or t he ot he r of t hese t wo si t uat i ons.
The r ef i nement t r e a t e d her e, whi ch gi ves a n u p p e r b o u n d of [ (n 3 - - n ) on t he
number of appl i cat i ons of t he l abel i ng pr ocess bef or e obt a i ni ng a ma x i mu m flow,
is t he f ol l owi ng: I n t he l abel i ng pr ocess, s can on a "f i r st - l abel ed f i r s t - s canned"
basis. T h a t is, bef or e s c a nni ng a l abel ed node u, s can t he nodes t h a t got l abel ed
before u.
I t can be s hown t h a t a di r ect ed p a t h i n N l f r o m s t o t, obt a i ne d b y t hi s ver s i on of
the l abel i ng pr ocess, is one whi ch c ont a i ns a mi n i mu m n u mb e r of arcs. Thus , t he
upper b o u n d can be s t a t e d as f ol l ows:
THEORE~I 1. I f , i n the labeling method f or f i ndi ng a max i mu m f l ow i n a network on
n nodes, each f l ow augmentation is done along an augmenting path having fewest arcs,
1 3
then a max i mu m f l ow will be obtained after no more than : (n - n) augmentations.
For pr es ent pur pos es , we will r egar d t he n u mb e r of ar cs i n a p a t h as i t s l engt h. Th e
" di s t ance" f r o m a node u t o a node v i n N I is t he mi n i mu m l engt h of a di r ect ed p a t h
from u t o v i n N I, or else ~ if t her e is no s uch pa t h.
Let F = fo, f l , f2, . . . be a n y s equence of flows i n N s uch t h a t fk+l is obt a i ne d f r om
by an a u g me n t a t i o n c or r e s pondi ng t o a s hor t es t di r ect ed p a t h pk i n N Ik. Le t N k
S k k k
denot e N , a nd l et 5 (u, v) de not e t he di s t ance f r om u t o v m N .
LEMMA 1. I f k < m and (u, v) is a bottleneck arc relative to pk and fk, and also rela-
tive to pm and f f , then, f or some 1 such that k < 1 < m, (v, u ) C pZ.
LEMMA 2. I l k < l, (u, v) ~ pk and (v, u ) C p t , then ~ ( s , t) > ~k(s, t) + 2.
Journal of t he Association for Comput i ng Machinery, Vol. 19, No. 2, April 1972
252 J . E DMONDS AND R. M. KAR P
Gi ve n t hes e l emmas , t he pr oof of Th e o r e m 1 is at hand. Le t {u, v} be a n y pai r of
nodes such t h a t (u, v) ~ A or (v, u ) ~ A. Le t t he s equence {ki} consi st of all i ndi ces
ki such t h a t ei t her (u, v) or (v, u ) is a bot t l e ne c k arc r el at i ve t o P ~ a n d f ~. By Le mma
1, one can f i nd a s equence {l~}, c ont a i ni ng {kl} as a s ubs equence, such t h a t
o r
(u, v) ~ P*~, j odd a nd (v, u ) ~ Pt~, j e ve n
(u, v) ~ P*~, j e ve n a nd (v, u ) ~ Pt~, j odd.
By Le mma 2, 6 zj +' (s, t ) > 6 Zj(s, t ) + 2, j = 1, 2, . Thus , ~t *j(s, t ) > 2 ( j - 1).
Bu t t he l engt h of a n y di r e c t e d p a t h i n N k is at mos t n - 1 so t h a t 6 *j (s, t ) < n - 1
f or all j . Th e l e ngt h of t he s equence {/j} is t he r e f or e at mos t (n - 1 ) + 1 =
(n -+ 1), a nd t hus t he n u mb e r of occur r ences of (u, v) or (v, u ) as a bot t l e ne c k arc
t h r o u g h o u t t he ent i r e l abel i ng me t h o d is at mos t (~ + 1). Th e n u mb e r of oc-
cur r ences of bot t l e ne c k ar cs a l t oge t he r is t he r e f or e bounde d by
n+2 l ( n 12 - n 3 - n 4
And, si nce e v e r y a u g me n t a t i o n de t e r mi ne s a bot t l e ne c k arc, t he n u mb e r of aug-
1 3
me nt a t i ons is also b o u n d e d b y z (n - n) .
Th e pr oof of L e mma 1 e mpl oys t wo si mpl e pr opos i t i ons .
PROPOSITION 1. I f (u, v) is a bottleneck arc relative to pk and f~, then (u, v) ~ N k+l.
PROOF. Th e a u g me n t a t i o n f r o mf k t o f k+l is such t ha t , if (u, v) C A t h e n f k+l (u, v)
= c (u, v), a nd if (v, u ) ~ A t h e n fk+l (y, U) = 0; hence, (u, v) ~ N *+1. II
PROPOSITmN2. I f (U,V) C N k+lthen ( u , v) ~ N kor ( v, u ) C pk.
PROOF. Suppos e (u, v) C N k+l and (u, v) ~ Nk; t hen, e i t he r fk+1(u, v) ~ f k( u, v)
orffl +~ (v, u) ~ fk (v, u) . I n e i t he r case, (u, v) or (v, u ) mus t be i n pk. Bu t (u, v) ~ pk,
si nce (u, v) ~ N*; t hus , (v, u ) ~ pk.
We can now pr ove Le mma 1. By Pr opos i t i on 1, (u, v) C Nk+I; si nce (u, v) ~ p,n,
( u , v ) C N m. Le t 1 + 1 = mi n { t I t > / ~and ( u , v) ~ N t } . T h e n ( u , v ) ~ N ~+~,
(u, v) ~ N~; hence, b y Pr opos i t i on 2, (v, u ) ~ P~. Thi s compl et es t he pr oof of Le mma
1. II
Th e pr oof of Le mma 2 will ma ke use of t he f ol l owi ng pr opos i t i on.
PROPOSITION" 3. For t~ = O, 1, 2, , and for all u,
~ ( s , u) < ~ +~ ( s, u) ( 1)
a nd
6~ ( u, t) < /t ~+~ ( u, t) . ( 2 )
PROOF. We pr ove ( 1) , t he pr oof of (2) bei ng si mi l ar. I f 6 k+~ (s, u) = ~ , t he re-
sul t is evi dent . As s umi ng 6k+~(s, u ) = h is fi ni t e, l et s = u0, u~, . . . , uh = u be
t he node s equence of a s hor t es t di r e c t e d p a t h f r om s t o u. Th e n 6 k (s, u0) = 0 and
we cl ai m t h a t
6k(s, ui+l) _~ 1 + 6k(s, ui ), i = 0 , - " , h - 1. (3)
For , si nce (ui , u~+~) ~ N ~+1, Pr opos i t i on 2 t el l s us t h a t ( u , , ui+~) ~ N ~ or (ui+~,
u~) ~ P~. I n t he f or me r case, fi~(s, u~+~) < 1 + 6~(s, ui ) , si nce t he ar c (ui , ui+~)
enabl es us t o get a di r e c t e d p a t h f r om s t o Ui+l i n N ~ ha vi ng no mor e t h a n 1 +
6~(s, u~) arcs. I n t he l a t t e r case, ~i~(s, ui) = 1 + 6~(s, ui+~), so fi~(s, u~+i) =
J our nal of t he Associ at i on for Co mp u t i n g Machi nery, Vol. 19, No. 2, Apr i l 1972
Theoretical I mprovements in, Algorithmic Ei~ciency f or Net work Fl ow Problems 253
- 1 + ~ ( s, ul ) < 1 -F 5k (s, ui ). Summi ng t he inequalities given in (3),
~ k( s, u) < h + g ( s , u0) = h = g+ 1 ( s , u) ,
and (1) is proved. II
To prove Lemma 2 not e t hat , since (u, v) ~ pk, ~k (s, t) = ~k (s, u) + 1 -b (3 k (v, t).
Also, ~k(s, v) = 1 + ~tk (s, u) and/tk (u, t) = 1 + ~k(v, t). Since (v, u) C pZ, ~tl(s, t) =
~Z(s, v) 1 + ~tZ(u, t). But , by Proposi t i on 3, St(s, v) _> ~*(s, v) and 5Z(u, t) _>
~k(u, t), so t hat ~l(s, t) > ~ik(s,v) -t- 1 -t- ~k( u, t ) = (1 + ~k( s , u) ) + 1 -I- (1 +
~k(v, t )) = 2 + ~t k (s, t). Thus, Lemma 2 is proved, and we are done. I I
The proof of Theor em 1 can be modified qui t e si mpl y to suppl y bounds on t he
numbers of augment at i ons required in cert ai n ot her refinements of t he Ford-
Fulkcrson labeling met hod. Let a (u, v) be a real-valued funct i on defined whenever
(u, v) C A or (v, u) C A, such t ha t b (u, v) = a( u , v) + a(v, u) > 0. Let t hewei ght
of a pat h P in N havi ng t he node sequence ul , u2, . . " , % be ~_--~ a( u i , Ui+l).
Consider a var i ant of t he labeling met hod in which each augment at i on is along a
flow-augmenting pat h of mi ni mum weight. Then t he number of augment at i ons can-
not exceed ( S ,'~(u.v)c a 1/[b (u, v )] ) -I- I A [, where S is t he maxi mum wei ght of a pat h
from source to sink. Theor em 1 corresponds to t he ease where a (u, v) = 1 for all
pairs (u, v). Anot her ease, corresponding to t he rule: "select a fl ow-augment i ng
path with as few reverse ares as possible," has a(u, v) = 1 if (v, u ) C A, and
1 3
a(u, v) = 0 otherwise. A bound on t he number of i t erat i ons in t hi s ease is ~ (n -- n2).
1.3. A SECOND REFINEMENT. I n t hi s section we consider t he following refine-
ment of t he labeling met hod: at each i t er at i on choose a f l ow- augment i ng pat h
which gives t he l argest possible augment at i on.
Let N be a net work in which every capaci t y is an integer. Let M > 1 be a positive
integer such t hat , for any par t i t i on of t he nodes of N i nt o two sets, X and X, wi t h
s C X and t { 2 , t he number of ares wi t h one end in X and t he ot her in 2 is less
than or equal to M. Let f* (t, s) denot e t he val ue of a maxi mum flow.
THEORmr 2. I f , i n the labeling method f or f i ndi ng a max i mu n f l ow i n N, a net-
work with all capacities integral, each augmentation is done along an augment i ng
path giving the max i mu m possible augmentation, then a max i mu m f l ow will be
obtained after no more than 1 -~- lOgM/(M--1) f * (t, S) augmentations.
Before provi ng Theor em 2, we show how t he rule under consi derat i on can be
implemented. Suppose we arc seeking a fl ow-augment i ng pat h in N rel at i ve to a
flow f. Associate wi t h each arc (u, v) C N f a number e (u, v) equal to t he val ue of e
that would resul t if (u, v) were a bot t l eneck arc in a fl ow-augment i ng pat h relative
to N and f. Specifically,
(i) if ( u, v) C A and ( v, u) ~, A, t hen e ( u , v ) = c ( u , v ) - f ( u , v ) ,
(it) if ( u, v) ~ A and ( v , u ) C A, t hen e ( u , v ) = f ( u , v ) ,
(iii) if ( u, v) C A and ( v, u) ~ A, t hen e ( u , v ) = e ( u , v ) - f ( u , v ) q-
/(v, u).
Then t he labeling met hod seeks a directed pat h from s to t in N z in which t he
mallest val ue of e (u, v) is as large as possible. Thi s is a bot t l eneck probl em of t he
ype st udi ed in [4]. One met hod of finding such a pat h is to label s, and t hen to repeat
he following step unt i l t is labeled: find an are (u' , v' ) ~ N I such t hat u' is labeled,
' is not labeled, and for any are (u, v) from a labeled node to an unl abel ed node,
(u', v' ) _> e (u, v ). Label v' and record u ' as t he predecessor of v'. When t is labeled,
J our nal of t he Associ at i on for Co mp u t i n g Machi nery, Vol. 19, No. 2, Apr i l 1972
254 J . EDMONDS AND R. M. KARP
t raci ng t he sequence of predecessors back from t gives a maxi mum-e flow-augmenting
pat h. If, at some step, t here is no arc from a labeled node to an unl abel ed one, t hen
no fl ow-augment i ng pat h exists.
PROOF OF THEOREM 2. Consider a par t i t i on of t he nodes of N i nt o t wo sets, X
and 2 , such t hat s E X and t E X. Define
c ( X , 2 ) = ~ c ( u , v ) , f ( X , X ) = ~ f ( u , v )
uE._" u Ex
vE X v E X
( u , v ) E A ( u , v ) E A
and
f ( X , X ) = ~ f ( u , v ) .
u E
v E X
( u , v ) E A
Then, for any flow f ,
c ( X , X ) > f ( X , X ) - - f ( X , X ) = f ( t , s).
Suppose t he labeling met hod using maxi mum augment at i ons produces t he sequence
of flows f0, fl , . . . , fk, . . . . Let e k = f + l (t, s) - fk (t, s). Consider t he augment at i on
f r omf f to f+~. Let t he set X consist of s t oget her wi t h all nodes which can be reached
from s by a di rect ed pat h in N k consisting of arcs (u, v) such t hat e(u, v) > k;
let X denot e t he remai ni ng nodes. Then t C 2 and every arc (u, v) in N k such t hat
u E Xa n d v E 2 s a t i s f i e s e ( u , v ) < e k.
c ( X , 2 ) - [ f*(X , 2 ) - - f ~ ( 2 , X)]
_< ~kl { ( u , v ) l u E X , v C 2 , ( u , v ) ~ A or ( v, u ) C A]} 1 _< ekM.
Now f* (t, s) < c (X, 2 ) and ~ (t, s) = fk (X, 2 ) - fk ( 2, X) , so
f *( t , s) - f k(t , S) < cAM; i.e. f*(t , s) - - f k(t , s) < [fk+'(t, s) -- f k(t , s)] M.
Equi val ent l y,
f *( t , s) -- f~+~(t, s) < [f*(t, s) -- fk(t, s)](1 - - / ~ - 1 ) .
Thus, by i nduct i on,
f *( t , s) -- f f ( t , s) < f *( t , s)(1 -- M- l ) k.
Now, since all t he capacities are integers, each flow is integral. Thus, if f is not a
maxi mum flow, t hen
f * ( t , s ) - f ( t , s ) >_ 1,
SO
and
f *( t , s) ( 1 -- M- l ) k >_ 1
k _~ --logl--1/Mf* (t, S) ---- IOgM/(M--1)f* (t, S ),
SO t he t ot al number of augment at i ons cannot exceed
1 -t- I OgM /(M --1)f (t, S).
1 2
Let 6 denot e t he average capaci t y of an arc in A. Then f* (t, s) < 6n 2 and M < ~n,
SO
iOgM/(M--1) f * ( t, S) < l ogl +2/(~2-2)(n26) = in n26
In (1 + 2 / ( n ~ - - 2))"
Journal of t he Association for Comput i ng Machinery, Vol. 19, No. 2, April 1972
Theoretical I mprovements i n Algorithmic E~ c i enc y for Net work Fl ow Problems 255
But
( 2 ) > i n ( i + 2 ) 2 1 ( 2 ) 2
In 1--~-n~---- ~ _ ~ >n--~-- ~ ~ .
Using these est i mat es we find t ha t t he number of augment at i ons cannot exceed
2 In n + In 5 n 4
1 -t- = 1 + - - ( 2 1 n n -k l n~)
2( 1/ n 2 - 1 / n 4) 2n 2 - 2
= n 2 1 n n + n 2 1 n S - t - O ( n 21nn+n 2 1 n o ) .
Thus, al t hough t he present bound depends on t he capacities and requires t hei r
integrality, i t is superior to t he bound of Section 1.2 in appr oxi mat el y t he range
0 < g < e ~ / 4.
2. The Mi ni mu m- Cost Flow Problem
2.1. A LABELING METHOD. I n t hi s sect i on we t ur n t o t he probl em of finding a
maximum flow of mi ni mum cost. Gi ven a net wor k N, associate wi t h each arc
(u, v) E A a nonnegat i ve cost d(u, v) as well as t he usual positive capaci t y c(u, v).
Let the cost of a flow f be ~( ~, , ) e ~ d(u, v)f (u, v) and let its value be f (t , s). We seek
flow of mi ni mum cost among t hose wi t h val ue f *(t , s).
Call a flow f extreme if i t is of mi ni mum cost among flows wi t h value f ( t , s). We
mention some well-known charact eri zat i ons of ext reme flows. I n doing so, we make
use of t he net work N s associated wi t h f. We recall t ha t a net work, by definition, has
at most one are from one given node to anot her. For convenience we also assume t hat
(u, v) C A ~ (v, u) ~ A. Obvious devices using "fi ct i t i ous nodes" can be used to
enforce t hi s rest ri ct i on if i t does not originally hold. Associate wi t h any arc (u, v)
of N s a weight ~ (u, v) as follows:
~d( u , v), (u, v) C A,
A( u , v) = ~ - d ( v , u ) , (v, u ) E A.
Define t he wei ght of a subgraph of N s as t he sum of t he wei ght s of its arcs. Define a
labeling f unc t i on as a f unct i on from t he nodes to t he real numbers.
THEORE~I 3. 2 Let f be a flow. Then the following are equivalent:
(i) f is extreme,
(ii) every directed cycle in N s has nonnegat i ve weight,
(iii) t here exists a labeling f unct i on 7r such t hat , for every arc (u, v) of N s,
~ ( u) + ~ ( u, v) - ~ r( v) _> 0.
A r est at ement of (iii) in t erms of t he net work N is: for (u, v) ~ A,
~r(u) - - 7r(v) + d( u , v) > 0 ~ f ( u , v) = O,
(4)
7r(u) -- z ' ( v) + d( u , v) < 0 ~ f ( u , v) = c(u, v).
If t he flow f and t he labeling funct i on 7r t oget her sat i sfy (4), t hen f and 7r are
called compatible.
Anot her basic resul t is t he following.
2 The e q u i v a l e n c e of (i) and (iii), s t a t e d i n a s o me wh a t di f f e r e nt f o r m, can be f o u n d i n [5,
pp. 114-115].
Journal of the Association for Computing Machinery, Vol. 19, No. 2, April 1972
2 5 6 J. EDMONDS AND R. M. KARP
THEORE:U 4. ([5, p. 121]). I f f i8 extreme and P is a p at h of m i n i m u m weight i n
N s f rom 8 to t, then a f l ow f ' obtained by au g ment i ng along P is extreme.
For br e vi t y call a pa t h of mi ni mum wei ght a " s hor t es t p a t h . " The or e m 4 sug-
gest s t he following met hod of sol vi ng t he mi ni mum- cos t flow pr obl em: s t ar t i ng wi t h
an ext r eme flow f0, comput e a sequence of ext r eme flows J~, f l , . . . , fk, fk+l, . . .
obt ai ni ng fk+l f r om fk by augment i ng al ong a shor t est pa t h f r om 8 t o t in N sk. A
shor t est pa t h can be det er mi ned usi ng t he following al gor i t hm.
ALGORITHM A : S h o r t e s t - P a t h Al g o r i t h m
Let N fk ha ve t he s et of ar cs A k, and l et A( u, v) be t h e we i g h t of ar c (u, v) C A k.
(1) Set a ( s ) = 0 a nd s et ~( u) = - k- ~, u ~ s.
(2) Set S = {s}.
(3) I f S = 4~, h a l t ; o t h e r wi s e choos e u* s u c h t h a t u* E S a nd or(u*) = mi n u Es , r ( u) -
(4) F o r e a c h v s u c h t h a t (u*, v) C A k, s e t
,r(v) = r ai n (a(v), a ( u * ) A- A( u*, v)).
If this process decreases a(v), adjoin v to the set S.
(5) Delete u* from S and go to (3).
Al gor i t hm A has t he following pr oper t i es:
(1) Upon i t s t er mi nat i on, a ( u ) gi ves t he wei ght of a s hor t es t pa t h f r om s t o u;
(2) I f A (u, v) >_ 0 for ever y arc (u, v), t hen each ver t ex accessible f r om s ent ers
t he set S exact l y once, so t ha t t he t ot al a mount of c omput a t i on is pr opor t i onal t o
t he numbe r of ares;
(3) I f no cycl e is of negat i ve wei ght , t hen each ver t ex accessi bl e f r om 8 ent er s t he
set S at most n - 1 t i mes, so t ha t t he t ot al a mount of c omput a t i on has a bound
pr opor t i onal t o n - 1 t i mes t he numbe r of ares;
(4) I f t her e is a negat i ve- wei ght cycl e accessible f r om 8, t hen t he al gor i t hm is
nont er mi nat i ng. One wa y t o det ect t hi s is t o keep a s ubgr aph T of t ent at i ve s hor t es t
pat hs. T cont ai ns arc (u, v) if v l ast ent er ed S dur i ng an appl i cat i on of St ep (4) wi t h
$
u = u. Any cycle in T has negat i ve wei ght ; if a negat i ve- wei ght cycle is accessi bl e
f r om 8, t hen such a cycl e will occur in T by t he t i me an5' ver t ex ent er s S for t he nt h
t i me.
The di scussi on of t he s hor t es t - pat h al gor i t hm shows t he efficiency t o be gai ned
in eases when all wei ght s are nonnegat i ve. Too l i t t l e at t ent i on has been pai d t o t hi s
essent i al poi nt in t he devel opment of al gor i t hms for mi ni mum- cos t flows. We
pr esent in t hi s sect i on an al gor i t hm desi gned so t ha t all s hor t es t - pat h cal cul at i ons are
done on net wor ks wi t h all wei ght s nonnegat i ve.
Let f be a flow and l et ~- be a l abel i ng funct i on. Assign each arc (u, v) of N ] a
wei ght X( u , v ) = ~r(u) -4- A( u , v ) -- 7r(v).
The n cl ear l y
(i) if C is a di r ect ed cycle, t hen
5( u, ~ ) = ~ a( u,~ );
( u , v ) ~ C ( u , v ) CC
(ii) if P is a di r ect ed p a t h f r o m u * t o v*, t hen
~( u, ~) = ~-(u*) - ~-(~*) + ~ ~( u, ~).
( u , v ) ~ P ( u , v ) EP
Thus, N s has a cycle of negat i ve wei ght wi t h respect t o t he wei ght s A (u, v) if
Journal of the Association for Computing Machinery, Vol. 19, No. 2, April 1972
Theoretical I mprovements i n Algorithmic Efficiency for Network Flow Problems 257
and onl y if N I has a cycle of negat i ve wei ght wi t h r espect t o t he wei ght s A (u, v).
Also, P is a shor t est pa t h f r om s t o t wi t h r espect t o t he wei ght s A (u, v) if and onl y
if P is a shor t est pa t h f r om s t o t wi t h r espect t o t he wei ght s A (u, v). Consi der t he
implications of t hese f act s when f and ~r are compat i bl e. The n A (u, v) > 0, and a
mi ni mum- wei ght f l ow- augment i ng p a t h ( r el at i ve t o t he wei ght s A(u, v) ) can be
found by a s hor t es t - pat h cal cul at i on usi ng t he nonnegat i ve wei ght s A(u, v).
A var i ant of t he al gor i t hm suggest ed by The or e m 4 is now a ppa r e nt whi ch per -
forms all s hor t es t - pat h cal cul at i ons on net wor ks wi t h all wei ght s nonnegat i ve.
ALGORITHM B: Minimum-Cost Flow Algorithm
(1) Set f0 equal to the zero flow, and set 7r equal to the identically zero labeling function;
(2) Given fk and 7r k, determine fk+l by augmenting along a minimum-weight pat h from s to t
in N/k with respect to the (nonnegative) weights
ak(u, v) = ~-k(u) + ,~(u, v) - ~-k(v).
I f s ever al mi n i mu m- we i g h t p a t h s e xi s t , c hoos e one wi t h t he f e we s t ar cs .
(3) I f ak( u) d e n o t e s t h e we i g h t of a s h o r t e s t p a t h f r o m s t o u wi t h r e s pe c t t o t he we i g h t s
A k, s et lr~+l(u) = ~k(u) + aS( u) ; t a k e k(u) = 7rk+l(u) = - ] - ~ if u is i na c c e s s i bl e f r o m s i n
N/k .
(4) Halt when, for some k, no flow-augmenting path exists with respect to f k
Some pr oper t i es of t he al gor i t hm are gi ven in t he fol l owi ng t heor em.
THEORE~ 5. For each k, fk and 7rE are compatible. For eaeh k and u, 7r k (u ) gives
the weight of a shortest path from s to u i n N Ik with respect to the weights A (u, v) and
~'~ ' (u ) _> ~'~ (u ).
We pr esent t wo bounds on t he numbe r of flow augment at i ons r equi r ed by t he
mi ni mum- cost flow al gor i t hm.
THEOREM 6. / f all the capacities are integers, then the computation terminates after
at most f * (t, s) flow augmentations.
PROOF. Each flow fk is i nt egral , and each a ugme nt a t i on i ncreases t he flow by a
posi t i ve i nt eger. [r
THEORE~r 7. Suppose the costs d (u, v) are integers less than or equal to an integer D.
Then the computation terminates after at most 1 + ~ (n 3 - n ) (n - 1 )D flow augmenta-
tions.
PROOF. We show t ha t t he overal l c omput a t i on can be r egar ded as a sequence of
at mos t (n - 1) D + 1 phases, each consi st i ng of a ma x i mu m flow comput at i on.
Each phase cor r esponds t o a peri od dur i ng whi ch 7r k (t) r emai ns const ant . Suppose
7r k (t) is cons t ant for k~ < k < k2. The n t he flow augment at i ons i nvol ved in passi ng
f r om fk~ t o fk: ar e al ong di r ect ed pat hs in t he s ubnet wor k N' cont ai ni ng t hose arcs
(u, v) i n N Ik' such t ha t ~r k~ (u) + A(u, v) -- 7r ~ (v) = 0. Hence, t hese augment at i ons
Ltre par t of a maxi mum- f l ow c omput a t i on in N' . The bound of Sect i on 1.2 is appl i -
cable, since t he al gor i t hm selects, at each st ep, a pa t h wi t h fewest arcs among t hose
of mi ni mum wei ght . Hence, t he numbe r of augment at i ons per phase is at mos t
(n 3 - n) . Now, except at t he l ast st ep, when t is inaccessible by a f l ow- augment i ng
9at h and ~rk~) = oc, 7r k (t) is t he wei ght of some pa t h in N f r om s t o t, and hence is
~n i nt eger bet ween 0 and (n - 1 )D. Thus, not i ng t ha t 7r k (t) is nondecr easi ng wi t h
~, we see t ha t t he numbe r of phases, excl udi ng t he l ast st ep, is at mos t (n - - 1) D,
md t he t heor em follows. [I
COROLLARY 1. Algorithm B solves any minimum- cost flow problem i n a finite nTm-
)er of steps (even when neither the capacities nor the costs are commensurable).
Journal of the Association for Computing Machinery, Vol. 19. No. 2, April 1972
2 5 8 J. EDMONDS AND R. M. KARP
PROOF. The first hal f of t he pr oof of The or e m 7 is appl i cabl e in t hi s case, and
shows t ha t t her e is a finite bound on t he number of successive flow augment at i ons
wi t hout an i ncrease i n ~r k (t). But , for a ny k, ~.k (t) is t he wei ght of some di rect ed
pa t h f r om s t o t in N f~, cor r espondi ng t o some pa t h wi t hout r epeat ed ver t i ces i n N.
Since t he number of such pat hs is finite ~-~ (t) increases onl y a finite numbe r of times,
so t ha t t he ent i r e process must be finite. I]
Al t hough i t is comf or t i ng t o know t ha t t he mi ni mum- cost flow al gor i t hm t er-
mi nat es, t he bounds on t he numbe r of augment at i ons are most unf avor abl e. The
scaling met hod of t he next t wo sections is a var i ant of t hi s al gor i t hm in whi ch t he
bound depends l ogari t hmi cal l y, r at her t ha n l i nearl y, on t he capacities. A challeng-
ing open pr obl em is t o emul at e t he resul t s of Sect i on 1.2 for t he maxi mum-fl ow prob-
l em b y gi vi ng a met hod for t he mi ni mum- cost flow pr obl em havi ng a bound on
comput at i on whi ch is a pol ynomi al in t he number of nodes, and is i ndependent of
bot h costs and capacities.
2.2. A SCALING METHOD FOR THE HITCHCOCK TRANSPORTATION PROBLEM. I n
t hi s sect i on and t he following one, we pr esent a t echni que for sol vi ng a mi ni mum-
cost flow pr obl em by t r eat i ng a sequence of pr obl ems wi t h t he same cost as t he
gi ven pr obl em, but wi t h "scal ed down" capaci t i es whi ch appr oxi mat e t hose of t he
gi ven pr obl em t o successi vel y mor e digits of precision. The efficiency of t hi s scaling
me t hod is based on t he following t wo f eat ur es :
(1) t he capacities, and hence t he flow augment at i ons, in t he appr oxi mat e prob-
l ems are on a coarser scale t ha n in t he original pr obl em;
(2) t he final sol ut i on of each appr oxi mat e pr obl em yields a good initial flow for
t he next appr oxi mat e probl em.
We pr ove t ha t t he number of comput at i on st eps r equi r ed by t he scaling met hod
is pr opor t i onal not t o t he capaci t i es (as in t he met hod of Sect i on 2. 1) but t o t he
number s of digits i n t he bi nar y r epr esent at i ons of t he capacities. Roughl y speaki ng,
t he scaling met hod is r el at ed t o t he original met hod as bi nar y ar i t hmet i c is t o
una r y ar i t hmet i c (i.e. count i ng) .
Fi r st we consi der a special case i n whi ch t he scaling t echni que is par t i cul ar l y
simple. The Hitchcock transportation problem asks for a maxi mum flow of mi ni mum
cost t hr ough a net wor k of t he t ype shown i n Fi gure 1.
The cost s and capaci t i es are as follows:
arc (s, si) has cost 0 and capaci t y a l , i = 1, 2, , m;
arc (t~., t ) has cost 0 and capaci t y bj , j = 1, 2, . . . , n;
arc (sl , tj ) has cost d~j and capaci t y % oo, i = 1, 2, . . , m, j = 1, 2, , n;
t he r e t ur n arc (t, s) has cost 0 and capaci t y + ~o.
I t is assumed t ha t ~i ' 21 al = ~ - 1 bj . The val ue of a maxi mum flow is cl earl y
The s t andar d i nt er pr et at i on of t hi s pr obl em is well known. Each ver t ex s~ cor-
r esponds t o a " s our ce" at whi ch ai uni t s of a commodi t y are avai l abl e; each ver t ex
t~. corresponds t o a "des f f nat i on" whi ch demands b~. uni t s of t he commodi t y. The
cost per uni t of shi ppi ng f r om s~ t o tj is dl j , and a shi ppi ng pa t t e r n is sought whi ch
mi ni mi zes t he cost of meet i ng t he demands at t he dest i nat i ons f r om t he supplies
at t he sources.
I n t he following speci al i zat i on of t he cr i t er i a for an ext r eme flow gi ven i n eq.
(4), ui denot es 7r(s~) and vj denot es l r ( t j ) ; also, f i i denot es f(s~, tj ) when i >_ 1
a n d j > 1; foi denot es f (s, si) and fio denot es f ( t j , t ).
J o u r n a l o f t h e A s s o c i a t i o n for C o m p u t i n g M a c h i n e r y , V o l . 19, N o . 2, A p r i l 1972
T heor et i c al I m p r o v e m e n t s i n A l g o r i t h m i c E g i c i e nc y f o r N e t wo r k F l o w P r o b l e m s
_ _ . _ _ _ _ _ . . o ~ , . . . . . ~ t
259
F I G, 1
T HE ORE M N.
1, i f a ~ d o n l y i f t here e x i s t uo , u l , . , Um a n d vo , vl , , v~ s u c h t hat
u ~- - wj -t -d~j _> 0, i = ~, 2, . . - , m; j = 1, 2, . . - , n , (5a)
ui -- v; -~- di; > 0 ~ L j = 0, i = 1, 2, . . . , m; j = 1, 2, . . . ,~t, (5b)
Uo > u i ~ f oi = 0, (5c)
Uo < u i ~ f 0 i = a , , (Sd)
vi > Vo ~ f ~ o = O, (5e)
vj < Vo ~ j ~ o = b; (5f)
T h e f l o w f i s e x t r e m e a m o n g m a x i m u m f l o ws f o r t he n e t wo r k o f F i g u r e
Call a flow f for t he Hi t chcock pr obl em p s e u d o - e x t r e m e if t her e exist ui and v;
satisfying (5a) and (5b). A pseudo- ext r eme maxi mum flow is ext r eme; for a maxi -
mum flow has f0i = a i , i = 1, 2, . . . , m andf j 0 = b i , j = 1, . . . , n. Thus, if (5a)
and (5b) are satisfied, we ma y sat i sfy ( 5c ) - ( 5f ) by set t i ng Uo = mini=l.2.., mU~
and w0 = maxj=l.2....,,, v; . For a pr obl em of t he Hi t chcock t ype wi t h ~ a~ ~ ~ bj ,
a pseudo- ext r eme maxi mum flow is not , in general , ext r eme.
Al gor i t hm B can, of course, be used t o solve t he Hi t chcock probl em. An al t er nat e
met hod is based on t he fact t ha t a maxi mum pseudo- ext r eme flow is ext r eme. A
sequence of pai rs (f0, ~.0), (fl, ~.1), " " , (fk, ~.k) is comput ed where, for each k,
(fk. ~_k) satisfies (Sa) and (Sb), so t ha t fk is pseudo- ext r eme. The det er mi nat i on
of (fk+l, ~_k+l) f r om (fk, ~.k) differs f r om t he correspondi ng st e~ in t he pr evi ous
al gori t hm in onl y one r espect : if f~i < ai t hen arc (s, s~) in N j is assigned cost
(s, s~) = 0, regardl ess of ~.k si mi l arl y ~ (t j , t ) = 0 i ffj 0 < b; . I t is easily checked
t hat , if (fk, ~.k) satisfies (5a) and (Sb), t hen so does (f~+~, ~_k+~) ; t hus, fk+~ is pseudo-
ext reme if fk is. I f t he capaci t i es a~ and bj are i nt egers t hen an upper bound on t he
number of flow augment at i ons is ~ l a ~ .
Now we are pr epar ed t o pr esent t he scaling met hod. For any nonnegat i ve i nt eger
p, define Pr obl em p t o have t he same nodes, arcs, and costs as t he gi ven probl em,
but wi t h t he capaci t i es changed as follows: t he capaci t y of (s, s~) is [ai / 2 p] and t he
capaci t y of (re, t ) is [bff2v]. 3 Thus, t he original pr obl em is Pr obl em 0 and, in general ,
the capaci t i es in Pr obl em p are obt ai ned by del et i ng t he p l ow-order digits in t he
bi nary r epr esent at i ons of t he ori gi nal capacities.
3 , , [x]" me a n s " g r e a t e s t i n t e g e r l e s s t h a n o r e q u a l t o x . "
J our nal of t he Associ at i on for Comput i ng Machi nery, Vol. 19, No. 2, Apri l 1972
2 6 0 J . E DMONDS AND R. M. KAR P
LEMMA 3. I f f is a pseudo- extreme f l ow i n Probl em p, then 2 f is a pseudo- extreme
f l ow i n Probl em p - 1.
Choose 1 such t ha t ever y finite capaci t y has at most 1 digits in its bi nar y expan-
sion; i. e. a~ < 2 *, i = 1, 2, - . - , m, a n d b i < 2 t, j = 1 , 2 , . . . , n . T h e n t he scaling
met hod comput es maxi mum pseudo- ext r eme flows successively for Pr obl ems l -- 1,
1 - 2, , 0. I f f is t he maxi mum pseudo- ext r eme flow comput ed in Pr obl em p,
and 7r is t he associ at ed labeling funct i on, t hen 2 f is t aken as t he initial pseudo-
ext r eme flow in Pr obl em p - l , wi t h rr as its associ at ed labeling funct i on.
The following t heor em bounds t he number of flow augment at i ons in t he sol ut i on
of a t r ans por t at i on pr obl em by t he scaling met hod.
THEOREM 9. The nu mb er of f l ow au g ment at i ons i n ap p l yi ~ g the scaling method to
a t ransport at i on problem wi t h integral " s u p p l i es " a~, a~, . . . , am and integral " de-
mands " bl , b2, , bn i s less t han or equal to
(I
= a i
max (m, n) 2 + logs , na~' ~. 7, n) "
PROOF. Let fv* denot e t he val ue of a maxi mum flow in Pr obl em p. The initial
flow in Pr obl em 1 - 1 is 0 and, for p < 1, t he initial flow in Pr obl em p - 1 is 2fp*.
Recal l i ng t ha t each augment at i on gives a posi t i ve i nt egral i ncrease in t he flow, t he
t ot al number of augment at i ons is bounded above by
l--1 l--1
ft*-i q- ~_, (f*-~ - - '2fp*) = fo* -- E f p * " (6)
p = l p = l
Now
fv" = mi n ( ~ I a ~ 1 ~ I b 3 1 )
,:=, ~7 ' ,_57 >_o.
j = l
We can wri t e ai = 2 p [ ai / 2 ~] + ri~,, where 0 _< rip < 2 p - 1. Hence,
~ a i - ~ r i p ~ a l
~ [ a ~ ] i=l i=1 > i = 1
i=x 2P - - '2P
Si mi l arl y,
i = l
~ b j
j = l
2v
Let B denot e t he common val ue of
[log2 ( B/ ma x (m, n) ) ] . The n
, > ( B
f p / - max 0, 2--7
and
n .
~ i ~ , ai and Ejn=l bj , and let L denot e
- ma x (m, n ) )
) fp* >_ -- max (m, n) .
p = l p = l
J our na l of t i l e Associ at i on f or Co mp u t i n g Machi ner y, Vol. 19, No. 2, Apr i l 1972
Theoretical I mprovement s i n Algorithmic Efficiency for Net work Fl ow Problems 261
Applying t hi s i nequal i t y to (6), and not i ng t hat fo* = B, we find t hat an upper
bound on t he t ot al number of flow augment at i ons is
B/ 2 L + L m a x (re, n) _< (L + 2) max (re, n) .
This completes t he proof, ll
We remark t hat t hi s bound on t he number of flow augment at i ons is approxi-
mately equal to t he number of bi nar y digits requi red to encode t he dat a of t he
t ransport at i on problem. Each augment at i on requires O( m, n) comput at i on steps,
so t hat t he number of comput at i on steps in t he entire process is bounded by a low-
degree pol ynomi al in t he size of t he problem, as measured by t he l engt h of t he i nput
text. I n t hi s sense t he scaling met hod is a " good" al gori t hm. 4
2.3. A SCALING METHOD FOR THE ~' ~I NI MUM- Cos T FLOW PROBLEM. R e f e r e n c e s
[6] and [7] give a simple met hod of convert i ng any mi ni mum- cost flow probl em havi ng
I A I arcs and n nodes i nt o an "equi val ent " Hi t chcock t r anspor t at i on probl em wi t h
I A [ sources, n dest i nat i ons, and a maxi mum flow of ~( ~. , ) c i C (U, V). By Theor em 9,
the appl i cat i on of t he scaling met hod to such a deri ved t r anspor t at i on pr obl em
requires at most
(L + 2)[ A I
flow augment at i ons where L = log2 (~(u. ~. )c(u, v)/[ A I). Thus, t he approach of
converting to an equi val ent t r anspor t at i on probl em which is solved by t he scaling
method yields a good al gori t hm for t he mi ni mum-cost flow problem.
In t hi s section, we consider t he di rect appl i cat i on of t he scaling met hod to t he
minimum-cost flow problem. The general approach is clear. Gi ven a mi ni mum-
cost flow Pr obl em on a net work N wi t h costs d (u, v) and capacities c (u, v), define
Problem p as a probl em i dent i cal wi t h t he given one except t hat t he capaci t y of arc
(u, v) is given by [e(u, v)/2v] . Choose 1 as t he least i nt eger such t hat 2 l > e(u, v)
for all (u, v) C A. Then t he pl an is to solve Probl ems 1 - 1, 1 - 2, . . . , 0 succes-
sively using Al gor i t hm B, t aki ng twice t he final flow in Probl em p as t he initial
flow in Probl em p - 1. There is a maj or difficulty, however. If.fp* is a mi ni mum-cost
maxi mum flow in Pr obl em p, t hen 2fv* is a flow in Pr obl em p - l , but not , in general,
an extreme flow. I n t he case of t he t r anspor t at i on probl em t hi s difficulty was not
serious, since it was possible to work wi t h pseudo-ext reme flows i nst ead of ext reme
flows. For general mi ni mum-cost flow probl ems t he r emedy for t hi s difficulty is
somewhat more complex.
We begin by showing t hat if f is ext reme in Probl em p, t hen 2 f i s "al most ext r eme"
in Probl em p - 1. Since f is ext reme in Pr obl em p, t here is a labeling funct i on 7r
such t hat
~- (u) + d( u , v) - ~- (v) > 0 ~ f ( u , v) = 0, (u, v) C A,
~' (u) + d(u, v) - ~' (v) < 0 ~ f ( u , v) = [c(u, v)/2P], (u, v) C A.
Using t he inequalities
Fe(u, ) 1 Fe( ,v)l
2 L - ~ - - J -< L ~ T - ' - J -< 2 L 2 G- - J + 1,
4 The c onc e pt of a " g o o d a l g o r i t h m" is di s c us s e d i n de t a i l i n [2].
Journal of the Association for Computing Machinery, Vol. 19, No. 2, April 1972
262 z. EDMONDS AND R. M. KARP
we h a v e
~r(u) + d(u, v) - - ~' (v) > 0 ~ 2 f ( u , v) = O, ( 7)
7r(u) + d( u , v) -- ~r(v) < 0 ~ 2 f ( u , v) < [c(u, v ) / 2 p- ' ] < 2 f ( u , v) + 1.
Bu t c o mp a t i b i l i t y of f a nd ~r i n P r o b l e m p - 1 r equi r es
~r(u) + d(u, v) - ~r(v) < 0 ~ 2 f ( u , v) = [c(u, v)/ 2P-1].
Thus , 2f a nd ~r fai l t o be c o mp a t i b l e i n P r o b l e m p - 1 b y a t mo s t one uni t of fl ow
on a n y ar c. We gi ve a n ef f i ci ent me t h o d of t r a n s f o r mi n g 2f t o a fl ow whi ch ha s t he
s a me va l ue a nd is e x t r e me i n P r o b l e m p - - 1. Th e me t h o d c a n be r e ga r de d as a
v a r i a n t of t he Fu l k e r s o n out - of - ki l t e r a l g o r i t h m [5] i n whi ch t he " f l ow c h a n g e "
a nd " p o t e n t i a l c h a n g e " pha s e s ar e c o mb i n e d i nt o a si ngl e c o mp u t a t i o n .
We s t a t e t he me t h o d as i t a ppl i e s t o a n a r b i t r a r y i nt e gr a l f eas i bl e fl ow g i n Pr o b -
l e m p - - 1, a nd a n a r b i t r a r y l abel i ng f unc t i on 0. Dcf i ne el(u, v) = O( u ) +
d( u , v) - - 0 (v). Def i ne Kg.o (u, v), t he kilter number of ~rc (u, v) r e l a t i ve t o g a nd 0, as
g(u, v), i f d( u, v) > 0,
0, if d ( u , v ) = 0,
I
c (u, ~)~
- ~ - j - g(u, v), if d ( u, v) < 0.
Th u s , g a nd 0 ar e c o mp a t i b l e i f a n d onl y if each ar c ha s ki l t e r n u mb e r zero. Al so,
r e l a t i ve t o 2f a nd 0, t he ki l t er n u mb e r of each ar c is 0 or 1.
Th e f ol l owi ng a l g o r i t h m der i ves , f r o m a n i n c o mp a t i b l e pa i r (g, 0) , a new pa i r
(gt, 0' ), i n s uch a wa y t h a t
(i ) Kg,,o,(U, v) < Ko,o(U, v), (u, v) E A,
a n d
(ii) ~_,(u,~)caKo,,o,(U, v) < ~_,(u,v)caK~,o(u, v) - 1.
ALGORITHM C: Ki l t e r Nu mb e r Re d u c t i o n
(1) F o r m t h e a u g me n t a t i o n n e t wo r k N , h a v i n g A rJ as i t s s e t of ar cs . F o r e a c h ar c (u, v) E A g'
def i ne
~ ( u , v), i f (u, v) E A a n d g(u, v) < [c(u, v) / 2p- l l ,
7~(u, v) = [ - d ( u , v ) , i f ( v , u ) E A a n d g ( v, u ) > O.
La b e l e a c h ar e (u, v) E A g wi t h t h e we i g h t
B(u, v) = ma x ( ~( u, v), 0).
(2) Ch o o s e an ar c ( u* , v*) of N g s u c h t h a t
(a) (u*, v*) E A, a ( u, v) < 0 a n d g( u, v) < [~(u, v)/ 2P-l ],
or
( b) ( v * , u * ) E A, ~ ( u , v ) > 0 a n d g(u, v) > O.
(3) Le t N* = {x [ x = v* or N* ha s a d i r e c t e d p a t h f r o m v* t o x}. F o r x E N* , s e t 6(x) e qua l
t o t h e mi n i mu m we i g h t of a d i r e c t e d p a t h f r o m v* t o x. F o r x (~ N* s et
~(x) = max [0(u) - ~(v, u)].
{(v,u)EAOIv~:N*, uEN*}
Journal of the Association for Computing Machinery, Vol. 19, No. 2, April 1972
Theoretical I mprovement s i n Al gori t hmi c E~ c i enc y f or Net work Fl ow Problems 263
(4)
For each node z, let O' (x) = O(x) + 8(x).
If u* ~ N*, t hen q' = g.
If u* C N*, choose a cycle C of N g consisting of (u*, v*) t oget her wi t h a mi ni mum-wei ght
pat h from v* to u*. Obt ai n g' from g by performi ng a flow augment at i on around the cycle
C.
We ma k e t he f ol l owi ng a s s e r t i ons ( o mi t t i n g p r o o f s ) :
(i) Fo r e a c h ar c (u, v) , Kg, , v (u, v) < Kg,0 (u, v) ;
(ii) i f (u*, v* ) C A,
Ko, , v( u *, v*) _< Ko,e(u*, v*) - 1;
(iii) i f (v*, u * ) C A,
Ko,.o' (v*, u *) < Ko,e(v*, u *) - 1.
By i t e r a t i on of Al g o r i t h m C, t he p a i r (2f, ~-) c a n be c o n v e r t e d t o a n e x t r e me fl ow
for P r o b l e m p - 1 h a v i n g t he s a me va l ue as 2f. Si nce each i t e r a t i on r e duc e s t he
s um of t he ki l t e r n u mb e r s b y a n i nt eger , t he n u mb e r of i t e r a t i ons wi l l n o t exceed
~( ~, , ) e a Ki n , ( ( u, v ) ) . Bu t , si nce K2i . , (u, v) C {0, 1}, t he n u mb e r of i t e r a t i ons is
bounde d b y ] A [.
We ar e now i n a pos i t i on t o gi ve a c o mp l e t e s t a t e me n t of t he s cal i ng a l gor i t hm.
ALGORZTHM n: Sc a l i ng Al g o r i t h m f or Mi n i mu m- Co s t Fl o ws
(1) Set f = 0 and ~- = 0. Choose ! such t hat , for all (u, v) E A, c(u, v) < 2 Z. Set p = 1 - 1.
(2) Solve Pr obl em p by the al gori t hm of Section 2.1, using f as the initial flow and ~r as the
initial labeling function. Aft er this s t e p ] is a maxi mum flow of mi ni mum cost in Pr obl em
p, and ~r is compat i bl e wi t h f in Pr obl em p.
(3) I f p = 0, hal t . Otherwise replace p by p - 1 and replace f by 2f.
(4) Appl y Al gori t hm C repeat edl y, st ar t i ng wi t h the pai r (f, ~r), until a compat i bl e pai r (g, 8)
is obt ai ned. Set f = g and ~- = 0. Go t o 2.
Th e n u mb e r of s t e ps r e qui r e d i n a p p l y i n g t hi s a l g o r i t h m c a n easi l y be b o u n d e d .
Th e n u mb e r of e xe c ut i ons of Al g o r i t h m C i n St e p ( 4) i s a t mo s t ] A l ( l - 1).
T h e n u mb e r of fl ow a u g me n t a t i o n s ( e a c h r e qui r i ng a n a ppl i c a t i on of Al g o r i t h m
A t o a n e t wo r k wi t h n o n n e g a t i v e we i g h t s ) i s b o u n d e d a b o v e b y
1--1 l--1
fz*-i + ~ * - - = f v- 1 2fp* f 0 * - - ~ f v * . ( 8)
T h e n u m b e r o f a p p l i c a t i o n s o f A l g o r i t h m A t o n e t w o r k s w i t h n o n n e g a t i v e w e i g h t s
t o ve r i f y t h a t a m a x i m u m f l o w h a s b e e n r e a c h e d is I.
T o p u t a n u p p e r b o u n d o n ( 8) w e e st a bl i sh a l o w e r b o u n d o n f p *. L e t T b e a n
u p p e r b o u n d o n t h e n u m b e r o f a r c s i n a c u t -se t se p a r a t i n g s f r o m t; i.e. if t h e n o d e s
a r e p a r t i t i o n e d i n t o s e t s X a n d X s u c h t h a t s C S a n d t E X , t h e n t h e n u m b e r o f
a r c s di r e c t e d f r o m a n o d e i n X t o a n o d e i n X is less t h a n o r e q u a l t o T. A c c o r d i n g t o
t h e m a x - f l o w r a i n -c u t t h e o r e m ([5])
f v* = mi n E P(u")l P(u")l
. ~ L 2~ J=~7"YL 2p J
f or s ome p a r t i t i o n (Y, 1~). No w
e( u, " )7 > e( u, , )
- - - ~ - - A - - 2 P 1,
J o u r n a l o f t h e A sso c i a t i o n for C o m p u t i n g M a c h i n e r y , V o l . 19, N o . 2, A p r i l 1972
2 6 4 J. EDMONDS AND R. M. KARP
s o
1 1 ,
f p* >_ ~ ~ c ( u , v) - - T _> ~ f o - - T.
u EY
vET"
Su b s t i t u t i n g t hi s i n e q u a l i t y i n (8) gi ves, as a n u p p e r b o u n d on t he n u mb e r of flow
a u g me n t a t i o n s ,
~ - ~ ( 1 , ) 1 ,
] 0 - - ~p=l ~ f o -- T = : ~ f o + ( l - - 1 ) T < 1T.
Th e f ol l owi ng t he or e m s ums up our concl us i ons .
THEOREM 10. Let N be a net work wi t h n nodes, I A [ arcs, and at most T arcs i n
a
cut- set separat i ng s f r om t. Let l be the nu mb er of b i nary di gi t s needed to represent the
largest arc c ap ac i t y. T hen the sc al i ng met hod solves the mi ni mw~ t - c ost f l ow probl em
f or N u s i ng not more t han I A I (l - 1) ap p l i c at i ons of Al g ori t hm C and not more t han
l - - 1 + l T ap p l i c at i ons of A l g or i t hm A to net works wi t h ~wnnegative weights. E ac h
net work considered i n the al gori t hm has n nodes and at most I A [ arcs.
REFERENCES
(Note. References [1, 3, 6, 7] are not cited in the text.)
1. DINIC, E. A. Algorithm for sol ut i on of a problem of maximum flow in a network with
power estimation. Soy. Math. Dokl. 11 (1970), 1277-1280.
2. EDMONDS, J. Paths, trees and flowers. Canadian J . Math. 17 (1965), 449 467.
3. EDMONDS, J., AND KARP, R. M. Theoretical improvements in algorithmic efficiency for
network flow problems. Combinatorial Structures and Their Applications. Gordon and
Breach, New York, 1970, pp. 93-96 (abstract presented at Calgary I nt er nat i onal Conference
on Combinatorial Structures and Thei r Applications, June 1969).
4. EDMONDS, J., AND FULKERSON, D. R. Bottleneck extrema. RAND Corp. Memorandum
RM-5375-PR (Jan. 1968).
5. FORD, L. I{., AND FULKERSON, I). R. Flows in Networks. Pri ncet on U. Press, Pri ncet on,
N.J., 1962.
6. FULKERSON, D. l l . On the equivalence of the capacity-constrained t ransshi pment prob-
lem and the Hitchcock problems. RAND Corp. Memorandum RM-2480 (Jan. 1960).
7. WAGNER, H. M. On a class of capacitated t r anspor t at i on problems. Manag. Sci. 5 (1959),
304 318.
RECEIVED SEPTEMBER 1970; REVISED AUGUST 1971
Journal of the Association for Computing Machinery, Vo|. 19, No. 2, April 1972

You might also like