/
Matchings in Graphs Lecturer Meena Mahajan Scribe Niti Matchings in Graphs Lecturer Meena Mahajan Scribe Niti

Matchings in Graphs Lecturer Meena Mahajan Scribe Niti - PDF document

giovanna-bartolotta
giovanna-bartolotta . @giovanna-bartolotta
Follow
411 views
Uploaded On 2015-04-08

Matchings in Graphs Lecturer Meena Mahajan Scribe Niti - PPT Presentation

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

know from Berges

Share:

Link:

Embed:

Download Presentation from below link

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.


Presentation Transcript

MatchingsinGraphsLecturer:MeenaMahajanScribe:NitinSaurabhMeeting:213thJanuary2010 1AGeneralAlgorithmforMatchingLet=(V;E)beageneralundirectedgraph.WeknowfromBerge'stheoremthatamatchingMismaximuminifandonlyifhasnoaugmentingpathswithrespecttoM.Thisimmediatelysuggeststhefollowingalgorithmformaximummatchinginundirectedgraphs.M=;;n=V;forv=1tondoFindanaugmentingpathwithrespecttoMstartingatvIfsuccess,wegetapathM MendforReturnMRemark1Althoughtheabovealgorithmdoesasinglepassonvertices,scanningthemina xedorder,itdoesnotmissamaximummatching.ThecorrectnessofthealgorithmfollowsfromthefactthatifthereisnoaugmentingpathfromvwithrespecttoMandissomeaugmentingpathwithrespecttoMthenthereisnoaugmentingpathfromvwithrespecttoM.Wewillnotprovethishere.1.1Analgorithmfor ndinganaugmentingpathstartingataparticularvertexTo ndanaugmentingpathinstartingatvwithrespecttoamatchingM,weconstructadirectedgraphHvfromtheoriginalgraph,whereV(Hv)=V()andE(Hv)=f(u;v)w2V():(u;w)=2Mand(w;v)2Mg.Wealsode neFree=fuuisnotmatchedbyMgGood=fuN(u)\Freenfvg6=;gConsiderthefollowingalgorithmto ndanaugmentingpathfromv.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. Itiseasyto ndadirectedpathinHvfromvtoGood.Buttherequirementthatthewalkunderlyingbesimpleiniswhatcausesdiculties.(Toretrieveanaugmentingpathin,wemayhavetoscananddiscardseveraldirectedpathsinHv.)Weobserve rstthatthisrequirementisindeednecessary:ThoughtheexistenceofanaugmentingpathinwithrespecttoMfromvimpliestheexistenceofapseudoaugmentingpathinHv,theconverseisnottrue.Forinstance,inthe gurebelow,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.Repeatedly nddirectedpathsinHfromafreevertextoagoodvertex(goodnowmeansithasatleastonefreeneighbour).Ifsuchapathyieldsanaugmentingpathin,augmentthematchingandstartafresh.Otherwise,byClaim3,thepathyieldsablossom,andweshrinkit(andalsoshrinkthecurrentmatchingwithrespecttoit)andcontinue.Ifnosuchdirectedpathsarefound,reportthecurrentmatching.To nddirectedpathseciently,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=Vj2jMj(nU)jUandhenceMjV+Uj(nU) 2Iftheaboverelationisinfactanequality,thenMisamaximummatching,andUcerti esthisfact.SuchasubsetUisthereforecalledawitnesssetforM.ThustocertifythatamatchingMismaximuminagraph,itsucesto ndawitnesssetcertifyingthis.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)=VjjFreevertices=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.Startfromsuchanendpointandconsidertheinitialsegmentofuntilthepointwhereit rstvisitsB.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.AwitnesssetUforMcerti esthatMismaximum.Itisnotatallobviousapriorithatwitnesssetsexist.However,Claim6showsthatforthematchingNinthe nalgraphH,ODDformsawitnessset.Wecanshowsomethingstronger:Claim7Whenthealgorithmterminates,thesetODDisawitnesssetfoMin.ProofofClaim7:Notethatallshrunk-blossomverticesareinEVENinH.Ifweushrinktheblossoms,eachblossomwillformanoddcomponentinnODD.Considerthee ectofunshrinkingoneblossomatatime.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.De nition9AnOddSetCoverisafamilyofdisjointsubsetsofV,C=(C1;C2;:::;Cl),where1.eachCiisodd,and2.foreachedge(u;v),eithereitherfug2C,orfvg2C,orC2Csuchthatfu;vgC.6 Thatis,thefamilyChasdisjointoddsubsetssuchthatforeveryedge,eitherone(orboth)endpointisasingletonsetinthefamily,orbothendpointsarecontainedinasinglesetinthefamily.De nition10ThecostofanoddsetcoverC=(C1;C2;:::;Cl)isde nedtobePiCost(Ci),whereforeachodd-sizedCV,Cost(C)=1ifC=1,jCj1 2otherwiseItiseasytoseethatforanymatchingMandanyoddsetcoverC,MjCost(C).Theorem8impliesthatthisistight;thisisleftasanexercise.7