GrapherdocumentationRichardR.BurtonandKurtVanLehnLastrevised:December27,1983Copyright(c)1982,1983XeroxCorporationLIBRARY>GRAPHERcontainsacollectionoffunctionsandaninterfaceforlayingout,displaying,andedittinggraphs(i.e.,networksofnodesandlinks).Graphshavenodelabelsbutnotlinklabels.Linksaredrawnasstraightlines,withoutarrowheads.Nodelabelscanbeasinglelineoftextorabitmapofarbitrarysize.Therearefacilitiesforhavingactionstriggeredbyselectionofnodesingraphs.Atypicalwaytousethegrapherpackageistoimplementafunctionthatcreatesapartiallyspecifiedgraphthatrepresentssomeuserdata(orcontrol)structure.Forinstance,thebrowserpackage(BROWSER)usesgraphstorepresentfunctioncallingstructures(fromMasterscope).Suchapartiallyspecifiedgraphneedonlyhavethegraphlabelsandthelinksspecified.ItisgiventoLAYOUTGRAPH,alongwithsomeformattinginformation.LAYOUTGRAPHassignsapositiontoeachofthenodes.Thereareformatsforlayingouttrees,latticesandcyclicgraphs.LAYOUTGRAPHreturnsaGRAPHrecord,whichisusuallygiventoSHOWGRAPH.SHOWGRAPHdisplaysagraphinawindow.Displayedgraphsareoftenusedasmenus:selectinganodewiththeleftormiddlebuttoncancauseuser-providedfunctionstobecalledonthatnode.Displayedgraphscanbeeditedusingtherightbutton.Nodescanbeadded,deleted,moved,enlargedorshrunk.Linkscanbeaddedordeleted.Thisdocumentwillfirstdescribethedatastructuresr,theGRAPHandGRAPHNODErecords,thenthelayoutfunctions,thedisplayfunctions,andtheeditingfunctions.TheGraphAgraphisrepresentedbyaGRAPHrecord,whichhasthefollowingfields:GRAPHNODES,DIRECTEDFLG,SIDESFLG,GRAPH.MOVENODEFN,GRAPH.ADDNODEFN,GRAPH.DELETENODEFN,GRAPH.ADDLINKFN,GRAPH.DELETELINKFNandGRAPH.FONTCHANGEFN.GRAPHNODESisalistofgraphnodes,whicharedescribedbelow.DIRECTEDFLGandSIDESFLGareflagswhichcontrolhowlinksaredrawnbetweenthenodes.IfDIRECTEDFLGisNIL,theGrapherwilldraweachlinkinsuchawaythatitdoesnotcrossthenodelabelsofthenodesitrunsbetween.Often,thisleavessomeambiguity,whichissettledbySIDESFLG:IfSIDESFLGisNIL,theGrapherpreferstodrawlinksthatgobetweenthetopandbottomedgesofnodes.IfSIDESFLGisnon-NIL,itpreferstodrawlinksbetweenthesidesofthenodes.IfDIRECTEDFLGisnon-NIL,theedgesarefixed(e.g.,alwaystotheleftedgeofthetonode).Thiscancauselinkstocrossthelabelsofthenodestheyrunbetween.Inthiscase,ifSIDESFLGisNIL,the"from"endofthelinkisattachedtothebottomedgeofthe"from"node;the"to"endofthelinkisattachedtothetopedgeofthe"to"node.IfDIRECTEDFLGisnon-NILandSIDESFLGisnon-NIL,the"from"endofthelinkisattachedtotherightedgeofthe"from"node;the"to"endofthelinkisattachedtotheleftedgeofthe"to"node.Theremainingfieldsgivetheuserhooksintothegrapheditor,whichisdescribedbelow.TheGraphnodesTheGRAPHNODErecordhasthefollowingfieldsofinteresttotheuser:NODELABEL-thethingthatgetsprinted(usingPRIN3)asthenode.Ifthisisabitmap,bitbltisusedinsteadofPRIN3.Thisallowsiconsofarbitrarysizestobeusedasgraphlabels. b6p bqk Rb `p ` _)/l!'_) ]%C!%] \yX$ .>\y [! [! Yr!"$ *,-2p5/7=?*CIFFY X0 !')-044:=d@EGnIIX0 V Rt#'a,f 448<?{AiBFICICV U* 9F!1!%( -/4E9>?`A9GOHHU* S2S R$ R$ P <' }%E&(;/.0K58=>D,JBJBP O "%*m 01=39<6AG}G}O MY$k&,o26 =TA JsJJM L&:"%)#+~/36d8< BzBCEZI!JJL J /  ' /0 :@A!FH H J Ij[Uh"% ),+/x4Y7;@E@@I G ! %*+v0E4 5 ?~?IPIPG F q#@-$)+/249?@DyGoIIF D A (.J/157:>?EJVJVD C  M"%"}&)+0@5:@BMGhGGC AaOQoA @ @ >} #"%1 ,/84s72@^EI(I(>} < M &P %(+/ 6< ;p ; :q:p:: 8 8 7r <P !&*-/6:! DD7 5 \,;H;H5 4  )9<<4 22 1 1 / d<P#(*w15L/ . . ,} !=$(-036C:@LBGIGHH,} * ZD!>#' *-+.2386 89=a?CEII* )w6S!!&6(-30 7<=aACC)w 'rpZ!'T,,-1<47G9A>AZCFF' &q,"$**+/158H>@aDEGG&q $B$ #k #k !  "X#&M)-G1358);=C?A4EEII! e x "|$),".4569B<>E6FII e  Mo]"$;&+d.0~27;=ACEhGJVJV _ R:+ #'''q( 249u<4CRDJJ_  Mo]"$;&)-].1N6: BS p    q8mps   r t m&*A+0248   y "%*/358; +: #(*.16?:;; ! !%*    q?[NODEID-auniqueidentifier.NODEID'sareusedinthelinkfieldsinsteadofusingpointerstothenodesthemselvessothatcircularLispstructurescanbeavoided.NODEID'sareoftenusedaspointerstothestructurerepresentedbythegraph.TONODES-alistofNODEIDS:alinkrunsfromthisnodetoeachnodeinTONODES.FROMNODES-alistofNODEIDS:alinkrunstothisnodefromeachnodeinFROMNODES.NODEPOSITION-thelocationofthecenterofthenode(aPOSITION).NODEFONT-Specifiesthefontinwhichthisnode'slabelwillbedisplayed.ItcanbeanyfontspecificationacceptabletoFONTCREATE,includingaFONTDESCRIPTOR.NODEFONTischangedbygrapheditoperationsLARGERandSMALLER.Whenthishappens,thefontfamilymaybechangedaswellasthesize.BOXNODEFLG-Ifthisfieldisnon-NIL,thenodelabelwillhaveaboxdrawnaroundit.NODEWIDTHandNODEHEIGHT-Normally,thesearesetbygraphertobethewidthandheightofthenode'sNODELABEL.However,iftheuserprovidesfixnumsforthesefields,theirvalueswillbeusedinstead.Thisfeaturecanbeusedtogiveanodealarger-than-normal"margin"arounditslabel.Graphnodescanbecreatedbythecreateoperatorfromtherecordpackageorwiththefollowingfunction:NODECREATE(IDLABELPOSITIONTONODEIDSFROMNODEIDSFONTBOXED?)ThisfunctionreturnsaGRAPHNODEwithNODELABEL=ID,NODELABEL=LABEL,NODEPOSITION=POSITION,NODEFONT=FONTandBOXNODEFLG=BOXED?.Awordonsavinggraphsonfiles:ThegrapherfunctionsuseFASSOC(i.e.,EQnotEQUAL)tofetchagraphnodegivenitsid.Hence,simplydumpingagraphontoafileandreadingitbackinwillonlyworkcorrectlyiftheid'sareatomic.Beforedumpingagraph,itiswisetosettoNILthefieldsthatarenormallycalculatedandfilledinbythegrapherfunctions.Inparticular,unlessspecialprovisionsaremade,theNODELABELandtheNODEFONTfieldswillreadbackinaslitatomswithnameslike{BITMAP}#1,23456or{FONTDESCRIPTOR}#7,2345insteadofrealbitmapsandfontdescriptors.LayingoutaGraphLAYOUTGRAPH(NODELSTROOTIDSFORMATFONTMOTHERDPERSONALDFAMILYD)LAYOUTGRAPH"laysout"apartiallyspecifiedgraphbyassigningpositionstoitsgraphnodes.ItreturnsaGRAPHrecordsuitablefordisplayingwithSHOWGRAPH.TheinputNODELSTisalistofGRAPHNODESthatpartiallyspecifiesagraph:onlytheirNODEID,NODELABEL,andTONODESfieldsneedtobefilledin.Optionalfieldsare:NODEFONT,NODEWIDTHandNODEHEIGHT.TheseoptionalfieldswillbefilledinappropriatelyiftheyareNIL.Allotherfieldswillbeignoredand/oroverwritten.ROOTIDSisalistofthenodeidentifiersofthenodesthatwillbecometheroots.Theotherargumentsareoptionalandcontroltheformatofthelayout.FORMATcontrolsthegeometryofthelayout.Itisanunorderedlistofatoms.Therearethreebasicformats:COMPACT[thedefault]-Thegraphislayedoutasaforest b r b a~7 "")+/j03F5b `2#%$'+ 354` _ !$[&I,,`3599_ ]W$C$ ,.05] \ \ Z^/_$O%l'+-.p145Z Y`qY W W V xIy&i'*-G.1{5 7V T`q !T S S Q #_$'P+-O/3:4 Y@2@8Ks I #&-.0294;;I HmC* #%(*h,/Hm F F Eg h!s"(+.14_4eEg C JKhg L!yC Ba Ba @q $%,/2J46];<@ ?[1  "'0T11f7a?[ =`N!#'+.3I57M= ?BD FsIuIu* )/aVsa!""&,-293V479y;=I?B,EHH)/ ' X$  6!#%+H 12E3 :?CC' &) 8v#&E(04`69=l>@F II&) $~{!(5W:P;>DFII$ ## .6## !p ! ^ ^ qDp Q Q "v(W,3B;Bf   3r g# )"-6/5;=/> GZHH3 . "% (+ 568 @GG- 1S!$'/0U9; EFJPJP 'p+e &%'B*M,//159Z;=BGG'  ":_"P% ,z.0k47s9?MAEEHH !' d%=', -/444!   !S #D'(2)Z*,357b; 1016] \\ Z Z Y"%1&(-2Y WLW V V T1n%',bT S S Q B!E"%';)-// 7'Q O/T"x%(9 11O Np N M!r b &)Q,35$;< ?BH$H|H|M! K ")[,0. 5I:*<@UBFKHEJJK J+t $@$3f:=?DHdHdJ H x (#&a+ 55q ?0BDlDlH G 'R!H#B%(N(()V))G E E D  $(*.T349.:?BhCGGD B1g -!J%{'*.Q./57  y"&N*0d2^79;BCgDJ J > < q;7K &*,.u58;889C9I< : : 9z]~ o"&- 45;=BFHH9z 7MF P!m$%&){-c/4U: =?.AEE7 6t f #W&+ 429?AII6t 4 v*S$8'p(+L-26S8=F@} JfJf4 3nl"&)m*/B04#79S;@ @dFJJ3n 1 v e l$?()"*J,246n9;<? CP1 0~p 0~ /r J R  Z m>@ &Z*-1Z/ - J R  Z$@- , , * J R  Z ] %w)>+/)13o* ) J R  Z 1) 'p ' &)r p5d & 0259<?CE0IpIp&) $ !Q"n%',.58LABE^J JbJb Xx"&N')c)+12c6?7;AD^II 2um !"A(* 3i8@<> EGJJ ("8 *T-w/15;#;{=D%HH  ,;X"%N ,M13S68mAD D   %: #&(,Q0$2 :<&@DYG H)H) pU+ (g-i.249:>mCqEE  "!#*/*169J;@CEIJJ  I "s%(*.4(79=r   | |  n % +y- 8L8;n?F=HH v Y2 %!v ),.0l27}?ACFFIJzJz v j  b"' 1 p p  n1$ &e,2737:>DqII q?[basedonthesizeofFONTtobeused.PERSONALDcontrolstheminimumdistancebetweenanytwonodes.MOTHERDistheminimumdistancebetweenamotherandherdaughters.FAMILYDcontrolstheminimumdistancebetweennodesfromdifferentnuclearfamilies.TheclosesttwosisternodescanbeisPERSONALD.TheclosestthattwonodesthatarenotsisterscanbeisPERSONALD+FAMILYD.DisplayingandEditingaGraphSHOWGRAPH(GRAPHWLEFTBUTTONFNMIDDLEBUTTONFNTOPJUSTIFYFLGALLOWEDITFLG)SHOWGRAPHdisplaysthenodesintheGRAPH.IfWisawindow,thegraphwillbedisplayedinit.Ifthegraphislargerthanthewindow,thewindowismadeascrollingwindow.IfWisNIL,thegraphwillbedisplayedinawindowlargeenoughtoholdit.IfWisastring,thegraphwillbedisplayedinawindowlargeenoughtoholditandthewindowwillusethestringforthewindowtitle.SHOWGRAPHcachessomeinformationinthegraphnodefieldsinordertomakescrollingfaster.ThegraphisstoredontheGRAPHpropertyofthewindow.SHOWGRAPHreturnsthewindow.IfeitherLEFTBUTTONFNorMIDDLEBUTTONFNarenon-NIL,thewindowisgivenaBUTTONEVENTFNthat,ineffect,turnsthegraphintoamenu.Whenevertheleftormiddlebuttonisdepressedandthecursorisoveranode,thatnodewillbedisplayedinverted,indicatingthatitisselected.LettinguponthebuttonwillcalleithertheLEFTBUTTONFNorMIDDLEBUTTONFNwithtwoarguments:theselectedGRAPHNODE(thiswillbeNILifthecursorwasnotoveranodewhenthebuttonwasreleased)andthewindow(fromthewindow,thefunctionscanaccessthegraphviaWINDOWPROP).Thegraph'sinitialpositionisdeterminedbyTOPJUSTIFYFLG.IfT,thegraph'stopedgeispositionedatthetopedgeofthewindow;ifNIL,thegraph'sbottomedgeispositionedatthebottomedgeofthewindow.IfALLOWEDITFLGisnon-NIL,therightbuttoncanbeusedtoeditthegraph.(Thenormalwindowcommandsareavailablebyrightbuttoningintheborderortitleregions.)Rightbuttoningwhileashiftkeyisdownallowspositioningofnodesbytrackingthecursor.Rightbuttoningwiththeshiftkeyupbringsupamenuofeditoperations.Theeditoperationsallowmoving,addinganddeletingofnodesandlinks.AddinganodepromptsforaNODELABEL,createsanewnodewiththatlabel,addsittothegraphandallowstheusertopositionit.Deletinganoderemovesit(usingDREMOVE)fromGRAPHafterdeletingallofthelinkstoandfromit.WhentheSTOPmenucommandisselected,thegraphwindowisclosed.CertainfieldsoftheGRAPHrecordarefunctionsthatgetcalledbythegrapheditorwheneveranactionisperformedonanelementinthedisplayedgraph.Theyallowthegraphtoserveasansimpleeditinterfacetothestructurebeinggraphed.BelowarethefieldsofGRAPHandtheargumentsthatthecorrespondingfunctionwillbecalled.InallcasesGRAPHisthegraphbeingdisplayedandWINDOWisthewindowinwhichitisdisplayed.GRAPH.MOVENODEFN(NODENEWPOSGRAPHWINDOW)calledaftertheuserhasstoppedmovinganodeinteractively(i.e.isnotcalledasthenodeisbeingmoved.)GRAPH.ADDNODEFN(GRAPHWINDOW)calledwhentheuserselects"Addanode"andshouldreturnaNODEorNILifnonewnodeistobeadded.Nodemovingoperationwillbecalledonthenewnodeafteritiscreatetodetermineitsposition.GRAPH.DELETENODEFN(NODEGRAPHWINDOW)calledwhenanodeisdeleted.Beforethisfunctioniscalled,allofthelinkstoorfromthenodearedeleted.GRAPH.ADDLINKFN(FROMTOGRAPHWINDOW)calledwhen b r b & {P~#O,#14:,?EHFHFb ` 24#)r/00M5&7:W AAH>H>` _{$w(+16@BB] \D\ Zp Z YO YO Wq W V kV%V Tp T S5b $ 1 =V HGS5 Q Q PorlF "$b)+',.)/F476;J=?FGII]JJPo N Ma[!$K)~*./5;8;<>Z?BDIIN Mi ZH.K~! &?'*,,-'.O/1Q2n69=2?AGInJJMi K%|!{#) +q.0j4]6w8>AAfAfK JclY $&9(/358:y>>D H\H\Jc H 0! &(k*0[0:-?AlFH G] G] E  T *,|2R49;@?@$@$E DW V Q#&G*[-.7229;>J?DIJeJeDW B  ! %'+j-/6%< BEgFGGB AQ^ o #M%),6 7t9! F6I,I,AQ ? l&J)a+-0?1\38.;=j@AE9II? >K M%'(+>03.9q<$@CKG_II>K < < ;E ;E 9 f $& 234.58=E?C0DD9 8? {=W%G&d)N+059!: AC EeJ3J38? 6v g6 59 59 3  9o $ (+6-$02)477;<?HD I?I?3 23I}&0'* .0Q289G=CrGH5H523 0  !p#'F).15629@]CSEHH0 /- ys_ &&'C* , 37<AD[II/- - ,j!&() 289$<?BEhI-I-- ,'a~oB $%+,203M6<=BII,' *5p"!%#&)x,.:.249 <CDD* )!au"#N#T)! ' ' &;!]#*,/)3Q5*7;?F&HH& $;v "]$+//3e7 9f=z?BDFF$ #i"%, ,b035c9:?BE E # !4 &p(*/P/1437f`#A&'(-[.. p    %`*1n59]:z: xH6!'g(-Q//$ ~_#%+   ^"8$)048|8  q?[alinkisadded.GRAPH.DELETELINKFN(FROMTOGRAPHWINDOW)calledwhenalinkisdeletedwhichcanbeeitherdirectlyorfromdeletinganode.GRAPH.FONTCHANGEFN(HOWNODEGRAPHWINDOW)calledwhentheuseraskedforthelabelonanodetobemadelargerorsmaller.HOWisoneofLARGERorSMALLER.MiscellaneousfunctionsGRAPHREGION(GRAPH)ReturnsthesmallestregioncontainingallofthenodesinGRAPH.LAYOUTSEXPR(SEXPRFORMATFONTMOTHERDPERSONALDFAMILYD)JustlikeLAYOUTGRAPHexceptitgetsitsgraphasas-expressionratherthanalistofGRAPHNODEs.Aformalrecursivedefinitionofitsfirstargumentis:Ifthes-exprisanatom,itsNODELABELwillbeitselfanditwillhavenoTONODEs;elseitisalistanditscarwillbetakenasitsNODELABELanditscdr,whichmustbealistofs-exprs,willbetakenasitsTONODEs.Notethatcirculars-expressionsareallowed.Forexample,thefollowingdisplaysaparsetreeforthesentence"Theprogramdisplaysatree."(SHOWGRAPH(LAYOUTSEXPR'(S(NP(DETthe)(NOUNprogram))(VP(VERBdisplays)(NP(DETa)(NOUNtree))))'(VERTICAL)NIL'(HELVETICA12] b r b b ` ` _$&,+27&::_ ]% "&+-s00] \Zw\ Z Z Y %)`.5n9=]=cY WCe!Z#T$q()+/a3t3zW V>O &(]/JV Tp T SC SC Qq QpQQ P6 P6 NN M M LrN1 #%~')o-/04{L Jp J IS IS G$$*3B:G F F E5r z U!$%)+, 5[9<=?AAE5 C 02!j ')C+-4=57'9=?7A%E FFC B/T0!$&.?1)2F3469;t=@BB0F GIIB/ @f3&"$%')[.1*368:AB.EHMHM@ ?)" F!J!$ *5,28(9E=,?BDtJJ?) =B= <9p <9 : w  !$(W,4<: 9 wN%X/b9lC !"v#M$$$(W-a49 81 wN%X/b9lC !"v#M$$$%&'(W+/6=\81 6 wN%X/b9lC ! +/ 9#<=V>->36 q?[ HELVETICA  HELVETICA ~GACHA }  $ 1P6j/976%{ERIS}LIBRARY>GRAPHER.TED;1 SANNELLA.PA31-Jul-84 10:45:07