%% xygraph.tex from $Id: xygraph.doc,v 3.3 1996/12/19 03:31:56 krisrose Exp $ %% %% Xy-pic ``Graph Combinator feature'' option. %% Copyright (c) 1994-1996 Kristoffer H. Rose %% %% This file is part of the Xy-pic package for graphs and diagrams in TeX. %% See the companion README and INSTALL files for further information. %% Copyright (c) 1991-1996 Kristoffer H. Rose %% %% The Xy-pic package is free software; you can redistribute it and/or modify %% it under the terms of the GNU General Public License as published by the %% Free Software Foundation; either version 2 of the License, or (at your %% option) any later version. %% %% The Xy-pic package is distributed in the hope that it will be useful, but %% WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY %% or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License %% for more details. %% %% You should have received a copy of the GNU General Public License along %% with this package; if not, write to the Free Software Foundation, Inc., %% 675 Mass Ave, Cambridge, MA 02139, USA. %% \ifx\xyloaded\undefined \input xy \fi \xyprovide{graph}{Graph feature}{\stripRCS$Revision: 3.3 $}% {Kristoffer H.~Rose}{krisrose@brics.dk}% {BRICS/Computer Science, University of Aarhus, Ny Munkegade, building 540, DK--8000 Aarhus~C} \xyrequire{arrow}\xycatcodes \xydef@\xygraph#1{\relax\graph#1\endgraph} \xydef@\graph{\if\inxy@ \DN@{\xy@@{\nter@{}}}% \else \DN@{\xy \xy@\xy{\nter@\endxy}}\fi \next@ \xy@\xygraph{\senter@ \idfromc@{?NODE}\spushc@ \expandafter\let\expandafter\next@\csname Q@graphbase\endcsname \ifx\next@\relax \setbase@\z@\z@{3pc}\z@ \else \expandafter\next@ \fi}% \GRAPH[]} \xydef@\endgraph{\ignorespaces} \xydef@\GRAPH{\xyFN@\GRAPH@} \xydef@\GRAPH@{% \ifx \space@\next \expandafter\DN@\space{\xyFN@\GRAPH@}% \else\ifx :\next \DN@:{\xy@:{}\expandafter\GRAPHar@\GRAPHeveryarrow@@}% \else\addDASH@\ifx\next \addDASH@\DN@{\xy@-{}\expandafter\GRAPHar@\GRAPHeveryline@@}% \else\ifx (\next \DN@({\xy@({\spushid@{?NODE}\idfromc@{?NODE}}\xyFN@\GRAPH@}% \else\ifx ,\next \DN@,{\xy@,{\cfromid@{?NODE}}\xyFN@\GRAPH@}% \else\ifx )\next \DN@){\xy@){\cfromid@{?NODE}% \tests@\z@{\idfroms@{?NODE}\z@ \spop@}{\xyerror@{) without (}{}}}% \xyFN@\GRAPH@}% \else\ifx \endgraph\next \DN@{\xy@@{\tests@\z@\spop@\sleave@\leave@}}% \else\ifx \end\next \DN@{\xy@@{\tests@\z@\spop@\sleave@\leave@}}% \else\ifx ~\next \DN@~{\xy@@{\enter@\cfromthec@}\afterNODE{\leave@ \xyFN@\GRAPH@}!}% \else \DN@{\afterNODE{\xyFN@\GRAPH@}}% \fi\fi\fi\fi\fi\fi\fi\fi\fi \next@} \xylet@\GRAPHsaved@PATHafterPOS=\PATHafterPOS \xylet@\GRAPHsaved@afterar@@=\afterar@@ \xydef@\GRAPHar@{% \let\PATHafterPOS=\afterNODE \let\afterar@@=\GRAPHafterar@ \ar} \xydef@\GRAPHafterar@{% \let\PATHafterPOS=\GRAPHsaved@PATHafterPOS \let\afterar@@=\GRAPHsaved@afterar@@ \xy@@{\cfromid@{}}\xyFN@\GRAPH@} \xylet@\afterNODE@@=\empty \xydef@\afterNODE#1{\xy@@{\enter@\pfromthep@}% \DN@##1{\def\afterNODE@@{\xy@@\leave@ \def\afterNODE@@{##1}#1}}% \expandafter\next@\expandafter{\afterNODE@@}% \xyFN@\NODE@} \xylet@\theMOVE@@=\relax \xydef@\NODE@{% \ifx \space@\next \expandafter\DN@\space{\xyFN@\NODE@}% \else\ifx [\next \DN@[##1]{\xy@{[##1]}{}% \def\theMOVE@@{[##1]}\xyFN@\MOVE@##1]}% \else\ifx "\next \DN@ "##1"{% \xy@{"##1"}{\cfromid@{##1}}\def\theMOVE@@{"##1"}\xyFN@\NODE@i}% \else\ifx ?\next \DN@ ?{% \xy@?{\cfromid@{?NODE}}\def\theMOVE@@{?}\xyFN@\NODE@i}% \else\ifx !\next \def\theMOVE@@{[]}\let\next@=\NODE@i \else \testAND@\iffalse \DN@##1{\xy@{}{\pfromc@ \advance\X@c\X@xbase \advance\Y@c\Y@xbase \czeroEdge@}\jumpMOVE@ \xyFN@\NODE@i}% \else\ifx \\\next \DN@\\{\xy@\\{\pfromc@ \advance\X@c\X@xbase \advance\Y@c\Y@xbase \R@c=\X@ybase \U@c=\Y@ybase \intersect@ \advance\X@c-\X@ybase \advance\Y@c-\Y@ybase \czeroEdge@}\def\theMOVE@@{\\}\xyFN@\NODE@i}% \else \xyerror@{Illegal : \string`\meaning\next\string' unexpected}{}% \fi\fi\fi\fi\fi\fi\fi \next@} \xydef@\jumpMOVE@@{&} \xydef@\jumpMOVE@{\let\theMOVE@@=\jumpMOVE@@} \xydef@\testAND@{{\aftergroup\ifx \addAND@\ifx\next\addFalse@\else\addTrue@\fi}} \xydef@\addFalse@{\aftergroup\iffalse} \xydef@\addTrue@{\aftergroup\iftrue} \xydef@\MOVE@{\xy@@{\count@=\z@ \count@@=\z@}% \ifx \space@\next \expandafter\DN@\space{\xyFN@\MOVE@}% \else\ifcat A\noexpand\next \let\next@=\MOVE@letter \else \let\next@=\MOVE@x \fi\fi \next@} \xydef@\MOVE@letter{% \ifx \space@\next \expandafter\DN@\space{\xyFN@\MOVE@letter}% \else\ifx u\next \DN@ u{\xy@@{\advance\count@\@ne}\xyFN@\MOVE@letter}% \else\ifx d\next \DN@ d{\xy@@{\advance\count@\m@ne}\xyFN@\MOVE@letter}% \else\ifx l\next \DN@ l{\xy@@{\advance\count@@\m@ne}\xyFN@\MOVE@letter}% \else\ifx r\next \DN@ r{\xy@@{\advance\count@@\@ne}\xyFN@\MOVE@letter}% \else \let\next@=\MOVE@x \fi\fi\fi\fi\fi \next@} \xydef@\MOVE@x{% \ifx ]\next \DN@ ]{\MOVE@hop \xyFN@\NODE@i}% \else\ifx (\next \DN@{\MOVE@hop \xyFN@\MOVE@place}% \else\ifx !\next \DN@{\MOVE@hop \xyFN@\MOVE@place}% \else\ifx /\next \DN@{\MOVE@hop \xyFN@\MOVE@place}% \else\addLT@\ifx\next \DN@{\MOVE@hop \xyFN@\MOVE@place}% \else\addGT@\ifx\next \DN@{\MOVE@hop \xyFN@\MOVE@place}% \else\addDASH@\ifx\next \addDASH@\DN@{\xyerror@{- not implemented yet}{}}% \else \xyerror@{illegal : \codeof\theMOVE@@}{}\let\next@=\NODE@i \fi\fi\fi\fi\fi\fi\fi \next@} \xydef@\MOVE@hop{\xy@@{\pfromc@ \czeroEdge@ \edef\next@{\the\count@@,\the\count@ @}\expandafter\vfromcartesian@@\next@ \advance\X@c-\X@origin \advance\Y@c-\Y@origin \advance\X@c\X@p \advance\Y@c\Y@p}} \xydef@\MOVE@place{\xy@@\no@@ \afterPLACE{\xyFN@\MOVE@}} \xydef@\NODE@i{\let\next@=\NODE@x \ifx \space@\next \expandafter\DN@\space{\xyFN@\NODE@i}% \else\addEQ@\ifx \next \addEQ@\DN@"##1"{\xy@{="##1"}{\idfromc@{##1}}\xyFN@\NODE@i}% \else\ifx !\next \DN@!{\xyFN@\NODE@escape}% \else\ifx :\next \else\addDASH@\ifx\next \else\ifx (\next \else\ifx ,\next \else\ifx )\next \else\ifx ~\next \else\ifx [\next \else\ifx "\next \else\ifx ?\next \else\ifx ^\next \else\ifx _\next \else\ifx |\next \else\addLQ@\ifx\next \else\addRQ@\ifx\next \else \testAND@ \iffalse \else\ifx \\\next \else\ifx \endgraph\next \else\ifx \end\next \else \let\next@=\NODE@it \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi \next@} \xydef@\NODE@x{\xy@@{\idfromc@{}}\afterNODE@@} \xydef@\NODE@it{\let\PATHlabelit@@=\NODEit@ \PATHit@} {\xyuncatcodes \gdef\next{+}} \xylet@\GRAPHnodemodifiers@@=\next \xydef@\NODEit@#1{% \DN@{#1}\ifx\next@\empty \DN@{\expandafter\NODEit@i\expandafter{\GRAPHnodemodifiers@@}}% \else \DN@{\NODEit@i{#1}}\fi \next@} \def\NODEit@i#1#2{\xy@{*#1{#2}}{\drop@{#1}{#2}}% \DN@{\addEQ@\ifx\next\else \xy@@{\idfromc@{#2}}\fi \NODE@i}% \xyFN@\next@} \xydef@\NODE@escape{% \ifx \space@\next \expandafter\DN@\space{\xyFN@\NODE@escape}% \else\ifcat A\noexpand\next \DN@##1{\rungraphescape@{##1}}% \else\ifcat !\noexpand\next \DN@##1{\rungraphescape@{##1}}% \else\ifx \bgroup\next \DN@##1{\xy@{!{##1}}{}\POS##1\relax \xyFN@\NODE@i}% \else\ifx ~\next \let\next@=\graphsetup@ \else \DN@{\xyerror@{Unknown graph }{}\xyFN@\NODE@i}% \fi\fi\fi\fi\fi \next@} \xydefcsname@{graph !M}#1#{\NODE@matrix{#1}} \xydef@\NODE@matrix#1#2{\xyerror@{matrix feature not loaded}{}\xyFN@\GRAPH@} \xydef@\NODE@matrix@#1#2{\xy@{!M#1{#2}}{}% \def\everyentry@{\GRAPHeveryentry}% \xymatrix#1{#2}% \let\everyentry@=\empty \insertmatrixingraph@ \xyFN@\NODE@i} \xydef@\GRAPHeveryentry{\def\:{\ar}\def\="##1"{\xy@@{\idfromc@{##1}}}} \xywithoption{matrix}{\let\NODE@matrix=\NODE@matrix@} \xydef@\insertmatrixingraph@{% \xy@@{\enter@{\cfromthec@ \pfromthep@}% \expandafter\let\expandafter\next@\csname Q@1,1\endcsname \ifx\next@\relax\else \next@ \swap@ \expandafter\let\expandafter\next@\csname Q@1,2\endcsname \ifx\next@\relax\else \next@ \setbase@\X@p\Y@p\X@c\Y@c \expandafter\let\expandafter\next@\csname Q@2,1\endcsname \ifx\next@\relax\else \next@ \setbase@@{-\X@c}{-\Y@c}\fi\fi\fi \leave@}} \xydefcsname@{graph !P}#1#{\NODE@poly{#1}} \xydef@\NODE@poly#1#2{\xyerror@{poly(gon) feature not loaded}{}\xyFN@\GRAPH@} \xydef@\NODE@poly@#1#2{\xy@{!P#1{#2}}{}\xypoly@#1{#2}\xyFN@\NODE@i} \xywithoption{poly}{\let\NODE@poly=\NODE@poly@} \xydefcsname@{graph !E}#1#{\NODE@arc{#1}!} \xydef@\NODE@arc#1#2{\xyerror@{(ellipse+)arc feature not loaded}{}% \xyFN@\GRAPH@} \xydef@\NODE@arc@#1#2{\xy@{!E#1{#2}}{}\ellipse#1{#2}\xyFN@\NODE@i} \xywithoption{arc}{\let\NODE@arc=\NODE@arc@} \xylet@\GRAPHeveryarrow@@=\empty {\xyuncatcodes \gdef\next{@{-}}} \xylet@\GRAPHeveryline@@=\next \xydef@\graphsetup@~{\xyFN@\graphsetup@i} \xydef@\graphsetup@i{% \ifx :\next \DN@:##1{\def\GRAPHeveryarrow@@{##1}\xyFN@\NODE@i}% \else\addDASH@\ifx\next \addDASH@\DN@##1{\def\GRAPHeveryline@@{##1}\xyFN@\NODE@i}% \else\ifx *\next \DN@*##1{\def\GRAPHnodemodifiers@@{##1}\xyFN@\NODE@i}% \else\ifcat A\next \DN@##1##2{\newgraphescape{##1}{##2}\xyFN@\NODE@i}% \else \DN@{\xyerror@{illegal graph setup \codeof\next@}{}\xyFN@\NODE@i}% \fi\fi\fi\fi \next@} \xydef@\newgraphescape#1{% \expandafter\let\expandafter\next\csname graph !#1\endcsname \ifx\next\relax \expandafter\let\csname G!#1\endcsname=\undefined \xywarning@{Redefining graph !#1}\fi \expandafter\gdef\csname graph !#1\endcsname{% \expandafter\let\expandafter\next\csname G!#1\endcsname \expandafter\xyFN@\expandafter\NODE@\next}% \DN@{\newgraphescape@{#1}}\xyFN@\next@} \xydef@\newgraphescape@#1{% \ifx [\next \ifx\newcommand\undefined \xyerror@{[n] only with LaTeX}% \else \def\nextiv@{\expandafter\newcommand\expandafter{\csname G!#1\endcsname}}\fi \else \def\nextiv@{\expandafter\gdef\csname G!#1\endcsname}\fi \nextiv@} \xydef@\rungraphescape@#1{% \expandafter\let\expandafter\next\csname graph !#1\endcsname \ifx\next\relax \xyerror@{Undefined graph !#1}\fi \next} \xyendinput