dot语言手册

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

DrawinggraphswithdotEmdenR.GansnerandEleftheriosKoutsofiosandStephenNorthNovember2,2010Abstractdotdrawsdirectedgraphsashierarchies.Itrunsasacommandlinepro-gram,webvisualizationservice,orwithacompatiblegraphicalinterface.Itsfeaturesincludewell-tunedlayoutalgorithmsforplacingnodesandedgesplines,edgelabels,“record”shapeswith“ports”fordrawingdatastruc-tures;clusterlayouts;andanunderlyingfilelanguageforstream-orientedgraphtools.BelowisareducedmoduledependencygraphofanSML-NJcompilerthattook0.23secondsofusertimeona3GHzIntelXeon.ContMapFreeMapExpandCPSprintCoderBaseCoderErrorMsgSparcInstrGlobalFixCPSHoistSortedListIntsetCPSoptContractEtaClosureProfileList2SparcAsCodeSparcMCEmitIEEERealSparcCMCGSparcMCodeClosureCalleeSortSparcAsEmitSpillPrintUtilCPSsizePrimSparcMCCPScompAccessRealConstSparcACConvertCoreInfoLambdaCPSgenStrsSignsAbstractFctApplyFunctorOverloadPrintTypeUnifyTypecheckPrintAbsynStreamMLLexFunVectorAsciiLrParserJoinWithArgJoinMLLrValsFunCoreLangNewParseIndexMiscTyvarSetAbsynTypesNormalizeModulesConRepInstantiateLrTableBackpatchPrimTypesPolyContInitialAssemblyMathUnsafeLoaderCInterfaceCleanUpCoreFuncInLineFastlibCoreDummyOverloadsMakeMosStampsIntmapPersStampsPathnamesSymbolBigintDynamicIntStrMapArrayExtUnionfindSiblingsStrgHashEnvBasicTypesTuplesModuleUtilEqTypesFixityTypesUtilEqualVariablesBareAbsynPrintBasicsPrintValPrintDecSigMatchIntSparcDIntShareBatchRealDebugBogusDebugUnixPathsInteractModuleCompImporterIntSparcIntNullDLinkageProfIntNullInterpProcessFileFreeLvarLambdaOptTranslateOptReorderCompSparcMCoptMCprintNonrecMCInlineOpsUnboxed1dotUser’sManual,November2,201021BasicGraphDrawingdotdrawsdirectedgraphs.Itreadsattributedgraphtextfilesandwritesdrawings,eitherasgraphfilesorinagraphicsformatsuchasGIF,PNG,SVG,PDF,orPostScript.dotdrawsgraphsinfourmainphases.Knowingthishelpsyoutounderstandwhatkindoflayoutsdotmakesandhowyoucancontrolthem.Thelayoutproce-dureusedbydotreliesonthegraphbeingacyclic.Thus,thefirststepistobreakanycycleswhichoccurintheinputgraphbyreversingtheinternaldirectionofcertaincyclicedges.Thenextstepassignsnodestodiscreteranksorlevels.Inatop-to-bottomdrawing,ranksdetermineYcoordinates.Edgesthatspanmorethanonerankarebrokenintochainsof“virtual”nodesandunit-lengthedges.Thethirdstepordersnodeswithinrankstoavoidcrossings.ThefourthstepsetsXcoordi-natesofnodestokeepedgesshort,andthefinalsteproutesedgesplines.Thisisthesamegeneralapproachasmosthierarchicalgraphdrawingprograms,basedontheworkofWarfield[War77],Carpano[Car80]andSugiyama[STT81].Wereferthereaderto[GKNV93]forathoroughexplanationofdot’salgorithms.dotacceptsinputintheDOTlanguage(cf.AppendixD).Thislanguagede-scribesthreemainkindsofobjects:graphs,nodes,andedges.Themain(outer-most)graphcanbedirected(digraph)orundirectedgraph.Becausedotmakeslayoutsofdirectedgraphs,allthefollowingexamplesusedigraph.(Aseparatelayoututility,neato,drawsundirectedgraphs[Nor92].)Withinamaingraph,asubgraphdefinesasubsetofnodesandedges.Figure1isanexamplegraphintheDOTlanguage.Line1givesthegraphnameandtype.Thelinesthatfollowcreatenodes,edges,orsubgraphs,andsetattributes.NamesofalltheseobjectsmaybeCidentifiers,numbers,orquotedCstrings.Quotesprotectpunctuationandwhitespace.Anodeiscreatedwhenitsnamefirstappearsinthefile.Anedgeiscreatedwhennodesarejoinedbytheedgeoperator-.Intheexample,line2makesedgesfrommaintoparse,andfromparsetoexecute.Runningdotonthisfile(callitgraph1.gv)$dot-Tpsgraph1.gv-ograph1.psyieldsthedrawingofFigure2.Thecommandlineoption-TpsselectsPostScript(EPSF)output.graph1.psmaybeprinted,displayedbyaPostScriptviewer,orembeddedinanotherdocument.Itisoftenusefultoadjusttherepresentationorplacementofnodesandedgesinthelayout.Thisisdonebysettingattributesofnodes,edges,orsubgraphsintheinputfile.Attributesarename-valuepairsofcharacterstrings.Figures3and4illustratesomelayoutattributes.InthelistingofFigure3,line2setsthegraph’sdotUser’sManual,November2,201031:digraphG{2:main-parse-execute;3:main-init;4:main-cleanup;5:execute-make_string;6:execute-printf7:init-make_string;8:main-printf;9:execute-compare;10:}Figure1:Smallgraphmainparseinitcleanupprintfexecutemake_stringcompareFigure2:DrawingofsmallgraphdotUser’sManual,November2,20104sizeto4,4(ininches).Thisattributecontrolsthesizeofthedrawing;ifthedrawingistoolarge,itisscaleduniformlyasnecessarytofit.Nodeoredgeattributesaresetoffinsquarebrackets.Inline3,thenodemainisassignedshapebox.Theedgeinline4isstraightenedbyincreasingitsweight(thedefaultis1).Theedgeinline6isdrawnasadottedline.Line8makesedgesfromexecutetomakestringandprintf.Inline10thedefaultedgecolorissettored.Thisaffectsanyedgescreatedafterthispointinthefile.Line11makesaboldedgelabeled100times.Inline12,nodemake_stringisgivenamulti-linelabel.Line13changesthedefaultnodetobeaboxfilledwithashadeofblue.Thenodecompareinheritsthesevalues.2DrawingAttributesThemainattributesthataffectgraphdrawingaresummarizedinAppendicesA,BandC.Formoreattributesandamorecompletedescriptionoftheattributes,youshouldrefertotheGraphvizwebsite,specifically

1 / 40
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功