1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
%% xygraph.tex from $Id: xygraph.doc,v 3.11 2011/03/14 20:14:00 krisrose Exp $
%%
%% Xy-pic ``Graph Combinator feature'' option.
%% Copyright (c) 1994-1997 Kristoffer H. Rose <krisrose@tug.org>
%%
%% 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-2011 Kristoffer H. Rose <krisrose@tug.org>
%%
%% 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, see http://www.gnu.org/licenses/.
%%
\ifx\xyloaded\undefined \input xy \fi
\xyprovide{graph}{Graph feature}{\stripRCS$Revision: 3.11 $}%
{Kristoffer H.~Rose}{krisrose@tug.org}%
{IBM T.~ J.\ Watson Research Center, P.O.~Box 704, Yorktown Heights, NY 10598 (USA)}
\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 <node>: \string`\meaning\next\string' unexpected}{}%
\fi\fi\fi\fi\fi\fi\fi \next@}
\xydef@\jumpMOVE@@{&}
\xydef@\jumpMOVE@{\let\theMOVE@@=\jumpMOVE@@}
\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 <move>: \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 <escape>}{}\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\else \expandafter\let\csname G!#1\endcsname=\undefined
\xywarning@{Redefining graph <escape> !#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 <escape> !#1}\fi \next}
\xyendinput
|