We consider graphs of bounded arboricity ie graphs with no dense subgraphs l ike for example planar graphs Brodal and Fagerberg WADS99 described a very simple line arsize data structure which processes queries in constant worstcase time and performs ID: 22078
Download Pdf The PPT/PDF document "Adjacency Queries in Dynamic Sparse Grap..." 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.
AdjacencyQueriesinDynamicSparseGraphs LukaszKowalikAbstractWedealwiththeproblemofmaintainingadynamicgraphsothatqueriesoftheform\isthereanedgebetweenuandv?"areprocessedfast.Weconsidergraphsofboundedarboricity,i.e.,graphswithnodensesubgraphs,likeforexampleplanargraphs.BrodalandFagerberg[WADS'99]describedaverysimplelinear-sizedatastructurewhichprocessesqueriesinconstantworst-casetimeandperformsinsertionsanddeletionsinO(1)andO(logn)amortizedtime,respectively.WeshowacomplementaryresultthattheirdatastructurecanbeusedtogetO(logn)worst-casetimeforquery,O(1)amortizedtimeforinsertionsandO(1)worst-casetimefordeletions.Moreover,ouranalysisshowsthatbycombiningthedatastructureofBrodalandFagerbergwithecientdictionariesonegetsO(logloglogn)worst-casetimeboundforqueriesanddeletionsandO(logloglogn)amortizedtimeforinsertions,withsizeofthedatastructurestilllinear.ThislastresultholdsevenforgraphsofarboricityboundedbyO(logkn),forsomeconstantk.Keywords:datastructures,graphalgorithms,adjacency,orientation,dynamic1IntroductionInthepresentpaperwestudyfullydynamicgraphs,i.e.,graphswhichchangeintimebymeansofinsertingandremovingedges(itisstraightforwardtoextendourresultsforthesituationwhenalsoverticesmaybeinsertedandremoved).Suchasettingraisesanaturalquestion:howtostorethestructureofthegraphinmemorysothatsomekindofinformationcanberetrievedfast.Morespecically,wefocusonthemostbasicsortofinformationaboutgraph:adjacency.InotherwordsweallowforprocessingqueriesoftheformAreverticesuandvadjacent?.Whenthegraphunderconsiderationisdense,e.g.ithas\n(n2)edges1thereisatrivialandecientsolution:storeanadjacencymatrix.Thenboththeupdatesandthequeriestakeconstanttime.However,forbigsparsegraphs,likeplanargraphs,suchtheapproachmaybeconsideredasunacceptablebecauseofhugememoryrequirementscomparedtotheactualsizeofthegraphstored.Henceweconsideronlydatastructuresoflinearspace InstituteofInformatics,WarsawUniversity,Banacha2,02-097,Warsaw,Poland.ThisworkwaspartiallydonewhentheauthorwasapostdocinMax-Planck-InstitutefurInformatik,Saarbrucken,Germany.E-mail:lkowalik@mimuw.edu.pl.SupportedinpartbyKBNgrant4T11C04425.1Throughoutthepapernandmdenotethenumberofverticesandedges,respectively.1 complexity.Thenonecanuseanotherclassicdatastructure:adjacencylists.Unfortunately,inthiscasetimeneededtoprocessaquerymaybetoolarge,unlessthereissomeboundonthevertices'degreesinthegraph.Inordertoxthatprobleminthecaseofplanargraphs,ChrobakandEppstein[5]usedthefactthatedgesofanundirectedplanargraphcanbeorientedsothatatmost3edgesleaveeveryvertex.Theynoticedthatitsucestostoretheadjacencylistsoftheresultingdirectedgraph{thenuandvareadjacentintheoriginalgraphifandonlyifuisintheadjacencylistofvorviceversa.However,ChrobakandEppsteinconsideredonlystaticgraphs.ThedynamiccasewasstudiedbyBrodalandFagerberg[4].Theyconsidermoregeneralclassthanplanargraphs{graphswitharboricityboundedbysomeconstantc.ArboricityofgraphG,denotedasarb(G),isthesmallestnumberofforestsneededtocoveralledgesofG.AtheorembyNash-Williams[13]saysthatarboricityisequaltomaxJdjE(J)j=(jV(J)j 1)ewhereJisanysubgraphofGwithjV(J)j2verticesandjE(J)jedges.Intuitively,graphsofboundedarboricityareuniformlysparse,i.e.,theydonothavedensesubgraphs.(Inparticular,planargraphshavearboricity3.)BrodalandFagerbergshowhowtomaintainaboundedoutdegreeorientationofsuchgraphs.Clearlythisallowsforprocessingadjacencyqueriesinconstanttime.Theyshowthattheirupdatealgorithmisasymptoticallyoptimal(seeSection2fordetails).However,tighttimecomplexityanalysisoftheirapproachstillremainsopen.Theauthorswereabletoshowthatwhenorientationwithoutdegreeismaintained,4c,theamortizedtimeperoperationisconstantforinsertionsandO(logn)fordeletions.AnotheranalysisgivesO(1)worst-casedeletiontimeandO(logn)amortizedinsertiontime.Theseresultshaveapplicationsinboundedlengthshortestpathoracles[10]and,moresurprisingly,graphcoloring[9].OurResultsInthispaperweextendtheworkofBrodalandFagerberg[4]byusingaslightlydierentapproach.Insteadofmaintainingoutdegreesintheorientationboundedbyaconstantandtryingtoreducetheupdatetime,weaskhowonecanboundtheoutdegrees,whiletheamortizedupdatetimeisconstant.However,sincethealgorithmofBrodalandFagerbergisasymptoticallyoptimal,thereisnoneedfordesigninganewone.Weshowthatwhentheiralgorithmissupposedtomaintainorientationwithoutdegree,for4c(blogcnc+1),insertionstakeO(1)amortizedtimeanddeletionsO(1)worst-casetime(recallthatcistheboundonarboricity).Clearly,thisallowsforprocessingadjacencyqueriesinO(logn)worst-casetimewhenthearboricityisbounded.Notethatintheapplicationsinwhichweareinterestedinthetotaltimeofthewholesequenceofoperations,likeforexamplewhentheorientationisusedasadatastructureinsomealgorithm,thisisoptimalwhentheupdatesarefrequentcomparedtoqueries,i.e.,theratioofnumberofupdatestothenumberofqueriesis\n(logn).2 DictionaryApproachAnothernaturalapproachtoourproblemisstoringtheinformationabouttheedgesofthedynamicgraphinadictionary,i.e.,adatastructurewhichenablesadding,removingandndingkeys(elements).Inourcasetheseelementsareedgesofthegraph.Forconvenience,wewillassumethatverticesofthegraphareenumeratedfrom1tonandthatapairofverticesdescribinganedgecanbestoredinonewordofmemory(itiscommoninanalysisofgraphalgorithmstoassumethateachvertexcanbestoredinO(1)wordsofmemory).Dietzfelbingeretal.[6]showalinear-sizerandomizeddictionarybasedonhashingwithO(1)worst-casetimelookupsandO(1)amortizedexpectedtimeupdates.Withoutrandomizationthedynamicdictionaryproblemseemstobeharder:Mehlhorn,NaherandRauch[11]showthat\n(mloglogm)timeisneededforminsertionsinsomedeterministicmodeloflinear-spacedictionarythatencompassesbothhashingstrategiesandsearchtrees,whicharethetwomostecientsolutionstothedictionaryproblem.However,inourcase,whenthesizeoftheuniverse(numberofpossibleedges)israthersmall,thereisasolutionveryclosetothislowerbound.Namely,thedynamizationtechniquebyAnderssonandThorup[2]appliedtotheexponentialsearchtreesbyBeameandFich[3],achievestheO(loglogmloglogU logloglogU)worst-casetimeboundforbothlookupsandupdates,wheremisthenumberofkeysstoredandUisthemaximalkeystoredindictionary(itisassumedthatthedictionarystoresintegers).NotethatinthecaseofstoringedgesUn2,whichgivesusaboundofO(loglogn)2 logloglognontheworst-timecomplexityofeachoperation.OurResultsCombinedWithDictionaryApproachThemainassetofourresultissimplicityofthealgorithmwithitsasymptoticoptimalityinsituationswhentheupdatesareveryfrequent.However,bycombiningourapproachwithdeterministicdictionariesoneobtainstheoreticallyextremelyecientsolution:O(logloglogn)worst-casetimeforqueryandedgedeletionandO(logloglogn)amortizedtimeforinsertion,whenthedynamicgraphunderconsiderationhasarboricityboundedbyO(logkn),forsomeconstantk.Hencewegetthebestknowndeterministicmethodforstoringadjacencyofsparsegraphsinthesitu-ationwhenqueriesandupdatesappearsimilarlyoften.Thisshouldbecomparedwiththealreadymentioned\n(loglogn)lowerbound[11]foramortizedinsertiontimeinthedynamicdeterministicdictionarywhichstoresalltheedgesofthegraph.AdjacencyLabelingSchemesKannanetal.[8]introducedtheideaofalabelingscheme,whereeachvertexofagraphisassignedalabelsothatadjacencyoftwoverticescanbedecidedbasedonlyontheirlabels.WenotethathavinganorientationofagraphGonegetsalabelingschemeforGinwhichthelabelofavertexvisthenumberofvtogetherwiththenumbersofendverticesoftheedgesleavingv.ItfollowsthattheperformanceboundsfromboththepaperofBrodalandFagerbergandthepresentpapermaybereformulatedastherelevantspaceandtimeboundsfordynamiclabelingschemeingraphsofboundedarboricity.Theproblem3 ofmaintainingdynamicadjacencylabelswasalsoconsideredrecentlybyMorgan[12],whofocusedonthecaseoflinegraphs.ComparisonTheabovediscussionshowsthattherearetwoleadingapproachesfortheproblemofmaintainingadjacencyofadynamicgraphofboundedarboricity:randomizeddynamichashingandboundedoutdegreeorientations.Wepointoutthefollowingassetsoftheorientationapproach:deterministicalgorithm,theinformationisdistributedevenlyoverthenodesofthegraph(labellingscheme).2TheAlgorithmofBrodalandFagerbergInthissectionwesketchtheapproachfromthepaper[4].Wewillusethefollowingnotions.OrientationofanundirectedgraphGisadirectedgraph~GobtainedfromGbyreplacingeachedge,sayuv,eitherbyarc(u;v)orbyarc(v;u).Wewillalsosaythat~Gisad-orientationwhentheoutdegreeofeveryvertexdoesnotexceedd.Let~G1;~G2;:::;~Gtbeasequenceoforientations.WesaythatedgeuvisreorientedingraphGiwhenuvhasdierentorientationsinGi 1andGi.Eachsuchpair(uv;i)iscalledareorientation.However,thetermreorientationwithrespecttoanalgorithmwillmeansimplyanoperationofreversingtheorientationofanedge.ThealgorithmofBrodalandFagerbergworksasfollows.Letbetheboundonvertices'outdegreesthathastobemaintained.Thenwhenanedgeisremovedfromthegraphthealgorithmsimplyremovesitsorientedcounterpart.Afteraddinganedgethealgorithmorientsitarbitrarily.Next,aslongastheorientationcontainsavertexofoutdegreelargerthansuchavertexxispickedandtheorientationofalltheedgesleavingxisreversed.Clearly,thetotaltimeusedbytheabovealgorithmtomaintain-orientationduringasequenceofupdatesislinearinthelengthofthesequenceaddedtothenumberofreorien-tationsperformed.Thefollowinglemmastatesthattheabovealgorithmisasymptoticallyoptimalwithrespecttothenumberofreorientationsperformed.Itfollowsthatitisalsooptimalinrunningtimesinceitstimecomplexityislinearinthenumberofreorientationsandanyalgorithmwhichmaintainsorientationhastomakereorientations.Lemma2.1(BrodalandFagerberg[4]).Letbeasequenceofinsertionsanddeletionsonaninitiallyemptygraph.LetGibethegraphafteri-thoperationandletkdenotethenumberofedgeinsertions.Ifthereexistsasequence~G0;~G1;:::;~Gjjof-orientationswithatmostredgereorienta-tionsintotal,thenthealgorithmperformsatmost(k+r)+1 +1 24 edgereorientationsintotalonthesequence,provided2. 3AnalysisforLogarithmicOutdegreesLemma2.1impliesthatinordertoboundtheamortizedtimeofinsertoperationsinBrodal-Fagerbergalgorithmitsucestoconstructforanarbitrarysequenceofedgedeletionsandinsertions,asequenceoforientationsoftherelevantgraphswithasmallnumberofedgereorientations.However,inwhatfollowsweshowthatwhentheboundonoutdegreeislogarithmicinthelengthofthesequence,thenthereexistsasequenceoforientationswithnosinglereorientation.Lemma3.1.Anygraphwitharboricityccanbec-oriented.Proof.Theorientationcanbefoundbydecomposingthegraphintocforests,choosingarootineachtreeandorientingedgesofeachtreetowardsitsroot. Lemma3.2.LetG1;:::;Gtbeanysequenceofgraphswitharboricityboundedbyc.Thenthereexistsasequence~G1;:::;~Gtofc(blogtc+1)-orientationswithnoedgereorientations.Proof.Theproofisbytheinductionont.Fort=1thelemmaisequivalenttoLemma3.1.Nowassumet1andletk=bt=2c.Let~G01;:::;~G0kbeasequenceofc(blogkc+1)-orientationsofgraphsG1;:::;Gkwithnoreorientations,whichexistsbytheinductionhypothesis.Sim-ilarly,whenk+2t,fromtheinductionhypothesisweget~G0k+2;:::;~G0t|asequenceofc(blogkc+1)-orientationsofgraphsGk+2;:::;Gtwithnoreorientations.Weset~Gk+1tobeac-orientationofgraphGk+1obtainedbyLemma3.1.Nowconsideranyi=k+1andanedgeuv2Gi.Ifuv2Gk+1,weorientuvin~Githesameasin~Gk+1.Otherwiseweorientuvin~Githesameasin~G0i.Clearly,foranyvertexv2~Giwehaveoutdeg~Gi(v)outdeg~G0i(v)+outdeg~Gk+1(v)c(blogkc+1)+cc(blogtc+1).Finally,weconsideranyedgeuvwhichispresentintwosuccessivegraphsGi,Gi+1andwewillshowthatitsorientationisthesame.Ifuv2Gk+1theorientationofuvinboth~Giand~Gi+1isthesameasin~Gk+1.Otherwisetheorientationsofuvin~Giand~Gi+1arethesameasin~G0iand~G0i+1,hencetheyarethesame. Inthefollowinglemmaweshowthatwhenoneallowsreorientations,theboundonout-degreesbecomesindependentfromthelengthofthesequence.Lemma3.3.LetG1;:::;Gtbeanysequenceofgraphswitharboricityboundedbycandletbeanyinteger.Thenthereexistsasequence~G1;:::;~Gtofc(blognc+1)-orientationswithatmostct=reorientations.Proof.WepartitionthesequenceG1;:::;Gtintoblocksoflengthn.Foreachi=0;:::;bt=(n)cgraphsinblockGin+1;Gin+2;:::;G(i+1)narec(blognc+1)-orientedusingLemma3.2.5 Clearly,reorientationsmayappearonlyimmediatelyaftertheendofablock,i.e.,ingraphs~Gin+1fori0.Sincetherearebt=(n)csuchgraphsandeachofthemcontainsatmostc(n 1)edges,hencethetotalnumberofreorientationsdoesnotexceedct=. Corollary3.4.Considerasequenceofedgeinsertionsanddeletionsperformedonaninitiallyemptygraphsuchthataftereachoperationtheresultinggraphhasarboricityboundedbyc.Letkbethenumberofinsertionsandletbeaninteger.WhenthealgorithmofBrodalandFagerbergissettomaintainorientationwithoutdegreeatmost=4c(blognc+1)thenitperformsatmost2(k+2kc=)edgereorientations.Proof.Sincethenumberofdeletionsdoesnotexceedthenumberofinsertions,thesequenceofoperationshaslengthatmost2k.Thenthecorollaryfollowsimmediatelyfromlemmas2.1and3.3. Bysettingequaltotheboundonarboricitycwegetthefollowingtheorem.Theorem3.5.ThealgorithmofBrodalandFagerbergcanmaintainO(clogn)-orientationofaninitiallyemptydynamicgraphwitharboricityboundedbycwithconstantamortizedinsertiontimeandconstantworst-casedeletiontime. 4ApplyingDeterministicDictionariesIntheprevioussectionweanalyzedthetimecomplexityofthealgorithmofBrodalandFagerbergmaintainingO(clogn)-orientationofadynamicgraphwitharboricityboundedbyc.Nowconsideranimplementationofthisalgorithm,inwhichforeachvertexvthereisaseparatedictionarystoringtheendsoftheedgesleavingv.Moreover,lettheboundonarboricitybec=O(logkn),forsomeconstantk.Theorem3.5impliesthateachdictio-narystoresO(logk+1n)keysandeachedgeinsertioncausesamortizedconstantnumberofdictionaryinsertionsandworst-caseconstantnumberofdictionarydeletions(namely2).Inordertogetthebestbounds,wewillusethedictionaryobtainedbyapplyingthedynamizationtechniquebyAnderssonandThorup[2]tofusiontreesbyAndersson[1]andFredmanandWillard[7].Let!denotethememorywordlength(inbits)and#keysbethenumberofkeysstored.Then,asstatedin[2],thisdictionaryperformsboththelookupsandupdatesinworst-casetimeO(loglog#keys+log#keys log!).Sinceinourcasethewordlengthis!=O(logn)and#keys=O(logk+1n),wegettheboundofO(logloglogn)forallthethreeoperationsperformedonasingledictionary.ThisgivesusO(logloglogn)worst-casetimeforqueryandedgedeletionandO(logloglogn)amortizedtimeforinsertion.Finally,wenotethatinpracticalsituationsitmaybesucienttousedictionarieswhicharesimplerandeasierinimplementation,likesplaytreesforwhichwegetO(loglogn)amor-tizedtimebounds.Similarly,whenoneconsidersweakermodelthanthewordRAM,red-6 blacktreescanbeusedasdictionaries,givingO(loglogn)worst-casetimeforqueryandedgedeletionandO(loglogn)amortizedtimeforinsertion.References[1]A.Andersson.Fasterdeterministicsortingandsearchinginlinearspace.InProc.ofthe37thAnnualSymposiumonFoundationsofComputerScience(FOCS'96),pages135{141,1996.[2]A.AnderssonandM.Thorup.Tight(er)worst-caseboundsondynamicsearchingandpriorityqueues.InProc.ofthe32ndAnnualACMSymposiumonTheoryofComputing(STOC'00),pages335{342.ACMPress,2000.[3]P.BeameandF.F.Fich.Optimalboundsforthepredecessorproblemandrelatedproblems.J.Comput.SystemSci.,65:38{72,2002.[4]G.S.BrodalandR.Fagerberg.Dynamicrepresentationsofsparsegraphs.InProc.6thInt.WorkshoponAlgorithmsandDataStructures(WADS'99),volume1663ofLNCS,pages342{351,1999.[5]M.ChrobakandD.Eppstein.Planarorientationswithlowout-degreeandcompactionofadjacencymatrices.TheoreticalComputerScience,86(2):243{266,1991.[6]M.Dietzfelbinger,A.Karlin,K.Mehlhorn,andF.MeyeraufderHeide.Dynamicperfecthashing:Upperandlowerbounds.SIAMJ.Comput.,23(4):738{761,1994.[7]M.L.FredmanandD.E.Willard.Surpassingtheinformationtheoreticboundwithfusiontrees.J.Comput.SystemSci.,47:424{436,1993.[8]S.Kannan,M.Naor,andS.Rudich.Implicitrepresentationofgraphs.InProc.ofthe20thAnnualACMSymposiumonTheoryofComputing(STOC'88),pages334{343,NewYork,NY,USA,1988.ACMPress.[9] L.Kowalik.Fast3-coloringtriangle-freeplanargraphs.InS.AlbersandT.Radzik,editors,Proc.12thAnnualEuropeanSymposiumonAlgorithms(ESA2004),volume3221ofLectureNotesinComputerScience,pages436{447.Springer-Verlag,2004.[10] L.KowalikandM.Kurowski.Oraclesforboundedlengthshortestpathsinplanargraphs.ACMTrans.Algorithms,2(3):335{363,2006.[11]K.Mehlhorn,S.Naher,andM.Rauch.Onthecomplexityofagamerelatedtothedictionaryproblem.SIAMJ.Comput.,19(5):902{906,1990.7 [12]D.Morgan.Adynamicimplicitadjacencylabellingschemeforlinegraphs.InProc.9thInt.WorkshoponAlgorithmsandDataStructures(WADS'05),volume3608ofLNCS,pages294{305,2005.[13]C.S.J.A.Nash-Williams.Decompositionofnitegraphsintoforests.JournaloftheLondonMathematicalSociety,39:12,1964.8