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.,alwaystheleftedgeofthetonode).Thiscancauselinkstocrossthelabelsofthenodestheyrunbetween.IfDIRECTEDFLGisnon-NILandSIDESFLGisNIL,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.p c/b qc Jb` r `_) 'd!'~_)] ;!$]\y P$ .6\y[! [!Y s"$ *,%2h5'7=?"CAF F YX0 !')~-0}449=\@DGfIIX0V  }Jl#'Y,^ 448<?sAaB~FI;I;VU*  1>!)!%' -/4=96?XA1GGHHU*S *SR$ R$P 4u%=&(3/&0C58=>D$J:J:PO  "%*e 01539<.AGuGuOM Q$c%,g16 =LA JkJJML 2"%)+v/36\8; BrBCERIJJLJ ' ' // :?AFHHJI bSM`"%)$+/p4Q7;@=@@IG !%*+n0=45 ?v?IHIHGF i8%$)y+/x249?@DqGgIIF D  9~ '.B/157:>>EJNJNDC  E""u&)+085:@BEG`GGCA YGIgA@ @>}  " %) ,/04k7*@VEI I >}<  Ey yH %(+/ 6<; r ;: q:r::8 87 s 4H !&*-/5: DD75 T,;@;@54 )9<<4 2 21 1/ \y4H#( *o15D/. .,} !5$(-036;:@DBGAGHH,}* R<!6#'*-#.230689=Y?CEI}I}*)w .Ky!!&.(-+0 7;=YACC)w' jhR!'L,$-144w7?99>ARCFxFx'&q $|"$")+/148@=@YCEGG&q$ :$#k #k!   zP#&E)-?14<6:;>?DDYGfJJ! e U+"&\)g+22]3 =>DaG G e hRz 9!$*&(./16:H;>9CFISIS_  _M +"$(q*,b/3t34 >@\EHH_ h> f#%$')+ 0248%;=??DgHYJJY  _M +"$(Y),J/j3 Y S  f!r $')-2a67>BS r   q0erk  s l  e&~*9+02~48   q "%*.357; #2 #(~*.1679;;   !%*    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,theirvalueswillusedinstead.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.LAYOUTGRAPH'sinputROOTIDSisalistofthenodeidentifiersofthenodesthatwillbecometheroots.Theotherinputargumentsareoptionalandcontroltheformatofthelayout.FORMATcontrolsthegeometryofthelayout.Itisanunorderedlistofatoms.Therearethreebasicformats:COMPACT[thedefault]-Thegraphislayedoutasaforest c8b sYv/ "{")+/b03>5b ` *#%'w+ 3-4`_  !$S&A,,X35x99_] O;$ ,.05]\ \Z V'W$G%d'+%.h145ZY XiYW WV pAq&a'~*-?.1s57VT Xi !TS SQ  #W$'H+-G/324 <9QO ONy 9!$h%*,1H46NyL  !T$( , 35:LKs   "!?./78f>Q@*@0KsI  #&-.(214;; IHm ;"#%(*`,/HmF FEg  `!k"(*.14W4]EgC B8l !CBa Ba@ i $%, /2B4|6U;<@?[ ) "'0L11^7Y?[= XzF!#'+.3A5W=:@/;- -,5 4+ 5 #W(.17:<?WDFvJJ,5* S"$Z*H+e/y2368=?BDFkImIm*)/ YNkY!"&,-213N479q;=A?B$EHH)/'  P   .!#%+@ 12=3 :?CC'&) 0n#~&=(04X69=d>@FHH&)$ vs! 5O:H;>CFII$## &~.##! r ! ^ ^ q <rQ Q "n(O,3:;B^ 3 s _#)-./5x;='> GRHzHz3 & " (+ 568@GG- )K! $'/0M9; EF JHJH' h#y] &':*E,//159R;=BGG'  ")2*+-/j15U ;=?D FIPIP! \ !(5*027: >@BrGG`Gf!   K #<'(*)R*,357Z;   q"&F*0\2V79;AC_D|JJ><  i3/C &*,.m583889;9A<: :9z Uv g"&-{ 45;=BFHH9z7 zE> H!e#%&)s-[/4M:=?&AEE76t ^ #O&+ 4*9?AII6t4  n"K$0'h(+D-26K8=>@u J^J^43n d"&)e*/:0479K;@@\FII3n1  |n] d$7()*B,146f9;4?CH10~ r 0~/ s B J R e68 &R*,1R/- B J R8-, , * B J R U %o)6+/!13g*) B J R ))' r '&) s h-\ & 0|259<?CE(IhIh&)$   !I"f%|',.5|8D EGJ~J~  x"0 *L-o/15;;s<DHH  $3P"%F ,E13K6 8eADD 2 #&',I02 :<@DQGH!H!  zhM#{ (_-a.~249:>eCiEE y"#*/"16 9B;@CxEIII  A "k%(*.4 79=j | |  f x%+q- 8D8;f?F5HH v  Q*  }!n )+.0d27u?@CF>IJrJr v b  Z"' 1 p p  f )$&],27+7:>DiII q?[tobeused.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)calledwhenalinkisadded. c8b s n? ").4769>v>FGxIIb ` "%@' ./35;"=}CI`I``_ +"(+S0+26:=?p@ JJ^J^_]  T2!`#(=*,.>>]\* r \*Z ZYH q YHW cN%WV r VT Z $ 1 =N H?TS` S`Q sd> ~!$Z)+,.!/>47.;B=?EG~HIUJ}J}QPo  EYS!$C)v*./5;0;<>R?BDI I PoN  R@&Cv!&7'*, ,-.G/1I2f69=*?AGIfJJNMi t!s#)+i.0b4U6o8=AA^A^MiK dQ $&1(/358:q>6DHTHTKJc  (!&(c*0S0:%? AdFJcH HG]   L *,t2J49;8>@@G]E Nx I#&?*S-./2y29;>B?DHJ]J]EDW y!% '+b-/6; BE_F|GGDWB V g #E%),. 7l9 F.I$I$BAQ   d&B)Y+-071T38&:=b@AE1HHAQ?  E%(+603&9i<@CCGWI|I|?>K >K< <;E  ^ $& 224&58==?C(DD;E9 s5O%?&\)F+059:y AxCE]J+J+98? n_8?6 659   1g $({+.-02!47/;;?@DI7I7593 Au&('*.0I289?<CjGH-H-323  | !h"'>).056*9@UCKEHH230  qkW &&';*, 37}<ADSII0/-  $|b!&() 279<?BE`I%I%/-- Yv g{: $ %+ ,2(3E6<=AII-,' -h}!%&)p,.2.249<CDD,'* Ym"#F#L*)! )!' 3!U#),/!3I5"7};?FH H '& 3n "U$+//3]79^=r?BDFF&$ a"%,,Z035[9:?BEE$#  , &h(*/H/1,27<;=?D GG#! Oh##V$(*+s 1! % r % s#*/K6:F:L4  {; %&*b 24 YN"9#',. B H. %#*.2488( ]z %2)f*.0y33( }sa##p'+,'22" H6^X#9&y'(-S.." h   %X*1f59U:r:x p@.!'_(-I// vW#%+   V"0$w)048t8z    q?[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] c8b s b ` $&,#27::`_  "&+-k00_] Ro]\ \Z  %)X.5f9=U=[ZY ;]z!R#L$i')+}/Y3l3rYW 6G &(U/BWV r VT TS< q S3469;l=@:B(FGIICB/ ^+"${%')S.1"368:AB&E}HEHEB/@  >!B!$*-,28 9==$?BDlJJ@?) y:~?)= r =%>+8\ q?[ HELVETICA ~GACHA  HELVETICA ~GACHA x  $ 1f6j/97b${PHYLUM}LIBRARY>GRAPHER.TED;16 VANLEHN.PA27-DEC-83 18:40:40