We know from Berges theorem that a matching is maximum in if and only if has no augmenting paths with respect to This immediately suggests the following algorithm for maxim um matching in undirected graphs for 1 to do Find an augmenting path with ID: 49647
Download Pdf The PPT/PDF document "Matchings in Graphs Lecturer Meena Mahaj..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
MatchingsinGraphsLecturer:MeenaMahajanScribe:NitinSaurabhMeeting:213thJanuary2010 1AGeneralAlgorithmforMatchingLet=(V;E)beageneralundirectedgraph.WeknowfromBerge'stheoremthatamatchingMismaximuminifandonlyifhasnoaugmentingpathswithrespecttoM.Thisimmediatelysuggeststhefollowingalgorithmformaximummatchinginundirectedgraphs.M=;;n=V;forv=1tondoFindanaugmentingpathwithrespecttoMstartingatvIfsuccess,wegetapathM MendforReturnMRemark1Althoughtheabovealgorithmdoesasinglepassonvertices,scanningtheminaxedorder,itdoesnotmissamaximummatching.ThecorrectnessofthealgorithmfollowsfromthefactthatifthereisnoaugmentingpathfromvwithrespecttoMandissomeaugmentingpathwithrespecttoMthenthereisnoaugmentingpathfromvwithrespecttoM.Wewillnotprovethishere.1.1AnalgorithmforndinganaugmentingpathstartingataparticularvertexTondanaugmentingpathinstartingatvwithrespecttoamatchingM,weconstructadirectedgraphHvfromtheoriginalgraph,whereV(Hv)=V()andE(Hv)=f(u;v)w2V():(u;w)=2Mand(w;v)2Mg.WealsodeneFree=fuuisnotmatchedbyMgGood=fuN(u)\Freenfvg6=;gConsiderthefollowingalgorithmtondanaugmentingpathfromv.ifvisnotfreethenReturnvelseifu2N(v)\FreethenReturn(v;u)1 elseConstructFree,Good,Hv.SearchinHvforasimpledirectedpathfromvtothesetGood.Callsuchapathapseudoaugmentingpath.ifthewalkincorrespondingtoisasimplepaththenreturnthispath.endifendifThecorrectnessofthealgorithmfollowsfromthefollowingclaim:Claim2ThereisanaugmentingpathwithrespecttoMstartingatvifandonlyifthereisadirectedpathfromvtothesetGoodinHvsuchthatcorrespondstoasimplepathintheoriginalgraph.Proof:())LetbeanaugmentingpathinwithrespecttoM,beginningatvandendingatw.Letubetheneighbourofwon.ThenuisinthesetGood,andthesubpathofendingatucorrespondstoapseudo-augmentingpathinHvfromvtou.(()Letbethedirectedpathfromvtosomeu2GoodinHv.Sinceu2Good,ithasaneighbourw=vinFree.Thesimplepathincorrespondingto,alongwiththeedge(u;w),givesanaugmentingpathinwithrespecttoM. ItiseasytondadirectedpathinHvfromvtoGood.Buttherequirementthatthewalkunderlyingbesimpleiniswhatcausesdiculties.(Toretrieveanaugmentingpathin,wemayhavetoscananddiscardseveraldirectedpathsinHv.)Weobserverstthatthisrequirementisindeednecessary:ThoughtheexistenceofanaugmentingpathinwithrespecttoMfromvimpliestheexistenceofapseudoaugmentingpathinHv,theconverseisnottrue.Forinstance,inthegurebelow,letv=1.Thenu=2isinGood,becauseofneighbourw=3.InHv,thereisadirectedpathfrom1to2via4and6,butitspullbackinisthewalk1-2-4-5-6-4-2wichisnotasimplepath. 1212 However,despitethisproblem,wecanstillusepseudo-augmentingpaths,becauseofthefollowingstructure.Claim3Ifthefullpathcorrespondingtoapseudoaugmentingpathisnotaugmenting,thenitcontainsanoddcycle.Proof:Thefullpathcorrespondingtothepseudoaugmentingpathisnotaugmenting,whichimpliesthatfullpathisnotsimple.Henceitcontainsacycle.Ifitisanevenlength2 cycle,thenthepseudoaugmentingpathtouchesavertextwice,contradictingthefactthatapseudoaugmentingpathisasimpledirectedpath. Wewillnowseehowtousethisinsighttogetanecientalgorithm.2Edmonds'BlossomShrinkingAlgorithmAblossomBwithrespecttoMisanoddcyclewithmaximalnumberofmatchededges.Thatis,ifitcontains2k+1vertices,thenkedgesarematched.ShrinkingablossomBmeansshrinkingallverticesofBintoasinglenewvertex,say,andmakingitadjacenttoallverticesinVnBwhichareadjacenttoanynodeofB.ShrinkingBshrinksthematchingMtoMnB,wherewediscardalltheM-edgesonthecycle.Thestrategynowisasfollows.RepeatedlynddirectedpathsinHfromafreevertextoagoodvertex(goodnowmeansithasatleastonefreeneighbour).Ifsuchapathyieldsanaugmentingpathin,augmentthematchingandstartafresh.Otherwise,byClaim3,thepathyieldsablossom,andweshrinkit(andalsoshrinkthecurrentmatchingwithrespecttoit)andcontinue.Ifnosuchdirectedpathsarefound,reportthecurrentmatching.Tonddirectedpathseciently,thealgorithmmaintainsaforestofscannededges.Formally,thealgorithmcanbestatedasfollows.Algorithm1:M=;,H=,N=M2:EVEN=fvvisfreeinMgODD=;,EF=;MaintainalwaysVF=EVEN[ODDConstructforest=(VF;EF)3:Pickanedge(u,v)suchthatu2EVENandv=2ODDIfnosuchedgeexists,OutputM4:ifv=2VFthen5:PutvinODD,M(v)inEVEN,and(u;v)and(v;M(v))inEF,whereM(v)isthevertexmatchedtov.6:elseifv2EVENandu;vareconnectedinthen7:AblossomBhasbeenfound.ShrinkBto,andsetHtoHnB,NtoNnB.InH,putinEVEN.8:GotoStep39:elseifv2EVENandu;varenotconnectedinthen10:WehaveanaugmentingpathinHwithrespecttoN.RetrieveanaugmentingpathinwithrespecttoM.11:AugmentM.12:GotoStep2.13:endifMoststepsinthealgorithmareself-evident.Letuselaborateonsomesteps.3 Step7:Whatexactlyistheblossom?Letu;vbelongtotreeTin.Theedge(u;v)createsafundamentalcycleinT,andsincebothuandvareEVENvertices(atevendistancefromtherootofT),thecycleisodd.Thiscycleistheblossom.Step10:Whatistheaugmentingpath?Startfromtherootofthetreeincontainingu,comedowntou,movetov,gouptotherootofthetreecontainingv.AndhowdoweretrieveanM-augmentingpathin?Theideaistounshrinktheblossomsandmatchingsshrunkalongtheway.Consideronestage:HisobtainedfrombyshrinkingBto,andwehaveanaugmentingpathinH.Ifdoesnotvisit,thenisalsoanM-augmentingpathin.Ifvisits,therearetwopossibilities:1.endsin.ThiscanonlyhappeniftheblossomBincludedtherootofthetreeinwhichitwaslocated,sinceotherwiseisnotfreeinH.NowinendsatsomevertexatB,fromwherewecangototherootbyproceedingalongtheappropriatedirectionwhichhasthematchededge.2.visitsalongtheway.LetinreachvertexxonB.TheonlymatchededgeleavingBistheonefromavertexyonBtowardstherootofthetree.Fromx,wecanagainchoosetheappropriatedirectionalongBtomaintainM-alternation,reachy,andthencontinueasin.Clearly,thiscanbedoneacrossmultiplestagesaswell.Nowweneedtoprovethatthealgorithmisindeedcorrect;thatitterminateswithamaximummatching.ThiswillfollowfromLemma4andLemma5below.Lemma4Whenthealgorithmterminates,NisamaximummatchinginH.Lemma5LetNbeamatchinginHandBbeablossom.NnBismaximuminHnBifandonlyifNismaximuminH.ToproveLemma4,weneedatestforwhenamatchingismaximum.Suchatestcanbedevisedbasedonoddcomponents.ForanysetofverticesU,let(nU)denotethenumberofoddcomponentsof(nU).Clearly,foreveryUVandforeverymatchingM,Mrestrictedto(nU)mustleaveatleast(nU)verticesfree,oneperoddcomponentinnU.Theseverticescanonlybematched,ifatall,toverticesinU.Sothefollowingholds:Numberofverticesfreew.r.t.M=Vj 2jMj(nU) jUandhenceMjV+Uj (nU) 2Iftheaboverelationisinfactanequality,thenMisamaximummatching,andUcertiesthisfact.SuchasubsetUisthereforecalledawitnesssetforM.ThustocertifythatamatchingMismaximuminagraph,itsucestondawitnesssetcertifyingthis.Now,toestablishLemma4,weshowexactlythis.Claim6ThesetODDconstructedbythealgorithmatterminationisawitnesssetcertifyingthatNismaximuminH.4 Proof:Whenthealgorithmterminates,thevertexsetVispartitionedintothreesets:EVEN,ODDandREST.ThesetEVENisanindependentset,becauseifthereisanedgebetweenanytwoverticesinEVEN,theneitherStep6orStep9ofthealgorithmistrue,contradictingthefactthatalgorithmhasterminated.Step5ofthealgorithmensuresthatforeveryvertexinODD,itsmatchedvertexisputinEVEN.ItalsoensuresthattheverticesinEVENarematchedonlytotheverticesinODD.Step3ensuresthattherearenoedgesconnectingEVENandREST.So,ondeletingODD,eachvertexofEVENformsaconnectedcomponentbyitself.AndallverticesofRESTarematchedbyMwithinREST,soondeletingODD,thecomponentswithinRESTareallofevensize.Hence(HnODD)=EVEN=ODD+FreeverticesODD+V(H)j (HnODD)=Vj jFreevertices=2NODD+V(H)j (HnODD) 2=NThus,thesetODDisawitnesssetcertifyingthatNismaximuminH. Nowweneedtoshowthatamaximummatchinginthegraphaftershrinkingblossomsimpliesamaximummatchingintheoriginalgraph.ProofofLemma5:Wewillprovethecontrapositive;namely,NnBisnotmaximuminHnBifandonlyifNisnotmaximuminH.())SupposethatNnBisnotmaximum;thenithasanaugmentingpath.Step10ofthealgorithm(seethediscussionafterthealgorithmpseudo-code)describeshowtoretrievefromanN-augmentingpathinH.SoNisnotmaximum.(()AssumenowthatNisnotmaximuminH.LetxbethevertexonBsuchthatbothedgesofBincidentonxareunmatched.Byconstruction,Nhasanalternatingevenlengthpathfromafreevertexytox.(couldbe,ifxitselfisfree.)ThenN0=NisamatchingofthesamesizeasN,andsoN0isnotmaximuminHeither.SothereexistsanN0-augmentingpathinH.InHnB,thematchingN0nBisofthesamesizeasthematchingNnB.SoitsucestoshowthatN0nBisnotmaximum.WewillconstructfromanaugmentingpathinHnBwithrespecttoN0nB.IfcompletelyavoidsB,thenitselfisthedesiredpath,sinceitisalsoanaugmentingpathinHnB.Otherwise,notethatN0nBleavesthevertexfree.IfvisitsB,thensinceBhasatonlyonefreevertex,buthasbothendpointsfree,atleastoneendpointofisnotonB.StartfromsuchanendpointandconsidertheinitialsegmentofuntilthepointwhereitrstvisitsB.TheninHnBreachesthefreevertex,andsoitisanaugmentingpath. Wehavethusestablishedthattheblossom-shrinkingalgorithmisindeedcorrect.Regard-ingitscomplexity,here'sarough-and-readyreckoner.Thereareatmostn=2augmentations.Betweenoneaugmentationandthenext,thealgorithmcanaddatmostmedgestothefor-est,andshrinkatmostn=3blossoms.Detectinganaugmentationorblossomrequires(m)time,sincewemaintainaforest.Sotheoveralltimeisatmost(n(n+m)m).Abetteranalysisispossible.5 3WitnesssetsandoddsetcoversInestablishingcorrectness,weusedtheconceptofwitnesssets.AwitnesssetUforMcertiesthatMismaximum.Itisnotatallobviousapriorithatwitnesssetsexist.However,Claim6showsthatforthematchingNinthenalgraphH,ODDformsawitnessset.Wecanshowsomethingstronger:Claim7Whenthealgorithmterminates,thesetODDisawitnesssetfoMin.ProofofClaim7:Notethatallshrunk-blossomverticesareinEVENinH.Ifweushrinktheblossoms,eachblossomwillformanoddcomponentinnODD.Considertheeectofunshrinkingoneblossomatatime.lettheblossombeofsize2k+1.WeknowfromClaim6thatN=ODD+V(H)j (HnODD) 2WhenwereplacebyB,Vincreasesby2k,Nincreasesbyk,andODDremainsthesameinsize.Also,sinceBisnowanoddcomponentinsteadof,(HnODD)remainsthesame.Sotheeualitycontinuestohold.Repeatingthisanalysisforeveryblossom,weconcludethatODDisawitnesssetcerti-fyingthatMismaximumin. Thus,aniceconsequenceofEdmonds'algorithmisthatforeverygraph,witnesssetsalwaysexist.WehaveprovedtheTutte-Bergetheorem:Theorem8(Tutte-Berge'sTheorem)maxMM=minUV+Uj (nU) 2Proof:ForeverymatchingMandforeveryUV,theLHSisupperboundedbytheRHS.HencetakingmaximumonleftandminimumonrightgivesmaxMMjminUV+Uj (nU) 2Claim7showsthatthereisawitnesssetwhereequalityisachieved. Thenotionofwitnesssetscanbeframedequivalentlyusingoddsetcovers.Denition9AnOddSetCoverisafamilyofdisjointsubsetsofV,C=(C1;C2;:::;Cl),where1.eachCiisodd,and2.foreachedge(u;v),eithereitherfug2C,orfvg2C,orC2Csuchthatfu;vgC.6 Thatis,thefamilyChasdisjointoddsubsetssuchthatforeveryedge,eitherone(orboth)endpointisasingletonsetinthefamily,orbothendpointsarecontainedinasinglesetinthefamily.Denition10ThecostofanoddsetcoverC=(C1;C2;:::;Cl)isdenedtobePiCost(Ci),whereforeachodd-sizedCV,Cost(C)=1ifC=1,jCj 1 2otherwiseItiseasytoseethatforanymatchingMandanyoddsetcoverC,MjCost(C).Theorem8impliesthatthisistight;thisisleftasanexercise.7