Wightd Mtching nd Linr Progrmming Jonthn Turnr Mrch 19, 01 W v sn tht mximum siz mtchings cn b found in gnrl grphs using ugmnting pths. In principl, this sm pproch cn b pplid to mximum wight mtchings. Th min diffrnc is tht w nd to choos n ugmnting pth tht producs th lrgst possibl incrs in wight t ch stp. This is illustrtd in Figur 1. Not tht if w ugmnt th c b 4 5 5 d f Figur 1: Mx wight ugmnting pths mtching shown using th pth bcf, w gt lrgr mtching with wight tht is on lrgr thn tht of th originl mtching. On th othr hnd, th ugmnting pth bdf lds to dcrs in th mtching wight. Th ugmnting pth tht producs th lrgst incrs in wight is bdcf. Dfin th wight of n ugmnting pth to b th totl wight of its non-mtching dgs minus th totl wight of its mtching dgs. This pth wight is th nt gin possibl from flipping th dgs in th pth. Suppos M is mx wight mtching of siz k (tht is, mong ll mtchings with k dgs, M hs mximum wight) nd p is mximum wight umnting pth with rspct to M. If w cn show tht flipping th dgs of p yilds mx wight mtching of siz k + 1 thn w could us this to find mximum wight mtchings of rbitrry siz. 1
To shows this, ssum tht M is mx wight mtching on k + 1 dgs nd lt N b th st of dgs tht is in M or M but not both. Not tht N consists of ltrnting pths nd cycls with rspct to M, nd its cycls ll hv vn lngth. Lt th wight of pth or cycl in N b th totl wight of its dgs tht r not in M minus th totl wight of its dgs tht r in M. Obsrv tht ny vn lngth cycl in N must hv wight 0 sinc othrwis w could incrs th wight of M without incrsing its siz by flipping th dgs in th cycl. Th sm obsrvtion holds for pths of vn lngth. Now, sinc N hs on mor dg from M thn from M, w cn pir up ll but on of th odd lngth pths, so tht ch pir hs n qul numbr of dgs from M nd M. By th sm rgumnt s bfor, ch such pir of pths must hv wight 0. Th rmining pth must b mximum wight ugmnting pth with rspct to M, sinc if it wr not, w could us mx wight ugmnting pth to produc mtching of siz k +1 with lrgr wight thn M. Hnc, w hv th following thorm. Thorm 1 Lt M b mtching of mximum wight mong mtchings of siz k, nd lt p b mximum wight ugmnting pth for M. Thn th mtching obtind by flipping th dgs of p hs mximum wight mong mtchings of siz k + 1. This thorm provids th bsis for wightd mtching lgorithm. Finding mximum wight ugmnting pth is difficult to do dirctly, spcilly for gnrl grphs. Howvr, w cn us linr progrmming dulity to fcilitt th srch for mx wight ugmnting pths. W strt by dfining 0-1 slction vribl x for ch dg in th grph; x = 1 will corrspond to th inclusion of dg in th mtching. Th mtching problm is thn quivlnt to th intgr linr progrm mximiz subjct to wight(x) = x w() ={u,v} x 1 x {0, 1} for ll vrtics u for ll dgs Th objctiv function mximizs th wight of th dgs in th mtching, whil th constrints limit us to on dg pr vrtx. If w rplc th 0-1 constrints on th slction vribls with inqulits of th form x 1 w gt th linr progrm rlxtion of this ILP. W ctully don t nd to includ ths inqulitis xplicitly, sinc th form of th stndrd LP lrdy constrins th x to b non-ngtiv nd consquntly, th othr
constrints prvnt thm from bing lrgr thn 1. Edmonds showd tht for biprtit grphs, th LP rlxtion hs optiml solutions in which ll th slction vribls r intgrs, vn though thy r not constrind to b. Th ssntil proprty tht mks this tru is tht th cofficint mtrix for th linr progrm is totlly unimodulr. Edmonds lso showd similr proprty for gnrl grphs but w will dfr tht for now. W cn us dulity to dvlop n fficint lgorithm for th biprtit cs. Th dul problm is minimiz u z u subjct to z u + z v w() for ll dgs = {u, v} Th dul vribls r rfrrd to s vrtx lbls. For convninc, w dfin z = z u + z v for = {u, v}. Th complmntry slcknss condition tlls us tht for optiml vlus of th priml nd dul vribls, if z > w() thn x must b zro, nd if ={u,v} x 1, z u must b zro. This is quivlnt to sying tht for ny dg in th optiml mtching, z = w() nd for ny fr vrtx u, z u = 0. Morovr, if w cn find vlus of th x nd z u tht stisfy th complmntry slcknss conditions, ths must corrspond to optiml solutions, hnc th x vlus dfin mximum wight mtching. W cn us this to construct n lgorithm tht systmticlly djusts th priml nd dul vribls until th complmntry slcknss conditions r stisfid. Th following thorm cpturs ths obsrvtions. Thorm Lt G = (V, E) b biprtit grph with dg wights w(), lt M b mtching in G, lt ch vrtx u hv non-ngtiv lbl z u nd lt z = z u + z v for = {u, v}. If (1) z w() for ll () z = w() for M () z u = 0 if u is fr thn M is mximum wight mtching. Although, w rrivd t Thorm using LP dulity, it cn ctully b provd indpndntly, without rfrnc to linr progrmming t ll. If N is ny mtching, thn w() z z u z = w() N N u M M
Th first inqulity follows from condition (1) in th thorm; th scond follows from th fct tht N is mtching; th third follows from condition (); nd th finl qulity follows from condition (). An dg = {u, v} with z = z u + z v = w() is clld n qulity dg. Not tht if p = u 0,..., u k+1 is n ugmnting pth, thn conditions (1) nd () in th thorm imply tht th wight of p stisfis th following. wight(p) = (w(u 0, u 1 ) + w(u, u ) + + w(u k, u k+1 )) (w(u 1, u ) + w(u, u 4 ) + + w(u k 1, u k )) = (w(u 0, u 1 ) + w(u, u ) + + w(u k, u k+1 )) (z u1 + z u + + z uk ) (z u0 + z u + + z uk+1 ) (z u1 + z u + + z uk ) = z u0 + z uk+1 Also, not tht if p is constructd ntirly from qulity dgs, its wight is xctly qul to z u0 + z uk+1. Hnc, ny ugmnting pth tht uss only qulity dgs is mx wight pth, whil ny ugmnting pth tht uss t lst on non-qulity dg is not mx wight pth. This lds dirctly to n lgorithm for finding mx wight mtching. At ll tims, w mintin lbls tht stisfy conditions (1) nd () nd w construct collction of trs using only qulity dgs. Whnvr w find such n ugmnting pth, w flip th dgs, s usul. Not tht this mintins th vlidity of condition () bcus ll dgs in th ugmnting pth r qulity dgs. At vrious points in th lgorithm, w my us up ll th qulity dgs, prvnting us from xpnding th collction of trs ny furthr. Whn this hppns, w djust th lbls so s to crt dditionl qulity dgs, tking cr to mintin th vlidity of conditions (1) nd (). Evntully, th lbl djustmnts cus condition () to b stisfid, cusing th lgorithm to trmint. Hr s mor complt dscription. First, initiliz M = {} nd for ll u, lt z u b hlf of th lrgst dg wight. This clrly stisfis conditions (1) nd (). W srch for ugmnting pths by building st of trs rootd t th fr vrtics, s w hv don bfor. At ch stp, w considr prviously unxmind qulity dg = {u, v} with u vn. If v is unrchd, w xtnd th tr by dding nd th mtching dg incidnt to v. If v is vn, thn w hv found n ugmnting pth tht w cn us to xtnd th tr. Evry tim w xtnd th mtching, w discrd th currnt st of trs nd th odd/vn sttus informtion. Howvr, w rtin th vrtx lbls. 4
If th srch xmins ll qulity dgs without finding n ugmnting pth, w djust th vrtx lbls s follows. Lt δ 1 = min{z u u is vn} δ = min{z w() = {u, v}, u is vn, v is unrchd} δ = min{(z w())/ = {u, v}, u is vn, v is vn} δ = min{δ 1, δ, δ } Not tht whil th lgorithm is running, thr must b t lst on vn vrtx, so δ 1 is lwys dfind. Howvr, δ nd δ my b undfind du to th lck of n dg tht stisfis th condition. If ithr or both r not dfind, th dfinition of δ is djustd to ignor th undfind δ i vlus. W djust th lbls by subtrcting δ from th lbls of vn vrtics nd dding δ to th lbl of odd vrtics. Notic tht this mintins th vlidity of condition (), sinc mtching dgs ithr hv both ndpoints unrchd or hv on odd ndpoint nd on vn ndpoint. It lso mintins xisting qulity dgs tht r prt of tr, sinc ths dgs lso connct n vn vrtx to nd n odd on. In ddition, it mintins th vlidity of condition (1), sinc no z u is rducd nough to crt violtion. Not howvr, tht qulity dgs with two odd ndpoints my bcom inqulity dgs, s rsult of lbl djustmnt. Obsrv tht if δ = δ 1, thn ftr th djustmnt, condition () is stisfid, so th currnt mtching is mx wight mtching. If δ = δ < δ 1 or δ = δ < δ 1, th djustmnt producs t lst on nw qulity dg, llowing th srch for n ugmnting pth to rsum. Lt s look t n xmpl of th lgorithm in ction. In Figur w s 4+ 4+ 4+ 4+ x 5 b 4 y 4+ z 4+ d v 4+ 4+ 4+ Figur : Gtting strtd th stt of th lgorithm ftr th first two stps. Th initiliztion st ll vrtx lbls qul to 4. Thn, th first stp discovrd th ugmnting pth 5
.5+.5+.5.5+.5+.5.5+ x 5 b 4.5 y.5+ z.5.5+ x 5 b 5.5 y.5+ z.5+ d v.5+.5.5 d v.5+.5.5 4 4 + x 5 b y z 1+ x 5 b y z d v +.5.5 d v 1+.5.5 Figur : Exmpl of lbling lgorithm from b to u nd ddd {b, u} to th mtching. Th scond stp ddd th dgs {b, y} nd {b, u} to th tr rootd t y. Not tht ths r th only qulity dgs t this point, so ftr th scond stp, th lgorithm rlbls vrtics. In this cs, δ = 0.5 nd dgs {c, z} nd {, v} bcom qulity dgs. Ths r lso ugmnting pths, so th lgorithm finds thm nd ugmnts th mtching. It thn rbuilds th tr consisting of dgs {b, u} nd {b, v} giving th stt shown in th top lft of Figur. At this point, w must gin pus to rlbl th vrtics. In this cs, δ = 1, mking {c, y} n qulity dg, llowing th tr to xpndd furthr, giving us th stt shown in top right of th figur. Onc mor, w must rlbl th vrtics, this tim using δ = 0.5. This, mks {, u} n qulity dg nd lds to th ugmnting pth uby nd th stt shown in th bottom lft of th figur. Two mor stps producs th finl mtching shown in th bottom right of th figur. Now lt s considr how to implmnt this most fficintly. W cn us hps to quickly dtrmin th δ i vlus whn rlbling is rquird. Lt h 1, b hp contining ll th vn vrtics with z(u) s th ky for vrtx u. W ll mintin scond hp h 1,o for th odd vrtics. Lt h b hp contining ll dgs with on vn nd on un-
rchd ndpoint, nd lt ky() = z w(). Lt h b hp contining ll dgs with two vn ndpoints, nd lt ky() = z w(). W cn lso us ths hps to updt th lbls fficintly if w us hp with n fficint ddtokys oprtion. This oprtion dds vlu x to th kys of ll itms in hp nd llows th lbls to b djustd implicitly. Whn w rmov vrtx u from h 1, or h 1,o, its ky vlu is usd to updt th lbl z u, but whil u is in ithr of th hps, its lbl vlu is rprsntd implicitly by th ky of th hp itm. W ll xplin ltr how to xtnd th d-hp to implmnt ddtokys in constnt tim. This mks ch lbl djustmnt constnt tim oprtion. Now, thr r t most n/ ugmnting pth srchs nd within ch srch, ll but th lst stp ithr xtnds th tr or prforms rlbling. Whn xtnding th tr, w mk on unrchd vrtx odd nd nothr on vn. Ths must lso b ddd to ithr h 1,o or h 1,. In ddition, th dgs incidnt to th nw vn vrtx must b xmind, nd ddd to h or h s pproprit (w my hv to rmov n dg from h hr lso). Sinc no vrtx bcoms vn mor thn onc in n ugmnting pth srch, ths hp oprtions contribut O(m log n) to th tim for ch pth srch nd O(mn log n) ltogthr. Th tim for ch rlbling oprtion is O(1). During ny singl ugmnting pth srch, n dg cn bcom n qulity dg t most on tim. Sinc ll but th lst rlbling oprtion crts t lst on nw qulity dg, th numbr of rlbling oprtions pr ugmnting pth srch is t most m nd so th run tim for ll rlbling oprtions is O(mn). Th rmining oprtions nd hnc th ovrll run tim is O(mn log n). Wht rmins is to xplin how th d-hp cn b xtndd to implmnt ddtokys in constnt tim. This cn b don by dding singl vribl to th hp. Ech ddtokys(x) dds x to. Whn n itm is insrtd into th hp with ky of k, w substitut k s th intrnl ky vlu stord in th hp. Subsqunt ddtokys oprtion do not chng this stord ky vlu, just th vlu of. To rcovr th tru vlu of hp itm s ky, w simply dd th currnt vlu of to th stord ky.