InformationSciences181(2011)4253–4272 ContentslistsavailableatScienceDirect Information Sciences journal homepage: www.elsevier.com/locate/ins q Mental map preserving graph drawing using simulated annealing Chun-Cheng Lina, Yi-Yi Leeb, Hsu-Chun Yenb,⇑ aDepartmentofIndustrialEngineeringandManagement,NationalChiaoTungUniversity,Hsinchu300,Taiwan,ROC bDepartmentofElectricalEngineering,NationalTaiwanUniversity,Taipei106,Taiwan,ROC a r t i c l e i n f o a b s t r a c t Articlehistory: Visualizinggraphshasbeenstudiedextensivelyinthecommunityofgraphdrawingand Received26May2009 informationvisualizationovertheyears.Insomeapplications,theuserisrequiredtointer- Receivedinrevisedform19December2010 actwithagraphbymakingslightchangestotheunderlyinggraphstructure.Tovisualize Accepted2June2011 graphsinsuchaninteractiveenvironment,itisdesirablethatthedifferencesbetweenthe Availableonline6June2011 displays of the original and the modified graphs be kept minimal, allowing the user to comprehendthechangesinthegraphstructurefaster.Asthementalmapconceptrefers Keywords: tothepresentationofaperson’smindwhileexploringvisualinformation,thebetterthe Mentalmap mentalmapispreserved,theeasierthestructurechangeofagraphisunderstood.Itis Simulatedannealing somewhat surprising that preserving the user’s mental map has largely been ignored in Graphdrawing thegraphdrawingcommunityinthepast.Weproposeaneffectivemental-map-preserving graphdrawingalgorithmforstraight-linedrawingsofgeneralundirectedgraphsbasedon thesimulated-annealingtechnique.Ourexperimentalresultsandquestionnaireanalysis suggestthisnewapproachtobepromising. (cid:2)2011ElsevierInc.Allrightsreserved. 1.Introduction Graphsarewidelyrecognizedasapopularandusefulmodelforcapturingawidevarietyofreal-worldconceptsinappli- cationareassuchassocialnetworks,databases,discreteeventsystems,biologicalpathways,andmanymore[17].Througha nicevisualdisplayofagraph,theuserislikelytogainabetterinsightintotheinformationconveyedbythegraph.Asitis virtuallyinfeasibletomanuallydrawgraphsofhighcomplexityinstructureandsize,manysophisticatedautomaticdrawing methodsfordisplayingcomplicatedgraphshavebeendevelopedovertheyears(see,e.g.,[9,10,20]).Theinterestedreaderis referredto[1,21]fornicesurveysongraphdrawing. Inordertofindnicedrawings,graphdrawingalgorithmsareoftendesignedtomeetcertainaestheticcriteria(see,e.g., [31]), which specify the desired graphical structures and drawing properties. Such aesthetic criteria include minimizing thenumberofedgecrossingsorbends,minimizingthedrawingarea,maximizingthedegreeofsymmetry,andmanymore. Unfortunately,theproblemofsimultaneouslyoptimizingtwoormorecriteria,inmanycases,isNP-hard.Althoughthecom- putationalefficiencyaswellasthedrawingquality(i.e.,theextenttowhichtheoutputdrawingsconformtothedesired aestheticcriteria)remainthemostpopularmeasuresforjudgingtheeffectivenessofadrawingalgorithm,moreandmore attentionhasbeengiventotheissueofpreservingthementalmap[30]intheframeworkofinteractivegraphdrawing. In some applications, the user can interact with a graph by applying operations such as adding/deleting one or more nodes/edgestothegraphonaregularbasis.Tocopewiththistypeofdynamicallychanginggraphs,mostautomaticdrawing strategiesrelyonusinganexistingstaticgraphdrawingalgorithmtoredraweachmodifiedgraphfromscratch.Although q ApreliminaryversionofthisworkwaspresentedatAsiaPacificSymposiumonInformationVisualization2006,February1–3,2006,Tokyo,Japan. ⇑ Correspondingauthor. E-mailaddress:[email protected](H.-C.Yen). 0020-0255/$-seefrontmatter(cid:2)2011ElsevierInc.Allrightsreserved. doi:10.1016/j.ins.2011.06.005 4254 C.-C.Linetal./InformationSciences181(2011)4253–4272 suchstrategiesareconvenientandsimple,theysufferfromthefollowingdrawback.Sincetheuserisalreadyfamiliarwith the original drawing, applying an existing static graph drawing algorithm to the modified graph may render the output drawingill-behavedasfaraspreservingtheuser’s‘‘mentalmap’’isconcerned.Toseethis,considerFig.1.Fig.1(a)isthe drawingofagraphproducedbythewell-knownspringalgorithm[12].Supposeweaddnode4andconnectittotheremain- ingnodesofthegraph.Fig.1(b)and(c)aretwopossibledrawingsofthemodifiedgraphproducedbythespringalgorithm underdifferentsettingsofspringlengths.Clearly,Fig.1(c)isabetteroneasfaraspreservingthementalmapisconcerned, sinceitinheritsmoreinformationfromtheoriginaldrawing(i.e.,Fig.1(a)).Fig.2(originallygivenin[22])showsamore dramaticexampleillustratingtheimportanceofpreservingthementalmap.Theinitialgraph(Fig.2(a),excludingthethick curve)consistsofachainofquadrangles,whicharedisplayednicelybythe‘‘CircularwithRadial’’(CRforshort)layoutalgo- rithm[36].WhenweconnectthetwooutermostnodesbyasingleedgewhichismarkedbythethickcurveinFig.2(a),all thequadranglescollapseintooneinthelayoutredrawnbytheCRalgorithm(seeFig.2(b)).NotethatthebasicideaoftheCR algorithmistoplaceallthenodesonacircleandthenperformacrossingminimizationheuristic,whichstillresultsinat leastn/4crossings(wherenisthenumberofnodes)inthisexample.Unfortunately,thenewdrawingsuffersfromarather smallangularresolutionsuchthatitishardtorecognizetheoriginalstructure.AnalternativelayoutisdisplayedinFig.2(c) whichshowsacompleteringofquadranglesasitisconstructedfromtheinitialdrawing.Theabovetwoexamplessuggest thatusingastaticdrawingalgorithmtodrawamodifiedgraphfromscratchmayresultinsomethingthatlookscompletely differentfromtheoriginal,causingtheusertohavetospendaconsiderableamountofextratimetocomprehendthenew drawing. Eades,Lai,Misue,andSugiyama[13]werethefirsttoproposethementalmapconceptofgraphdrawing,whichcanbe thoughtofasthepresentationofaperson’smindwhileexploringvisualinformationofagraph.Whatmakesthepreserva- tionofthementalmapimportantingraphdrawingisthattheuserisabletoquicklyrecognizetheredrawnlayoutofthe modifiedgraph,basedonhis/herunderstandingoftheoriginallayout.Mostoftheexistingalgorithmsfortheproblemof preservingthementalmapfocusonpreservingtheorthogonalordering(see,e.g.,[25])oraddingconstraintstotheinputgraph (see,e.g.,[2,19]).Fortwonodesuandvinagraph,thepreservationoftheorthogonalorderingmeanstherelativeabove/ below and left/right positions of the nodes remain unchanged after the graph is redrawn. Preserving the user’s mental map is sometimes referred to as a stability problem(see, e.g., [26]). Recently, Brandes and Pampel [3] have showed that itisNP-hard topreservetheorthogonalorderingevenfor thesimplestgraphs(paths).Forspecificdrawingstylestaking mentalmappreservationintoaccount,thereaderisreferredto[22]forcirculardrawingand[16]foronlinedynamicgraph drawing.Experimentalstudiesconcerningtheeffectofpreservingthementalmapcanbefoundin[32,33,35].Theimpor- tance of preserving the mental map can also be found in applications including distributed mobile object environments [15],onlinelearningenvironments[37],andmore. Thebasicrequirementofagraphdrawingalgorithmistoproduceanaestheticallypleasinglayoutin2-Dor3-D,taking theabstractrepresentationofagraphastheinput.InDavidsonandHarel’swork[6],anice-lookinggraphdrawingreferstoa drawingwhich:(1)distributesnodesevenly,(2)makesedge-lengthsuniform,(3)minimizesedge-crossings,and(4)keeps nodesfromcomingtooclosetoedges.Todrawgraphsnicely,asimulatedannealing(SA)methodwasusedin[6]withthe energycostfunctiondesignedtorespecttheaboverequirements.Theimplementationoftheirworkallowstheusertoadjust therelativeweightsofcriteriaintheenergycostfunctionamongvariousparameters,thoughsomeofthesecriteriamaybe inconflictwitheachother.TheSAmethodoffersamoreflexiblewayofdrawinggraphsthanmanyotheralgorithms.Our simulatedannealinggraphdrawingmethodisbasicallybasedonthestrategyreportedin[6].Theinterestedreaderisalso referredto[7,8]forearlierworkofapplyingtheSAmethodtographdrawing. Astherearemanyintuitivefactorsthataffectthementalmap,BridgemanandTamassia[5]formallydefinedthoseintu- itivefactorsfororthogonaldrawingsandpresentedsomestatisticalresultstoevaluatetheireffectsonhumanperceptionof similarity.Theyusedmanymetricstomeasurethesimilaritybetweendifferentdrawings,andthenaskedrespondentsto evaluatethebestmeasuresthatreflecttheirperceptionofsimilarityamongasetoforthogonaldrawings.Finally,theyused astatisticalmethodtofindtherelationshipbetweenthesemeasurementsandusers’feelings,andsuggestedthefollowing formeasuringthedegreeofpreservationofthementalmap:ranking,orthogonalordering,k-matrix,unweightednearestneigh- borwithin,averagedistance,weightednearestneighborbetween,shape,andrelativedistance.Previousstudies([32,33,35]),on theotherhand,oftenapplystudent-basedsurveystoevaluatingtheperformanceofmental-map-preservinggraphdrawing algorithms. Inthispaper,weproposeamental-map-preservinggraphdrawingalgorithmforstraight-linedrawingsofgeneralundi- rectedgraphs,baseduponthesimulatedannealinggraphdrawingapproachof[6]withtheenergycostfunctionincorporating 1 1 4 1 4 2 3 2 3 2 3 (a) (b) (c) Fig.1. Anexampleofthementalmapproblem. C.-C.Linetal./InformationSciences181(2011)4253–4272 4255 (a) (b) (c) Fig.2. Anexampleofthementalmapproblemincirculardrawing[22]. sixcriteriaof[5]toreflecttheuser’smentalmap.Aspointedoutin[24],student-basedsurveysmaynotalwaysbeappropriate asfarasevaluatingthequalityofamental-mappreservinggraphdrawingalgorithmisconcerned.Hence,inourstudywe considernotonlyexperimentalevaluationbutalsostudent-basedquestionnaireanalysis,inordertobetterjustifytheclaimed performanceofourdesign.Theexperimentalresultsshowthattoacertainextent,ourapproachiscapableofpreservingthe drawingcontourofagraphandtherelativepositionsofnodeswhenapplyingavertex/edgeinsertion/deletionoperationtoa graph.Similarto[6],ourapproachisveryflexibleinthesensethatitallowstheusertoadjusttherelativeweightsofcriteria among various parameters. We also see from the experimental evaluation that there exists a trade-off between drawing graphsnicelyandpreservingthementalmap.Asforthequestionnaireanalysis,ahighpercentageofrespondentschoose themodifieddrawingproducedbyourapproachasthebestmental-map-preservingmodifieddrawingintheirminds. Themaincontributionsofthispaperaresummarizedasfollows: 1. Mostofthepreviousworkofpreservingthementalmapfocusedonhowtopreservetheorthogonalordering(see,e.g., [25])oraddconstraintstotheinputgraph(see,e.g.,[2,19]).Toourknowledge,therehavenotbeengraphdrawingalgo- rithmsaimingatpreservingthementalmaponstraight-linedrawingsofgeneralundirectedgraphswhileusingmore sophisticatedcriteriasimultaneously. 2. Our approach allows the user to adjust the relative weights of various criteria, making our drawing algorithm very flexible. 3. Bytakingsamplesamongagroupofstudentswithbasicknowledgeofgraphsandgraphdrawing,BridgemanandTam- assia[5]suggestedanumberofgoodcriteriasuitableforcapturingthenotionofthementalmap.Ourgraphdrawing approachincorporatesthecriteriaof[5]intotheenergycostfunctionofasimulatedannealinggraphdrawingalgorithm topreservethedrawingcontourofagraphandtherelativepositionsofnodeswhenmodifyingthegraph. 4. Ourapproachobtainsthelocationofeachnodeineachiteration,resultinginasmoothprocessfromtheinitialdrawingto thefinaldrawing–adesirablepropertyininformationvisualization. Therestofthispaperisorganizedasfollows.InSection2,weintroducethesimulatedannealinggraphdrawingmethod, uponwhichourgraphdrawingalgorithmisbased.Section3involvesthedesignofanenergycostfunctiontopreservethe mentalmap.Section4showstheexperimentalresultsofourapproach.Section5givesaquestionnaireanalysisofourap- proach.AconclusionisgiveninSection6. 2.Preliminaries Asmentionedintheprevioussection,thefourrequirementsofa‘‘nicedrawing’’includedistributingnodesevenly,making edge-lengthsuniform,minimizingedge-crossings,andkeepingnodesfrombeingtooclosetoedges.Inthissection,wefirst introducethe generalframeworkof simulatedannealing,and then showhow todraw graphsnicelyusingthe simulated annealinggraphdrawingalgorithmproposedbyDavidsonandHarel(DHforshort)[6]. 2.1.Introductiontosimulatedannealing Simulatedannealing(SA)[23]isageneralizationoftheMonteCarlomethodforexaminingtheequationsofstatesand frozenstatesofn-bodysystems.SAisflexibleandhassuccessfullybeenappliedtosolvingvariouscombinationaloptimiza- tionproblems,includingsolvingthemaximumcliqueproblem[18],determiningthethicknessofagraph[28],etc.Itallows ‘‘uphill’’moves–movesthatspoil,ratherthanimprove,thetemporarysolution.ThisuniquefeatureallowsSAtoescapefrom alocalminimalsolution,thoughitisnotguaranteedthataglobalminimumcanbereachedeventually. ThebasicstepsofSAaregivenasfollows.ThefirststepofSAistogenerateaninitialconfiguration(eitherrandomlyor heuristicallyconstructed)andinitializetheso-calledtemperatureparameterT.Thenthefollowingisrepeateduntiltheter- minationconditionissatisfied.Anewsolutionfromtheneighborhoodofthecurrentsolutionisselectedrandomly.Theen- ergycostofthenewsolutioniscalculatedovertheobjectivefunctionandTisdecremented.Let/and/0denotethecurrent andnewenergycosts,respectively.If/0</,thenewsolutionwillbeaccepted.If/0>/,thissolutionwillbeacceptedwitha probabilityfromaBoltzmanndistributionfunctione(cid:2)ð/0(cid:2)/Þ=kT,wherekistheBoltzmannconstant.Weassumek=1.Thiskind of‘‘uphill’’moveswillbefewerasSAproceeds,becauseTdecreasesaftereachiteration. 4256 C.-C.Linetal./InformationSciences181(2011)4253–4272 2.2.Thegraphdrawingalgorithmusingsimulatedannealing TheinputoftheDHalgorithmisagraphG=(V,E),whereVisthesetofnodesandEisthesetofedges.EachnodeinVhas auniqueindex.ThekeydesigninSAistheenergycostfunction,onwhichtheefficiencyofthealgorithmhighlydepends.A goodenergycostfunctionshouldreflectthepropertiesofnice-lookingdrawings.ThecriteriausedbytheDHalgorithminthe designoftheenergycostfunctionaregivenasfollows,inwhichk ,...,k arenormalizingfactorsthatdefinetherelative 1 5 importanceofeachcriterioncomparedtotheothers. 1. Nodedistribution:"(i,j)2V(cid:3)V,a ¼k =d2 isaddedsothatnodesarespreadevenly,whered isthedistancebetween i;j 1 i;j i,j nodesiandj. 2. Borderlines:"i2V, m ¼k ð1=r2þ1=l2þ1=t2þ1=b2Þisadded so thatnodesarepreventedfrombeingtooclosetothe i 2 i i i i borderlines,wherer,l,t,b standforthedistancesbetweennodeiandtheright,left,topandbottomsidesofthedrawing i i i i frame,respectively. 3. Edgelengths:TheDHalgorithmusesc ¼k d2,whered isthelengthofedgek.Instead,ouralgorithmusesr=k s2,where k 3 k k 3 s is the standard deviationof edge lengths, becausethe utilizationof c tends to producedrawingswith shorteredge k lengthswhichmaynotbedesirableinsomecasesofpreservingthementalmap. 4. Edgecrossings:"(k,l)2E(cid:3)E,wesimplyaddtheterme whichequalsk f f ifedgeskandlcross;e =0otherwise,where k,l 4kl k,l f (resp.,f)istheweightattributedtoedgek(resp.,l),representingtheimportanceofedgek(resp.,l)notintersecting k l otheredges.Notethatk ¼k =g2 whereg isthegivenminimumdistancebetweennodesandedges. 4 5 min min 5. Node-edgedistances:Fornodeiandedgekwithdistanceg ,thetermh ¼k =g2 isadded. i,k i;k 5 i;k Inlightoftheabove,theenergycost/ofadrawingofgraphG=(V,E)iscomputedasfollows: /¼ X a þXm þrþ X e þ X h ; i;j i k;l i;k ði;jÞ2V(cid:3)V;i–j i2V ðk;lÞ2E(cid:3)E;k–l;kRNðlÞ ði;kÞ2V(cid:3)E;kRNðiÞ whereweslightlyabusethenotationN((cid:4))withN(l)denotingthesetofneighboringedgesofedgel,andN(i)representingthe setoftheedgesincidenttonodei.Infact,onlyanodemovesfromtheoriginalconfigurationtothenewconfigurationineach stepofthealgorithm.Fornotationalconvenience,thenodeintheoriginal(resp.,new)configurationiscalledp(resp.,p0).If thecalculationofacomponenttakesp(resp.,p0)intoaccount,itimpliesthatthecomponentbelongstotheenergycostfunc- tionoftheoriginal(resp.,new)configuration.Therefore,thedifferenceoftheenergycostsbetweentheoriginalandthenew configurations can be computed more efficiently as follows: /0(cid:2)/¼Pðp;jÞ2NðpÞðap0;j(cid:2)ap;jÞþðmp0(cid:2)mpÞþðr0(cid:2)rÞþ ðPðk;lÞ2Nðp0Þ(cid:3)E;k–lek;l(cid:2)Pðk;lÞ2NðpÞ(cid:3)E;k–lek;lÞþPk2E;kRNðpÞðhp0;k(cid:2)hp;kÞ, where r0 is the variance of the edge lengths in the new configuration. 3.Ourmental-map-preservinggraphdrawingalgorithm TheworkofBridgemanandTamassia[5]canberegardedasthemostcompleteworkonmentalmapmetrics.Theypre- sented the results of a user study based on several similarity measures between orthogonal drawings, which reflect the user’smentalmapaccordingtotheuser’sdirectresponses.Asaresult,ourapproachtothementalmappreservationprob- lemistoincorporatesomeofthebestmeasuresusedin[5]forstraight-linedrawingsintotheDHalgorithm.Inwhatfollows, weintroducethemaincomponentsofouralgorithm. 3.1.Configuration GivenagraphG=(V,E),aconfigurationspecifiestheplacementofnodesinVonaplane,assumingthatedgesaredrawnas straight-linesegments,andGisdrawnwithinagivenrectangularframe.Ifthereisnoaprioriinformationaboutthenodes, weplacethenodesrandomlywithinthedrawingframe.TheneighborhoodofaconfigurationCisaconfigurationthatisob- tainedfromCbychangingthelocationofacertainnode.Ineachiteration,wechooseanodearbitrarilyandthenassignita newrandomlocationwithinacircleofdecreasingradiusarounditsoriginallocation.Thesettingofadecreasingradiusmay acceleratetheconvergenceofthealgorithm[6]. 3.2.Thementalmapcostfunction Inordertopreservethementalmap,wedefinethementalmapcostMbetweentheoriginaldrawingDandthemodified drawingD0toreflectthesimilarityofdrawingsbasedoncertain’’components’’usedintheexperimentsreportedin[5].Note thatthevalueofeachcomponentinMisnonnegative,andhenceM=0impliesthatthetwodrawingsareviewedasthesame drawings.AlargermagnitudeofMmeansahigherdegreeofdifferencebetweenthetwodrawings. Notethatallthemeasuresproposedin[5]exceptthe‘‘Shape’’measurearedefinedintermsofpointsets,whicharede- rivedfromtheedgesandnodesofthegraphinsteadoftheedgesandnodesthemselves.Eachpointintheoriginaldrawing hasacorrespondingpointinthemodifieddrawing.Althoughthereareavarietyofwaystoselectthepointsetsasindicated C.-C.Linetal./InformationSciences181(2011)4253–4272 4257 in[5,27],inthispaperwechoosethepointsetincludingallthenodesofthegraph,becausethereisatmostanodemovingin eachtrialofourSAalgorithm–itsufficestocomputeonlythevaluesrelatedtothemovednode. Weadoptthenotationsoriginallyusedin[5]inoursubsequentdiscussion.PandP0alwaysrefertothepointsetsofdraw- ingsDandD0,respectively.SinceonlyonepointmovesineachtrialofourSAalgorithm,weletpdenotethemovedpoint,and p02P0isthecorrespondingpointofp(andviceversa).ThenumberofnodesinVisn.Recallthatd denotestheEuclidean p,q distancebetweenpointspandq. Inthefollowing,wedefinecomponentsusedinM,inwhichg ,...,g arethenormalizingfactorsthatdefinetherelative 1 6 importanceofacriterioncomparedtotheothers. 1. Ranking:Consideringthattherelativehorizontalandverticalpositionsofanodeshouldnotvarytoomuch,weaddtoM thecomponent g rankðP;P0Þ¼ 1 minfjrightðpÞ(cid:2)rightðp0ÞjþjaboveðpÞ(cid:2)aboveðp0Þj;UBg; UB whereUB=1.5(jPj(cid:2)1);right(p)andabove(p)arethenumbersofpointstotherightandaboveofp,respectively.Notethat theupperboundUBissetto1.5(jPj(cid:2)1)ratherthan2(jPj(cid:2)1)becausetheprobabilityunderwhichtheactualmaximum valuehappensisverysmall. 2. k-matrix: Two point sets P and P0 have the same order type if, for every triple of points (p,q,r), they are oriented counterclockwiseifandonlyif(p0,q0,r0)arealsoorientedcounterclockwise.Thek-matrixisdesignedtopreserveanorder typeofpoints.Hereweuseasimplifiedversion,whichcalculatesthenumberofnodestotheleftoftwodesignatednodes. Letk(p,q)bethenumberofpointsinPtotheleftofthedirectedlinefromptoq.WeaddtoMtheterm g X lambdaðP;P0Þ¼ 2 jkðp;qÞ(cid:2)kðp0;qÞj; UB q2P;q–p whereUB¼njðn(cid:2)1Þ2k. 2 3. Unweighted nearestneighbor within: This componentcapturesthe intuitive idea thata node’s nearest neighborshould remainitsclosestneighborafterthegraphisredrawn.Letnn(p)bethenearestneighborofpinPandnn(p)0bethecor- respondingnodeinP0 tonn(p).Thecomponentisdefinedas: nnwðP;P0Þ¼ g3 XminfjnearerðpÞj;1g; UB p2P whereUB¼jPj;nearerðpÞ¼fqjdp0;q<dp0;nnðpÞ0;q2P;q–p;q–nnðpÞg. 4. Weightednearestneighborbetween:Thisconceptisbasedontheassumptionthatanodeshouldnotmovetoofarfromthe originalposition,andhenceitsnewpositionshouldbeasclosetoitsoriginalpositionaspossible.Asthenewdrawingis presented,theuseroughttobeabletofindacertainnodewhichisrecordedinhis/hermentalmap.Thecomponentis definedas: g X nnbðP;P0Þ¼ 4 jnearerðpÞj; UB p2P whereUB¼jPjðjPj(cid:2)1Þ;nearerðpÞ¼fqjdp;q<dp;p0;q2P;q–pg. 5. Shape:Thiscomponentrecordstheedgeorientationofthegraph.Notethattheoriginalmeasurein[5]wasdesignedfor orthogonaldrawings.Tocopewithstraight-linedrawings,themeasureismodifiedasfollows: g X shape¼ 5 editsðe;e0Þ; UB e2E whereUB=jEjand (cid:2)1; if theincludedanglebetweene and e0 issmall; editsðe;e0Þ¼ 0; otherwise; inwhiche0isthecorrespondingedgeofeinD0.Notethatwhethertheincludedanglebetweentwoedgesissmallisdeter- minedbyusers. 6. Average relative distance: The average relative distance is the average of the distances from p to the remaining nodes. Therefore,weaddtheterm rdistðP;P0Þ¼nðng(cid:2)6 1Þ Xjdp;q(cid:2)dp0;qj: p;q2P Althougheightbestsimilaritymeasuresfororthogonaldrawingsweresuggestedin[5],onlysixofthemareincludedin ourmentalmapcostfunction.Thetwomeasuresdesignedforpreservingtheorthogonalordering(calledOrthogonalOrdering 4258 C.-C.Linetal./InformationSciences181(2011)4253–4272 in[5])ofnodesandminimizingthemovementdistanceoftheselectednode(calledAverageDistancein[5])areexcludedin ourworkforthereasonsgivenbelow.First,ifsomenewnodesandedgesarearbitrarilyaddedtoadrawingcausingnew edgecrossings,thenthosenewedgecrossingscannotbeeliminatedbyanalgorithmwhichpreservestheorthogonalorder- ingofnodes.Also,minimizingthenumberofedgecrossingsisusuallyregardedasthemostimportantaestheticcriterionin graphdrawing[29].Therefore,weexcludethemeasureofpreservingtheorthogonalorderingofnodes.Asourexperimental resultsindicate,ahighdegreeoforthogonalorderofnodesisstillpreservedwithouttakingthismeasureintoaccount.On theotherhand,themeasureofminimizingthemovementdistanceoftheselectednodeisexcludedbecauseithasbeenim- pliedbytheselectionoftheneighborhoodofaconfigurationintheSAalgorithm.Inaddition,itcanalsobeviewedasbeing achievedinpartbytheedgelengthcomponentintheenergycostfunction.Finally,theexclusionofthetwomeasuresresults inamoreefficientSAalgorithm,asexpected. 3.3.Ouralgorithm Ouralgorithm,describedinAlgorithm1,isalmostthesameastheDHalgorithmexcepttheifconditionatstep2(b)is replaced by the conjunction of the original condition and M0< (cid:2) , where M0 is the value of the mental map function at M thenewdrawingD0 and(cid:2) isthemaximaltoleranceofthementalmapcostthatacceptsthenewdrawingD0. M Algorithm1SA_MENTAL_MAP 1:denotetheinputdrawingasDandsetaninitialtemperatureT ; 0 2:fori-thstage,denotethetemperatureasT,andrepeatthefollowingfor30jVjtrials: i (a) randomlyselectapointp2P(notethatPisthepointsetofD);selectanewpositionp0 inadecreasing-radius circlearoundp;letD0 beanewdrawingwhichisalmostthesameasDexceptpisreplacedbyp0; (b) let/and/0bethevaluesoftheenergycostfunctionatDandD0respectively;letM0bethevalueofthemental mapfunctionatD0;if(/0(cid:2)/<0orrandom<e(cid:2)ð/0(cid:2)/Þ=Ti)and(M0<(cid:2)M),thensetD D0; 3:T =cT; i+1 i 4:iftheterminationconditionissatisfied,stop;otherwisegotostep2. TheenergycostandthementalmapcostareconsideredindependentlyinAlgorithm1,becausetheyservefordifferent purposes.Theformerisusedfordrawinggraphnicely,whereasthelatterisusedforpreservingthementalmap.Eachcom- ponentinthementalmapcostcanbenormalizedwiththeupperboundofvalue1exceptforthe‘Averagerelativedistance’ component(whichisofsmallvaluewhilepreservingthementalmap),andhence,itiseasytocontroltherelativeweightsof thesecomponentstopreservethementalmap.However,thevaluesofthecomponentsintheenergycostaresodiversethat itisdifficulttoadjusttheirweightstogenerateanicedrawingwhenthealgorithmconverges.Consolidatingthetwocosts withdifferentscalesintoonedoesnothelp,sinceitbecomesmoredifficulttoadjusttheweightstoreachconvergence,and moreimportantly,thegoalsassociatedwiththetwocostsarelikelytobeinconflictwitheachother.Asaresult,theenergy costandthementalmapcostareconsideredindependentlyinAlgorithm1. AlsonoteinAlgorithm1thattheSAschemeisonlyappliedtotheenergycost,becauseitwouldbedifficulttoachieve convergence if applyingto the two costs simultaneously. In addition,we believe that in most cases a user prefers a nice drawingwithareasonablepreservationofthementalmapthanabaddrawingwithawell-preservedmentalmap.Conse- quentlyweapplytheSAschemeonlytotheenergycost. ThecoolingscheduleusedinAlgorithm1followsthebasicgeometricscheduledescribedin[23]. 1. Initialtemperature:Wesettheinitialtemperaturehighenoughinorderforanyconfigurationtoworkasthestartingpoint ofthealgorithm.Alowerinitialtemperaturecanbechoseninthebeginning,iftheinitialconfigurationisknowntobear someresemblancetothedesiredfinalresult. 2. Temperaturereduction:Thetemperaturereductionstagedetermineswhentochangethetemperatureandhowtochange it.Thisstageaffectsthenumberofmovesateachtemperatureandtherangeofeachmove.Typicalapplicationssetthe numberoftrialsateachtemperaturetobepolynomialinthesizeoftheinput.Inoursetting,thenumberofmovesateach temperatureissetto30jVj,suggestedbytheDHalgorithm.Thecoolingscheduleruleisgeometric.IfT denotesthetem- i peratureatthei-thstage,thenthetemperatureatthenextstageisT =cT,wherecisarealnumberbetween0.6and i+1 i 0.95.SimilartotheDHalgorithm,weletc=0.75.Therangeofeachmovedecreaseswhenthetemperaturereduces.Ifthe rangeofmovementatthei-thstageisR,thentherangeofmovementservingforthenexttemperatureiscR,whichaccel- eratestheconvergenceofthealgorithm. 3. Termination condition: This is to decide when to stop the algorithm. Commonly used termination conditions include: stopping the algorithm when the solution is not modified after several consecutive stages, or fixing the number of stages to be a constant. To carry out a fair comparison between our algorithm and the DH algorithm, the number ofstagesinourexperimentsissettoten,whichisidenticaltothatusedin[6].Experimentalresultshaveshownthat, in many cases, substantial changes only happen in the early stages; subsequent stages yield only marginal improvement. C.-C.Linetal./InformationSciences181(2011)4253–4272 4259 Nowweturnourattentiontothetimecomplexityofouralgorithm.AsouralgorithmisbuiltupontheDHalgorithm,it sufficestoconsiderthetimecomplexityoftheDHalgorithm.Asindicatedin[6],theDHalgorithmrunsinO(jVj2jEj)time becausethenumberofstagesisaconstant,thenumberoftrialsineachstageis30jVj,andeverytermintheenergycost functioncanbecomputedinO(jVjjEj)time.Also,itisobviousthateverycomponentofthementalmapcostcanbecomputed intimenomorethanO(jVjjEj).Hence,Algorithm1alsorunsinO(jVj2jEj)time. 4.Experimentalresults Thissectionshowsfourexperimentalresultsforevaluatingtheperformanceofourmental-map-preservinggraphdraw- ingalgorithm.Ineachexperiment,theinitialdrawingoftheinputgraphisarandomdrawing,andthenanicedrawingis producedbytheDHalgorithm.Subsequently,liketheexperimentdesignedin[5],thegraphismodifiedbyaddingtwonodes with two and four incident edges, respectively. The locations of the two nodes are decided randomly, and the other end pointsofthesixedgesareconnectedtoarbitrarynodesintheoriginalgraph.Finally,wecomparethedrawingsofthemod- ifiedgraphproducedbyouralgorithmandtheDHalgorithm. OurprototypesystemrunsonanIntelCore2DuoCPUE8400@3.00GHzPCwith3.00GBmemory.Thestatisticsonthe runningtimeoftheDHalgorithmandouralgorithmwithrespecttofourexamplesaregiveninTable1.Ouralgorithmrunsa bitslowerthantheDHalgorithmsincemorecriteriaaretakenintoaccount.Liketheconclusiongivenin[6]regardingtheDH algorithm,ouralgorithm,fromapracticalviewpoint,isonlysuitablefordrawingdynamicgraphsofsmall-size. Inordertoseehowtherunningtimeofouralgorithmincreaseswhenthesizeoftheinputgraphgrows,weconsidersev- eralgraphstakenfromthewell-knowngraphdataset–RomeGraphs,1whichareoriginatedfrompracticalapplicationsranging fromdataflowdiagramstoPetrinets.ThelargestgraphintheRomeGraphdatasethas110nodes.Weconductexperimentson thefirst100graphsintheRomeGraphset,andrecordtherunningtimeofredrawingthemodifiedgraphofeachofthe100 graphs.Tothisend,weaddtwonodes,onewithtwoedgesandtheotherwithfouredges,tothenicedrawingofeachgraph. TheaveragerunningtimeversusthenumberofnodesisplottedinFig.3.Itturnsoutthatittakesabout25storedrawa100- nodegraph,whichissomewhatunacceptableforapplicationsthatrequirereal-timeresponses. ConsiderthefirstsimpleexperimentshowninFig.4.AninitialrandomdrawingisgiveninFig.4(a).AfterapplyingtheDH algorithmunderdifferentsettingsofparameterk ,threepossiblenice-lookingdrawingsaredisplayedinFig.4(b),inwhich 4 (i)–(iii)illustratehowlesspenaltiesonedgecrossingsaffecttheoutcomesofthealgorithm.Nowwearbitrarilyaddtwonew nodes7and8toeachofthethreedrawings,wherenode7isconnectedtonodes4and5,andnode8isconnectedtonodes1, 3,4,and5(seeFig.4(c)).Themodifiedgraphsareredrawnbyouralgorithm,asshowninFig.4(d).Forthesakeofcompar- ison,considerFig.4(e)and(f).Fig.4(e)showsthethreedrawingsobtainedbyapplyingtheDHalgorithmtodrawingsin(i)– (iii)inFig.4(c)directly.Ontheotherhand,Fig.4(f)displaystheoutcomesofapplyingtheDHalgorithmtorandomdrawings ofgraphsassociatedwith(i)–(iii)inFig.4(c)underthesamesettingofparameters. InviewofFig.4(c)and(d),itisobviousthatouralgorithmiscapableofgeneratingnicedrawings.Itisalsonothardtosee fromFig.4(b)and(d)thatthecontoursofdrawingsandtherelativepositionsofnodesareverysimilarinthetwosetsof drawings,suggestingthatouralgorithmpreservesahighdegreeofthementalmap.Incontrast,thedrawingsinFig.4(e) and(f)producedbytheDHalgorithmsharelittlesimilaritywiththoseinFig.4(b). Ifweremovetheadditionalnodes7and8andtheiradjacentedgesfromthedrawingsinFig.4(c)–(f),itbecomesclearer whythedrawingsinFig.4(d)preservebettermentalmaps.SeeFig.5.Sincethementalmapcriteriaandtheaestheticcriteria areofteninconflictwithoneanother,thereisatrade-offbetweenpreservingahighdegreeofthementalmapandachieving someaestheticcriteriasuchasminimizingthenumberofedgecrossings.Fortunately,ouralgorithmallowstheusertoadjust the weights between different criteria, in order to fit his/her drawing requirements. For example, node 5 in Fig. 5(b) (i) (whichisproducedbyouralgorithm)doesnotpreserveitsoriginalrelativeposition(i.e.,notsatisfiableasfaraspreserving thementalmapisconcerned).ConsiderFig.4(c)(i).Tokeepnode5inthesamerelativeposition(bychangingthesettingsof parameters),node8cannotmoveintothequadrangleboundedbynodes1,2,3,and6,whichinturn,inducesadditionaledge crossings,thoughnode8,inthiscase,keepsitsoriginalrelativepositionintact. Inthesecondexperiment,theinitialgraphFig.6(b)isacompletedegree-fourtreewith21nodesand20edges.Takingthe initialrandomdrawingshowninFig.6(a)astheinput,theDHalgorithmoutputsthedrawinginFig.6(b).Fig.6(c)showsthe graphtransformedbyinsertingnodes22and23(togetherwithsixedges)intothetree.Fig.6(d)isthedrawingproducedby applyingouralgorithmtothedrawinginFig.6(c).WecanobservethattherearenodrasticdifferencesbetweenFig.6(b)and (d).Fig.6(e)(resp.,Fig.6(f))isthedrawingproducedbyapplyingtheDHalgorithmtothedrawinginFig.6(c)(resp.,aran- domdrawingofthemodifiedgraph).AlthoughthedrawinginFig.6(f)almosthasnocommonpointswiththedrawingin Fig.6(b),thereareonlytwoedgecrossingsinthedrawinginFig.6(f),whichachievestheminimumnumberofedgecrossings amongallpossibledrawingsofthemodifiedgraph. Fig.7(a)–(d)simplydisplaythedrawingsafterremovingtheadditionalnodes22and23fromFig.6(c)–(f),respectively.By comparingFig.7(b)withFig.7(a),itcanbeobservedthatthedrawinginFig.7(b)almostpreservestheshapeandstructureof thedrawinginFig.7(a)exceptthattheorderingsofnodepairs(6,7)and(15,16)aredifferent.Asmentionedearlier,preserv- ingthementalmapandoptimizingsomeaestheticcriteriamaynotbeachievedsimultaneously.Thereasonwhytheorder- 1 http://www.dia.uniroma3.it/(cid:5)gdt/. 4260 C.-C.Linetal./InformationSciences181(2011)4253–4272 Table1 ThestatisticsonthetotalrunningtimeoftheDHandouralgorithms. Problem jVj jEj DH our Fig.4(c) 8 15 0.1453s 0.1781s Fig.6(c) 23 26 0.7206s 0.9837s Fig.8(c) 65 68 5.7500s 8.5030s Fig.10(c) 102 130 19.3353s 28.1252s 35 ec.) 30 me (s 25 ng ti 20 ni un 15 e r ag 10 er av 5 0 0 20 40 60 80 100 120 number of nodes Fig.3. Plotofaveragerunningtimeversusnumberofnodes. ingsofthetwopairsofnodesaredifferentisthatthedrawinginFig.7(b)correspondstothedrawinginFig.6(d)whichin- ducesfeweredgecrossingsthanthecasewhentheorderingsarenotmodified.IfwecompareFig.7(c)withFig.7(a)assum- ingnode1tobetherootofthetree,thesubtreesrootedatnodes2,3,and4lookdifferentalthoughthecounterclockwise orderingofthechildrenofnode1ispreserved.BycomparingFig.7(d)withFig.7(a),itisobviousthatthementalmapisnot preserved. Wealsocarryoutanexperimentonacompletebinarytreewith63nodesand62edges.Similartothepreviousexper- iments,Fig.8(a)–(f)showarandomdrawingoftheinitialgraph,thenicedrawingproducedbytheDHalgorithm,thedraw- ing ofthe modifiedgraphby addingtwo nodes, themodifieddrawingproducedby our algorithm,themodifieddrawing producedbytheDHalgorithm,andthedrawingproducedbyapplyingtheDHalgorithmtoarandomdrawingofthemod- ified graph, respectively. Fig. 9(a)–(d) show the drawings after the two added nodes are removed from Fig. 8(c)–(f), respectively. IfwelookatFig.8(b)and(d),thereareonlyslightmodificationsbetweenthetwodrawings,asonlynodepairs(7,15), (32,33),(36,37),(40,41),(58,59),and(60,61)areofdifferentorderings.Thisismainlycausedbythefactthatthemeasure ofpreservingtheorthogonalorderingofnodesisexcludedinourmentalmapcostfunction.If,ontheotherhand,sucha measureisincluded,thenadditionaledgecrossingsbecomeinevitable,causingtheoutputtobelessattractivefromtheaes- theticviewpoint.Incontrast,althoughthedrawinginFig.8(e)hasfeweredgecrossingsthanthedrawingproducedbyour algorithm,itdiffersalotincomparisonwiththeoriginaldrawingillustratedinFig.8(b),especially,inthelefthalfofthe drawing.Assuming node 1tobe theroot of thetree, the subtreesrootedat nodes8, 9,14, 20, and 26in thedrawing of Fig.8(a)aretotallydifferentfromthoseinthedrawingofFig.8(e).AsforFig.8(f),thedrawinghasonlyoneedgecrossing, whichachievestheminimumnumberofedgecrossingsamongallthepossibledrawingsofthemodifiedgraph.FromFig.9, theadvantageofourdrawingalgorithmbecomesapparentwhentheprimaryconcernisplacedonthepreservationofthe mentalmap. Finally,wepresentanexperimentcarriedoutonagraphwith100nodesand124edgeschosenfromtheRomeGraphdata set.Similartothepreviousexperiments,Fig.10(a)–(f)showarandomdrawingoftheinputgraph,thenicedrawingproduced bytheDHalgorithm,thedrawingofthemodifiedgraphbyaddingtwonodesandsixedges,themodifieddrawingproduced byouralgorithm,themodifieddrawingproducedbytheDHalgorithm,andthedrawingproducedbyapplyingtheDHalgo- rithmtoarandomdrawingofthemodifiedgraph,respectively. AlthoughthedrawingsinFig.10aremorecomplicated,thereisacommonfeaturein(b)–(e)thatmostnodesarecentral- izedinthebottomrightpartofthewholearea.BycomparingFig.10(b)withFig.10(d)and(e),itisclearthatdrawing(d)by ouralgorithmpreservesthecontouroftheoriginaldrawing(b),butdrawing(e)bytheDHalgorithmdoesnothavethis property. Figs.11and12showhowourSAalgorithmiscapableofescapingfromlocalminima.Fig.11givestheplotoftheenergy costversusthenumberoftrialsintheprocessofapplyingtheDHalgorithmtoFig.8(c)toyieldFig.8(e).RecallfromAlgo- rithm1thatthenumberoftrialsisequalto30jVjmultipliedbythenumberofexecutedstagesplusthenumberoftrials executedatthecurrentstage.Fig.11illustratesthatsome‘uphill’movescansuccessfullyescapefromlocalminimabyusing theDHalgorithm.Toseethis,considertheenergycostsinthewindowbetweenthe16500-thtrialandthe18000-thtrialin C.-C.Linetal./InformationSciences181(2011)4253–4272 4261 2 3 2 1 1 2 6 1 4 4 2 6 5 6 5 4 6 3 1 3 4 3 (i) (ii) (iii) 5 5 (a) the initial drawing.(b) applying the DH algorithm to (a) under different settings of parameters. 3 8 8 8 2 1 2 6 1 4 7 2 7 67 5 4 6 5 3 1 4 3 (i) (ii) (iii) 5 (c) adding nodes 7 and 8 to each of the three drawings in (b). 3 8 8 1 2 6 2 7 4 2 1 7 5 4 5 6 8 1 6 3 3 5 7 4 (i) (ii) (iii) (d) applying our algorithm to each of the three drawings in (c). 3 7 1 2 6 4 1 6 7 2 8 5 4 5 1 4 6 2 3 5 8 8 7 (i) (ii) (iii) 3 (e) applying the DH algorithm to each of the three drawings in (c). 6 4 3 4 8 1 3 7 5 8 5 2 3 2 7 1 5 6 2 1 8 4 6 7 (i) (ii) (iii) (f) applying the DH algorithm to a random drawing of the graph in (c). Fig.4. Theexperimentforaninitialcubicgraphwithsixnodes. Fig.11.Thecurveoftheenergycostbetweenthe16500-thtrialandthe17000-thtrial(‘plain’-moving)isalmostflat.How- ever,‘downhill’-movingfollowedby‘uphill’-movingnearthe17000-thtrialyieldsabettersolution,whichillustratesthe advantageoftheSAmethod. 4262 C.-C.Linetal./InformationSciences181(2011)4253–4272 3 2 1 2 6 1 4 2 6 5 4 6 5 3 1 4 3 (i) (ii) (iii) 5 (a) Figure 3(c) without nodes 7 and 8. 3 1 2 2 6 4 1 2 5 5 6 4 6 3 1 3 4 (i) (ii) (iii) 5 (b) Figure 3(d) without nodes 7 and 8. 1 3 1 2 4 2 6 6 5 6 4 4 5 1 2 3 5 (i) (ii) (iii) 3 (c) Figure 3(e) without nodes 7 and 8. 4 3 6 1 5 4 2 3 3 5 5 6 2 2 1 1 4 6 (i) (ii) (iii) (d) Figure 3(f) without nodes 7 and 8. Fig.5. Removingnodes7and8fromFig.4(c)(d)and(f). Fig.12illustratesa‘‘costversustrialnumber’’plotintheprocessofyieldingFig.8(d)fromFig.8(c)usingouralgorithm. Fig.12(a)and(b)givetheplotsoftheenergycost/andthementalmapcostM,respectively,againstthenumberoftrials. Fig.12(c)and(d)givedetailedviewsofthedotted-lineboxesin(a)and(b),respectively.Notethatthetolerance(cid:2) ofMis M setto0.3inthisexperiment,causingtheconfigurationwiththevalueofMlargerthan0.3toberejectedinFig.12(b)and(d), whichinturnyieldsaconsiderableamountof‘plain-moving’inFig.12(a).FromFig.12(a)and(c),weobservethatouralgo- rithm,anSA-basedmethod,alsohastheabilitytoescapefromlocalminimainmanycases.Itshouldbenotedthatthemax- imumenergycostinFig.11(undertheDHalgorithm)islargerthanthatinFig.12(a)(underouralgorithm)byapproximately 4billion.Suchadisparityisduetothefactthattheweightofthemeasureofpenalizingthenumberofedgecrossings(oneof themostimportantmeasuresinproducinganicedrawing)issettoahugevalue.Inordertopreservethementalmap,our algorithmproducesthedrawinginFig.8(d)withthreemoreedgecrossingsthanthedrawinginFig.8(e),causingtheextra4 billioninthecorrespondingenergycost. Asouralgorithmisbasedonthestochasticsimulatedannealing(SSA)strategy,itisnotsurprisingthatouralgorithmis somewhatslowwhenapplyingtolargegraphs.Apossiblewaytoimprovetheperformanceofouralgorithmistoconsider usingthedeterministicsimulatedannealing(DSA)technique[11]instead,whichrunsfasterinmanyreal-worldproblemsof largescalewithoutsacrificingtheaccuracyofthesolution.ThebasicideaofDSAistouseahyperbolictangentfunctionto transformdigitalvaluesoftheenergycostinSSA(seeFig.11)intoanalogvalues.DesigningaDSA-basedmental-map-pre-
Description: