| 1 |
% Copyright 2019 by Till Tantau |
| 2 |
% Copyright 2019 by Jannis Pohlmann |
| 3 |
% |
| 4 |
% This file may be distributed and/or modified |
| 5 |
% |
| 6 |
% 1. under the LaTeX Project Public License and/or |
| 7 |
% 2. under the GNU Public License. |
| 8 |
% |
| 9 |
% See the file doc/generic/pgf/licenses/LICENSE for more details. |
| 10 |
|
| 11 |
\ProvidesFileRCS{tikzlibrarygraphs.code.tex} |
| 12 |
|
| 13 |
|
| 14 |
% |
| 15 |
% Interface keys |
| 16 |
% |
| 17 |
|
| 18 |
\def\tikzgraphsset{\pgfqkeys{/tikz/graphs}}% |
| 19 |
|
| 20 |
\tikzgraphsset{ |
| 21 |
new ->/.code n args={4}{% |
| 22 |
\path [->,every new ->/.try] |
| 23 |
(#1\tikzgraphleftanchor) |
| 24 |
edge[#3] #4 |
| 25 |
(#2\tikzgraphrightanchor);}, |
| 26 |
new --/.code n args={4}{ |
| 27 |
\path [-,every new --/.try] |
| 28 |
(#1\tikzgraphleftanchor) |
| 29 |
edge[#3] #4 |
| 30 |
(#2\tikzgraphrightanchor);}, |
| 31 |
new <->/.code n args={4}{ |
| 32 |
\path [<->,every new <->/.try] |
| 33 |
(#1\tikzgraphleftanchor) |
| 34 |
edge[#3] #4 |
| 35 |
(#2\tikzgraphrightanchor);}, |
| 36 |
new -!-/.code n args={4}{}, |
| 37 |
new <-/.code n args={4}{% |
| 38 |
\path [<-,every new <-/.try] |
| 39 |
(#1\tikzgraphleftanchor) |
| 40 |
edge[#3] #4 |
| 41 |
(#2\tikzgraphrightanchor); |
| 42 |
} |
| 43 |
}% |
| 44 |
|
| 45 |
|
| 46 |
\def\tikz@lib@graph@store@anchor#1#2{% |
| 47 |
\def\tikz@temp{#1}% |
| 48 |
\ifx\tikz@temp\pgfutil@empty% |
| 49 |
\let#2\tikz@temp% |
| 50 |
\else% |
| 51 |
\def\tikz@temp{.#1}% |
| 52 |
\let#2\tikz@temp% |
| 53 |
\fi% |
| 54 |
}% |
| 55 |
|
| 56 |
\tikzgraphsset{ |
| 57 |
default edge kind/.initial=--, |
| 58 |
--/.style={default edge kind=--}, |
| 59 |
->/.style={default edge kind=->}, |
| 60 |
<-/.style={default edge kind=<-}, |
| 61 |
<->/.style={default edge kind=<->}, |
| 62 |
-!-/.style={default edge kind=-!-}, |
| 63 |
default edge operator/.initial=matching and star, |
| 64 |
left anchor/.code=\tikz@lib@graph@store@anchor{#1}{\tikzgraphleftanchor}, |
| 65 |
right anchor/.code=\tikz@lib@graph@store@anchor{#1}{\tikzgraphrightanchor}, |
| 66 |
left anchor=, |
| 67 |
right anchor= |
| 68 |
}% |
| 69 |
|
| 70 |
|
| 71 |
% |
| 72 |
% Keys for using nodes declared outside a graph inside a graph as if |
| 73 |
% it were declared there |
| 74 |
% |
| 75 |
|
| 76 |
\tikzgraphsset{ |
| 77 |
use existing nodes/.is if=tikz@lib@graph@all |
| 78 |
}% |
| 79 |
|
| 80 |
\tikzset{ |
| 81 |
new set/.code={ |
| 82 |
\expandafter\global\expandafter\let\csname tikz@lg@node@set #1\endcsname\pgfutil@empty% |
| 83 |
}, |
| 84 |
set/.code={ |
| 85 |
\tikz@fig@mustbenamed% |
| 86 |
\ifcsname tikz@lg@node@set #1\endcsname\else |
| 87 |
\tikzerror{Undefined set `#1'}% |
| 88 |
\fi |
| 89 |
\expandafter\def\expandafter\tikz@alias\expandafter{\tikz@alias% |
| 90 |
\expandafter\def\expandafter\pgf@temp\expandafter{\csname tikz@lg@node@set #1\endcsname}% |
| 91 |
\expandafter\expandafter\expandafter\pgfutil@g@addto@macro\expandafter\pgf@temp\expandafter{\expandafter\tikz@lg@do\expandafter{\tikz@fig@name}}% |
| 92 |
}% |
| 93 |
},% |
| 94 |
}% |
| 95 |
|
| 96 |
\newif\iftikz@lib@graph@all |
| 97 |
|
| 98 |
|
| 99 |
% |
| 100 |
% Simple versus multi graphs |
| 101 |
% |
| 102 |
\tikzgraphsset{ |
| 103 |
simple/.code={ |
| 104 |
\iftikz@lib@graph@simple% |
| 105 |
% is already simple, ignore |
| 106 |
\else |
| 107 |
\tikz@lib@graph@simpletrue% |
| 108 |
\pgfkeysalso{operator=\tikz@lib@graph@simple@done}% |
| 109 |
\fi% |
| 110 |
}, |
| 111 |
multi/.code={ |
| 112 |
\tikz@lib@graph@simplefalse% |
| 113 |
} |
| 114 |
}% |
| 115 |
|
| 116 |
\newif\iftikz@lib@graph@simple |
| 117 |
|
| 118 |
\def\tikz@lib@graph@set@simple@edge#1#2#3#4#5{% |
| 119 |
% #1 = kind (<-, ->, ...) |
| 120 |
% #2 = from |
| 121 |
% #3 = to |
| 122 |
% #4 = options |
| 123 |
% #5 = edge nodes |
| 124 |
% |
| 125 |
% Ok, first, test, whether edge exists: |
| 126 |
\ifcsname tikz@lg@e@#3@#2\endcsname% |
| 127 |
\expandafter\global\expandafter\let\csname tikz@lg@e@#3@#2\endcsname\relax% reset |
| 128 |
\fi% |
| 129 |
\expandafter\gdef\csname tikz@lg@e@#2@#3\endcsname{\tikz@lib@graph@make@simple@edge{#1}{#2}{#3}{#4}{#5}}% |
| 130 |
}% |
| 131 |
|
| 132 |
\def\tikz@lib@graph@make@simple@edge#1#2#3#4#5{% |
| 133 |
\pgfqkeys{/tikz/graphs}{new #1={#2}{#3}{#4}{#5}}% |
| 134 |
}% |
| 135 |
|
| 136 |
|
| 137 |
\def\tikz@lib@graph@simple@done{% |
| 138 |
\tikz@lib@graph@pack@node@list% |
| 139 |
{% |
| 140 |
\let\tikz@lg@do\tikz@lib@graph@simple@node% |
| 141 |
\tikz@lib@graph@node@list |
| 142 |
}% |
| 143 |
}% |
| 144 |
|
| 145 |
\def\tikz@lib@graph@simple@node#1{% |
| 146 |
{% |
| 147 |
\def\tikz@lib@graph@simple@from@node{#1}% |
| 148 |
\let\tikz@lg@do\tikz@lib@graph@simple@other@node% |
| 149 |
\tikz@lib@graph@node@list% |
| 150 |
}% |
| 151 |
}% |
| 152 |
|
| 153 |
\def\tikz@lib@graph@simple@other@node#1{% |
| 154 |
\ifcsname tikz@lg@e@\tikz@lib@graph@simple@from@node @#1\endcsname% |
| 155 |
\csname tikz@lg@e@\tikz@lib@graph@simple@from@node @#1\endcsname% |
| 156 |
\expandafter\global\expandafter\let\csname tikz@lg@e@\tikz@lib@graph@simple@from@node @#1\endcsname\relax% |
| 157 |
\fi% |
| 158 |
}% |
| 159 |
|
| 160 |
|
| 161 |
% |
| 162 |
% Basic options |
| 163 |
% |
| 164 |
|
| 165 |
\tikzgraphsset{ |
| 166 |
@nodes styling/.style=, |
| 167 |
nodes/.style={/tikz/graphs/@nodes styling/.append style={,#1}}, |
| 168 |
@edges styling/.initial=, |
| 169 |
edges/.style={/tikz/graphs/@edges styling/.append={,#1}}, |
| 170 |
edge/.style={edges={#1}}, |
| 171 |
@edges node/.initial=, |
| 172 |
edge node/.style={/tikz/graphs/@edges node/.append={#1}}, |
| 173 |
edge label/.style={/tikz/graphs/@edges node/.append={node[auto]{#1}}}, |
| 174 |
edge label'/.style={/tikz/graphs/@edges node/.append={node[auto,swap]{#1}}}, |
| 175 |
@operators/.initial=, |
| 176 |
operator/.style={/tikz/graphs/@operators/.append={#1}}, |
| 177 |
@extra group options/.style=, |
| 178 |
}% |
| 179 |
|
| 180 |
|
| 181 |
\def\tikzgraphinvokeoperator#1{% |
| 182 |
{% |
| 183 |
\pgfkeyslet{/tikz/graphs/@operators}\pgfutil@empty% |
| 184 |
\pgfkeys{/tikz/graphs/.cd,#1}% |
| 185 |
\pgfkeysgetvalue{/tikz/graphs/@operators}\tikz@lib@graph@temp% |
| 186 |
\global\let\tikz@lib@graph@temp\tikz@lib@graph@temp% |
| 187 |
}% |
| 188 |
\tikz@lib@graph@temp% |
| 189 |
\global\let\tikz@lib@graph@temp\relax% |
| 190 |
}% |
| 191 |
|
| 192 |
|
| 193 |
% |
| 194 |
% The parser |
| 195 |
% |
| 196 |
|
| 197 |
\def\tikz@lib@graph@parser{% |
| 198 |
\pgfutil@ifnextchar[{\tikz@lib@graph@parser@}{\tikz@lib@graph@parser@[]}%] |
| 199 |
}% |
| 200 |
|
| 201 |
\def\tikz@lib@graph@parser@[#1]{% |
| 202 |
\setbox\tikz@whichbox=\hbox\bgroup% |
| 203 |
\unhbox\tikz@whichbox% |
| 204 |
\hbox\bgroup |
| 205 |
\bgroup% |
| 206 |
\pgfinterruptpath% |
| 207 |
\scope[graphs/.cd,@graph drawing setup/.try,@operators=,every graph/.try,#1]% |
| 208 |
\begingroup% |
| 209 |
\iftikz@graph@quick% |
| 210 |
\expandafter\tikz@lib@graphs@parse@quick@graph% |
| 211 |
\else% |
| 212 |
\expandafter\tikz@lib@graphs@normal@main% |
| 213 |
\fi% |
| 214 |
}% |
| 215 |
|
| 216 |
\long\def\tikz@lib@graphs@normal@main#1{% |
| 217 |
\pgfkeysgetvalue{/tikz/graphs/@operators}\tikz@lib@graph@outer@operators% |
| 218 |
\let\tikz@lib@graph@options\pgfutil@empty% |
| 219 |
\let\tikz@lib@graph@node@list\pgfutil@empty% |
| 220 |
\pgfkeyssetvalue{/tikz/graphs/placement/depth}{0}% |
| 221 |
\pgfkeyssetvalue{/tikz/graphs/placement/width}{0}% |
| 222 |
\pgfkeyssetvalue{/tikz/graphs/placement/level}{0}% |
| 223 |
\tikz@lib@graph@start@hint@group% |
| 224 |
\tikz@lib@graph@parse@group{#1}% |
| 225 |
\tikz@lib@graph@end@hint@group |
| 226 |
\tikz@lib@graph@outer@operators% |
| 227 |
\let\tikz@lg@do=\tikz@lib@graph@cleanup% |
| 228 |
\tikz@lib@graph@node@list% |
| 229 |
\tikz@lib@graph@main@done% |
| 230 |
}% |
| 231 |
|
| 232 |
\def\tikz@lib@graph@main@done{% |
| 233 |
\endgroup% |
| 234 |
\endscope% |
| 235 |
\endpgfinterruptpath% |
| 236 |
\egroup |
| 237 |
\egroup% |
| 238 |
\egroup% |
| 239 |
\tikz@lib@graph@parser@done% |
| 240 |
}% |
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
\def\tikz@lib@graph@start@hint@group{% |
| 247 |
\pgfkeyssetvalue{/tikz/graphs/placement/local depth}{0}% |
| 248 |
\pgfkeyssetvalue{/tikz/graphs/placement/local width}{0}% |
| 249 |
\pgfkeyssetvalue{/tikz/graphs/placement/chain count}{0}% |
| 250 |
\pgfkeyssetvalue{/tikz/graphs/placement/element count}{0}% |
| 251 |
}% |
| 252 |
|
| 253 |
\def\tikz@lib@graph@end@hint@group{% |
| 254 |
% Get local depth and width outside |
| 255 |
\xdef\tikz@lib@graph@group@depth{\pgfkeysvalueof{/tikz/graphs/placement/local depth}} |
| 256 |
\xdef\tikz@lib@graph@group@width{\pgfkeysvalueof{/tikz/graphs/placement/local width}} |
| 257 |
}% |
| 258 |
|
| 259 |
\def\tikz@lib@graph@hint@aftergroup{% |
| 260 |
\pgfkeysgetvalue{/tikz/graphs/placement/width}\tikz@temp@h% |
| 261 |
\pgfkeysgetvalue{/tikz/graphs/placement/local width}\tikz@temp@lh% |
| 262 |
\pgfkeysgetvalue{/tikz/graphs/placement/local depth}\tikz@temp@lw% |
| 263 |
\pgfmathsetmacro\tikz@temp@h{\tikz@lib@graph@group@width+\tikz@temp@h} |
| 264 |
\pgfmathsetmacro\tikz@temp@lh{\tikz@lib@graph@group@width+\tikz@temp@lh} |
| 265 |
\pgfmathsetmacro\tikz@temp@lw{max(\tikz@lib@graph@group@depth,\tikz@temp@lw)} |
| 266 |
\pgfkeyslet{/tikz/graphs/placement/width}\tikz@temp@h% |
| 267 |
\pgfkeyslet{/tikz/graphs/placement/local width}\tikz@temp@lh% |
| 268 |
\pgfkeyslet{/tikz/graphs/placement/local depth}\tikz@temp@lw% |
| 269 |
% |
| 270 |
\pgfkeysgetvalue{/tikz/graphs/placement/element count}\tikz@temp% |
| 271 |
\c@pgf@counta=\tikz@temp\relax% |
| 272 |
\advance\c@pgf@counta by1\relax% |
| 273 |
\edef\tikz@temp{\the\c@pgf@counta}% |
| 274 |
\pgfkeyslet{/tikz/graphs/placement/element count}\tikz@temp% |
| 275 |
}% |
| 276 |
|
| 277 |
\def\tikz@lib@graph@placement@update{% |
| 278 |
\pgfkeys{/tikz/graphs/placement/logical node depth/.expand once=\tikz@lib@graph@name} |
| 279 |
\let\tikz@lib@graph@node@depth\pgfmathresult |
| 280 |
\pgfkeys{/tikz/graphs/placement/logical node width/.expand once=\tikz@lib@graph@name} |
| 281 |
\let\tikz@lib@graph@node@width\pgfmathresult |
| 282 |
% This is a single node, so update the lengths accordingly |
| 283 |
\pgfkeysgetvalue{/tikz/graphs/placement/width}\tikz@temp@h% |
| 284 |
\pgfkeysgetvalue{/tikz/graphs/placement/local width}\tikz@temp@lh% |
| 285 |
\pgfkeysgetvalue{/tikz/graphs/placement/local depth}\tikz@temp@lw% |
| 286 |
\pgfmathsetmacro\tikz@temp@h{\tikz@lib@graph@node@width+\tikz@temp@h} |
| 287 |
\pgfmathsetmacro\tikz@temp@lh{\tikz@lib@graph@node@width+\tikz@temp@lh} |
| 288 |
\pgfmathsetmacro\tikz@temp@lw{max(\tikz@lib@graph@node@depth,\tikz@temp@lw)} |
| 289 |
\pgfkeyslet{/tikz/graphs/placement/width}\tikz@temp@h% |
| 290 |
\pgfkeyslet{/tikz/graphs/placement/local width}\tikz@temp@lh% |
| 291 |
\pgfkeyslet{/tikz/graphs/placement/local depth}\tikz@temp@lw% |
| 292 |
% |
| 293 |
\pgfkeysgetvalue{/tikz/graphs/placement/element count}\tikz@temp% |
| 294 |
\c@pgf@counta=\tikz@temp\relax% |
| 295 |
\advance\c@pgf@counta by1\relax% |
| 296 |
\edef\tikz@temp{\the\c@pgf@counta}% |
| 297 |
\pgfkeyslet{/tikz/graphs/placement/element count}\tikz@temp% |
| 298 |
}% |
| 299 |
|
| 300 |
\def\tikz@lib@graph@placement@after@chain@update{% |
| 301 |
\pgfkeysgetvalue{/tikz/graphs/placement/depth}\tikz@temp@w% |
| 302 |
\pgfkeysgetvalue{/tikz/graphs/placement/local width}\tikz@temp@lh% |
| 303 |
\pgfkeysgetvalue{/tikz/graphs/placement/local depth}\tikz@temp@lw% |
| 304 |
\pgfmathsetmacro\tikz@temp@w{\tikz@lib@graph@chain@depth+\tikz@temp@w}% |
| 305 |
\pgfmathsetmacro\tikz@temp@lw{\tikz@lib@graph@chain@depth+\tikz@temp@lw}% |
| 306 |
\pgfmathsetmacro\tikz@temp@lh{max(\tikz@lib@graph@chain@width,\tikz@temp@lh)}% |
| 307 |
\pgfkeyslet{/tikz/graphs/placement/depth}\tikz@temp@w% |
| 308 |
\pgfkeyslet{/tikz/graphs/placement/local width}\tikz@temp@lh% |
| 309 |
\pgfkeyslet{/tikz/graphs/placement/local depth}\tikz@temp@lw% |
| 310 |
% |
| 311 |
\pgfkeysgetvalue{/tikz/graphs/placement/chain count}\tikz@temp% |
| 312 |
\c@pgf@counta=\tikz@temp\relax% |
| 313 |
\advance\c@pgf@counta by1\relax% |
| 314 |
\edef\tikz@temp{\the\c@pgf@counta}% |
| 315 |
\pgfkeyslet{/tikz/graphs/placement/chain count}\tikz@temp% |
| 316 |
}% |
| 317 |
|
| 318 |
|
| 319 |
% |
| 320 |
% Parse a group |
| 321 |
% |
| 322 |
|
| 323 |
\long\def\tikz@lib@graph@parse@group#1{ |
| 324 |
\let\tikz@lib@graph@group@qa\pgfutil@empty% |
| 325 |
\let\tikz@lib@graph@group@q\pgfutil@empty% |
| 326 |
\let\tikz@lib@graph@group@c\pgfutil@empty% |
| 327 |
\let\tikz@lib@graph@group@cont\pgfutil@empty% |
| 328 |
\let\tikz@lib@graph@group@conta\pgfutil@empty% |
| 329 |
\tikz@lib@graph@group@check#1\par\pgf@stop@eogroup% |
| 330 |
}% |
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
% |
| 335 |
% Start of a group |
| 336 |
% |
| 337 |
\def\tikz@lib@graph@group@check{% |
| 338 |
\pgfutil@ifnextchar[\tikz@lib@graph@group@opt{\tikz@lib@graph@group@opt[]}%] |
| 339 |
}% |
| 340 |
|
| 341 |
\def\tikz@lib@graph@group@opt[#1]{% |
| 342 |
\let\tikz@lib@graph@parse@extras\pgfutil@empty% |
| 343 |
\tikzgraphsset{ |
| 344 |
@operators=, |
| 345 |
every group/.try, |
| 346 |
@extra group options, |
| 347 |
@extra group options/.style=,% |
| 348 |
#1}% |
| 349 |
\expandafter\tikz@lib@graph@par\tikz@lib@graph@parse@extras% |
| 350 |
}% |
| 351 |
|
| 352 |
\tikzgraphsset{ |
| 353 |
parse/.code={\expandafter\def\expandafter\tikz@lib@graph@parse@extras\expandafter{\tikz@lib@graph@parse@extras#1}}, |
| 354 |
}% |
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
% |
| 359 |
% Remove \par |
| 360 |
% |
| 361 |
|
| 362 |
\def\tikz@lib@graph@par{% |
| 363 |
\pgfutil@ifnextchar\bgroup{\tikz@lib@graph@par@@}{\tikz@lib@graph@par@}% |
| 364 |
}% |
| 365 |
\long\def\tikz@lib@graph@par@#1\par{% |
| 366 |
\pgfutil@ifnextchar\pgf@stop@eogroup{% |
| 367 |
\expandafter\tikz@lib@graph@quotes\tikz@lib@graph@group@c#1"}{% |
| 368 |
\expandafter\def\expandafter\tikz@lib@graph@group@c\expandafter{\tikz@lib@graph@group@c#1}% |
| 369 |
\tikz@lib@graph@par% |
| 370 |
}% |
| 371 |
}% |
| 372 |
\long\def\tikz@lib@graph@par@@#1{% |
| 373 |
\expandafter\def\expandafter\tikz@lib@graph@group@c\expandafter{\tikz@lib@graph@group@c{#1}}% |
| 374 |
\tikz@lib@graph@par |
| 375 |
}% |
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
% |
| 380 |
% Replace ..."..."... by ..."{...}"... |
| 381 |
% |
| 382 |
\def\tikz@lib@graph@quotes{% |
| 383 |
\pgfutil@ifnextchar\bgroup{\tikz@lib@graph@quotes@@}{\tikz@lib@graph@quotes@}% |
| 384 |
}% |
| 385 |
\def\tikz@lib@graph@quotes@#1"{% |
| 386 |
\pgfutil@ifnextchar\pgf@stop@eogroup{% |
| 387 |
\tikz@lib@graph@passon{#1}% |
| 388 |
}{% |
| 389 |
\expandafter\def\expandafter\tikz@lib@graph@group@q\expandafter{\tikz@lib@graph@group@q#1"}% |
| 390 |
\tikz@lib@graph@quotes@cont% |
| 391 |
}% |
| 392 |
}% |
| 393 |
|
| 394 |
\def\tikz@lib@graph@quotes@cont#1"#2"{% |
| 395 |
\pgfutil@ifnextchar\pgf@stop@eogroup{% |
| 396 |
\tikz@lib@graph@passon{{#1}"#2}}{% |
| 397 |
\expandafter\def\expandafter\tikz@lib@graph@group@q\expandafter{\tikz@lib@graph@group@q{#1}"#2"}% |
| 398 |
\tikz@lib@graph@quotes@cont}% |
| 399 |
}% |
| 400 |
|
| 401 |
\def\tikz@lib@graph@quotes@@#1{% |
| 402 |
\expandafter\def\expandafter\tikz@lib@graph@group@q\expandafter{\tikz@lib@graph@group@q{#1}}% |
| 403 |
\tikz@lib@graph@quotes% |
| 404 |
}% |
| 405 |
|
| 406 |
|
| 407 |
|
| 408 |
% |
| 409 |
% Replace ..."..."... by ..."{...}"... (active version) |
| 410 |
% |
| 411 |
{% |
| 412 |
\catcode`\"=13\relax |
| 413 |
|
| 414 |
\gdef\tikz@lib@graph@passon#1{\expandafter\tikz@lib@graph@quotesactive\tikz@lib@graph@group@q#1"}% |
| 415 |
|
| 416 |
\gdef\tikz@lib@graph@quotesactive{% |
| 417 |
\pgfutil@ifnextchar\bgroup{\tikz@lib@graph@quotesactive@@}{\tikz@lib@graph@quotesactive@}% |
| 418 |
}% |
| 419 |
\gdef\tikz@lib@graph@quotesactive@#1"{% |
| 420 |
\pgfutil@ifnextchar\pgf@stop@eogroup{% |
| 421 |
\expandafter\tikz@lib@graph@encloser\tikz@lib@graph@group@qa#1[% |
| 422 |
}{% |
| 423 |
\expandafter\def\expandafter\tikz@lib@graph@group@qa\expandafter{\tikz@lib@graph@group@qa#1"}% |
| 424 |
\tikz@lib@graph@quotesactive@cont% |
| 425 |
}% |
| 426 |
}% |
| 427 |
|
| 428 |
\gdef\tikz@lib@graph@quotesactive@cont#1"#2"{% |
| 429 |
\pgfutil@ifnextchar\pgf@stop@eogroup{% |
| 430 |
\expandafter\tikz@lib@graph@encloser\tikz@lib@graph@group@qa{#1}"#2[}{% |
| 431 |
\expandafter\def\expandafter\tikz@lib@graph@group@qa\expandafter{\tikz@lib@graph@group@qa{#1}"#2"}% |
| 432 |
\tikz@lib@graph@quotesactive@cont}% |
| 433 |
}% |
| 434 |
|
| 435 |
\gdef\tikz@lib@graph@quotesactive@@#1{% |
| 436 |
\expandafter\def\expandafter\tikz@lib@graph@group@qa\expandafter{\tikz@lib@graph@group@qa{#1}}% |
| 437 |
\tikz@lib@graph@quotesactive% |
| 438 |
}% |
| 439 |
}% |
| 440 |
|
| 441 |
|
| 442 |
|
| 443 |
|
| 444 |
% |
| 445 |
% Replace ...[...]... by ...[{...}]... |
| 446 |
% |
| 447 |
\def\tikz@lib@graph@encloser{% |
| 448 |
\pgfutil@ifnextchar\bgroup{\tikz@lib@graph@encloser@@}{\tikz@lib@graph@encloser@}% |
| 449 |
}% |
| 450 |
\def\tikz@lib@graph@encloser@#1[{% |
| 451 |
\pgfutil@ifnextchar\pgf@stop@eogroup{% |
| 452 |
\expandafter\tikz@lib@graph@semi\tikz@lib@graph@group@cont#1;% |
| 453 |
}{% |
| 454 |
\expandafter\def\expandafter\tikz@lib@graph@group@cont\expandafter{\tikz@lib@graph@group@cont#1[}%] |
| 455 |
\tikz@lib@graph@encloser@cont% |
| 456 |
}% |
| 457 |
}% |
| 458 |
|
| 459 |
\def\tikz@lib@graph@encloser@cont#1]#2[{% |
| 460 |
\pgfutil@ifnextchar\pgf@stop@eogroup{% |
| 461 |
\expandafter\tikz@lib@graph@semi\tikz@lib@graph@group@cont{#1}]#2;}{% |
| 462 |
\expandafter\def\expandafter\tikz@lib@graph@group@cont\expandafter{\tikz@lib@graph@group@cont{#1}]#2[}% |
| 463 |
\tikz@lib@graph@encloser@cont}% |
| 464 |
}% |
| 465 |
|
| 466 |
\def\tikz@lib@graph@encloser@@#1{% |
| 467 |
\expandafter\def\expandafter\tikz@lib@graph@group@cont\expandafter{\tikz@lib@graph@group@cont{#1}}% |
| 468 |
\tikz@lib@graph@encloser% |
| 469 |
}% |
| 470 |
|
| 471 |
|
| 472 |
|
| 473 |
|
| 474 |
% |
| 475 |
% Replace ; by , |
| 476 |
% |
| 477 |
|
| 478 |
\def\tikz@lib@graph@semi{% |
| 479 |
\pgfutil@ifnextchar\bgroup{\tikz@lib@graph@semi@@}{\tikz@lib@graph@semi@}% |
| 480 |
}% |
| 481 |
\def\tikz@lib@graph@semi@#1;{% |
| 482 |
\pgfutil@ifnextchar\pgf@stop@eogroup{% |
| 483 |
\expandafter\tikz@lib@graph@main@parser\tikz@lib@graph@group@conta#1,}{% |
| 484 |
\expandafter\def\expandafter\tikz@lib@graph@group@conta\expandafter{\tikz@lib@graph@group@conta#1,}% |
| 485 |
\tikz@lib@graph@semi% |
| 486 |
}% |
| 487 |
}% |
| 488 |
\def\tikz@lib@graph@semi@@#1{% |
| 489 |
\expandafter\def\expandafter\tikz@lib@graph@group@conta\expandafter{\tikz@lib@graph@group@conta{#1}}% |
| 490 |
\tikz@lib@graph@semi% |
| 491 |
}% |
| 492 |
|
| 493 |
|
| 494 |
% |
| 495 |
% Main parse |
| 496 |
% |
| 497 |
|
| 498 |
\def\tikz@lib@graph@main@parser{% |
| 499 |
\begingroup% |
| 500 |
\pgfkeyssetvalue{/tikz/graphs/placement/local depth}{0}% |
| 501 |
\pgfkeyssetvalue{/tikz/graphs/placement/local width}{0}% |
| 502 |
\let\tikz@lib@graph@stored@actions\pgfutil@empty% |
| 503 |
\let\tikz@lib@graph@node@list\pgfutil@empty% reset |
| 504 |
\tikz@lib@graph@main@parser@start% |
| 505 |
}% |
| 506 |
\def\tikz@lib@graph@main@parser@start{% |
| 507 |
\pgfutil@ifnextchar\bgroup{\tikz@lib@graph@protect@group}{\tikz@lib@graph@main@parser@cont}% |
| 508 |
}% |
| 509 |
|
| 510 |
\def\tikz@lib@graph@protect@group#1{% skip space |
| 511 |
\pgfutil@ifnextchar\relax{\tikz@lib@graph@main@parser@cont{{#1}}}{\tikz@lib@graph@main@parser@cont{{#1}}}% |
| 512 |
}% |
| 513 |
|
| 514 |
\def\tikz@lib@graph@main@parser@cont{\tikz@lib@graph@check@quotes\tikz@lib@graph@main@parser@cont@normal}% |
| 515 |
\def\tikz@lib@graph@main@parser@cont@normal#1,{% |
| 516 |
\tikz@lib@graph@parse@one#1-\pgf@stop@eodashes% |
| 517 |
}% |
| 518 |
|
| 519 |
\def\tikz@lib@graph@parse@one{% |
| 520 |
\pgfutil@ifnextchar\bgroup\tikz@lib@graph@scope\tikz@lib@graph@node% |
| 521 |
}% |
| 522 |
|
| 523 |
|
| 524 |
|
| 525 |
% Special quoted nodes |
| 526 |
|
| 527 |
\def\tikz@lib@graph@check@quotes#1{% |
| 528 |
\let\tikz@lib@graph@cont@quote#1% |
| 529 |
\pgfutil@ifnextchar"{\begingroup\pgfkeys@temptoks{}\pgfutil@empty\tikz@lib@graph@quote@parser}{\tikz@lib@graph@check@quotes@active}% |
| 530 |
}% |
| 531 |
{% |
| 532 |
\catcode`\"=13\relax |
| 533 |
\gdef\tikz@lib@graph@check@quotes@active{% |
| 534 |
\pgfutil@ifnextchar"{\begingroup\pgfkeys@temptoks{}\pgfutil@empty\tikz@lib@graph@quote@parser@active}{\tikz@lib@graph@cont@quote}% |
| 535 |
}% |
| 536 |
\gdef\tikz@lib@graph@quote@parser@active"#1"{% |
| 537 |
\pgfkeys@temptoks\expandafter{\the\pgfkeys@temptoks #1}% |
| 538 |
\pgfutil@ifnextchar"{\pgfkeys@temptoks\expandafter{\the\pgfkeys@temptoks "}\tikz@lib@graph@quote@parser@active}{\tikz@lib@graph@quote@parser@done}% |
| 539 |
}% |
| 540 |
}% |
| 541 |
|
| 542 |
\def\tikz@lib@graph@quote@parser"#1"{% |
| 543 |
\pgfkeys@temptoks\expandafter{\the\pgfkeys@temptoks #1}% |
| 544 |
\pgfutil@ifnextchar"{\pgfkeys@temptoks\expandafter{\the\pgfkeys@temptoks "}\tikz@lib@graph@quote@parser}{\tikz@lib@graph@quote@parser@done}% |
| 545 |
}% |
| 546 |
|
| 547 |
\def\tikz@lib@graph@quote@parser@done{% |
| 548 |
{\expandafter\scantokens\expandafter{% |
| 549 |
\expandafter\expandafter\expandafter\tikzlibgraphactivations\expandafter\expandafter\expandafter\tikzlibgraphdoedef\expandafter{\the\pgfkeys@temptoks}% |
| 550 |
}}% |
| 551 |
{\expandafter\scantokens\expandafter{\expandafter\tikzlibgraphactivationsbrace\expandafter\xdef\expandafter\tikzlibgraphreplaced\expandafter<\tikzlibgraphreplaced>\catcode`\}=2\relax}}% |
| 552 |
\edef\tikzlibgraphreplaced{\expandafter\detokenize\expandafter{\tikzlibgraphreplaced}} |
| 553 |
\pgfutil@ifnextchar/\tikz@lib@graph@quotes@slash\tikz@lib@graph@quotes@no@slash% |
| 554 |
}% |
| 555 |
\def\tikz@lib@graph@quotes@no@slash{% |
| 556 |
\expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter% |
| 557 |
\tikz@smuggle\expandafter\expandafter\expandafter{\expandafter\tikzlibgraphreplaced\expandafter/\expandafter{\the\pgfkeys@temptoks}}% |
| 558 |
\expandafter\endgroup\expandafter\tikz@lib@graph@cont@quote\tikz@smuggle% |
| 559 |
}% |
| 560 |
\def\tikz@lib@graph@quotes@slash/{% |
| 561 |
\pgfutil@ifnextchar/% Ah, double slash... |
| 562 |
{\tikz@lib@graph@quotes@no@slash/}{\expandafter\endgroup\expandafter\tikz@lib@graph@cont@quote\tikzlibgraphreplaced/}% |
| 563 |
}% |
| 564 |
\def\tikzlibgraphdoedef{\xdef\tikzlibgraphreplaced}% |
| 565 |
|
| 566 |
\def\tikz@lib@prepare@active#1#2#3{% |
| 567 |
{% |
| 568 |
\catcode`#1=13\relax% |
| 569 |
\scantokens{\gdef\tikzlibgraphactivator{\def#2{@#3@}}}% |
| 570 |
}% |
| 571 |
\pgfutil@g@addto@macro\tikzlibgraphactivations{\catcode`#1=13\relax}% |
| 572 |
\expandafter\pgfutil@g@addto@macro\expandafter\tikzlibgraphactivations\expandafter{\tikzlibgraphactivator}% |
| 573 |
}% |
| 574 |
|
| 575 |
\let\tikzlibgraphactivations\pgfutil@empty |
| 576 |
|
| 577 |
% |
| 578 |
% Remove \outer from \+ for plain TeX |
| 579 |
% |
| 580 |
|
| 581 |
\outer\def\tikz@lib@outer@test{\tabalign}% |
| 582 |
\ifx\+\tikz@lib@outer@test |
| 583 |
\def\+{\tabalign} |
| 584 |
\fi |
| 585 |
|
| 586 |
\tikz@lib@prepare@active{\$}{$}{DOLLAR SIGN}% $ |
| 587 |
\tikz@lib@prepare@active{\&}{&}{AMPERSAND}% |
| 588 |
\tikz@lib@prepare@active{\^}{^}{CIRCUMFLEX ACCENT}% |
| 589 |
\tikz@lib@prepare@active{\~}{~}{TILDE}% |
| 590 |
\tikz@lib@prepare@active{\_}{_}{LOW LINE}% |
| 591 |
\tikz@lib@prepare@active{\|}{|}{VERTICAL LINE}% |
| 592 |
\tikz@lib@prepare@active{\[}{[}{LEFT SQUARE BRACKET}% |
| 593 |
\tikz@lib@prepare@active{\]}{]}{RIGHT SQUARE BRACKET}% |
| 594 |
\tikz@lib@prepare@active{\(}{(}{LEFT PARENTHESIS}% |
| 595 |
\tikz@lib@prepare@active{\)}{)}{RIGHT PARENTHESIS}% |
| 596 |
\tikz@lib@prepare@active{\/}{/}{SOLIDUS}% |
| 597 |
\tikz@lib@prepare@active{\.}{.}{FULL STOP}% |
| 598 |
\tikz@lib@prepare@active{\-}{-}{HYPHEN MINUS}% |
| 599 |
\tikz@lib@prepare@active{\,}{,}{COMMA}% |
| 600 |
\tikz@lib@prepare@active{\+}{+}{PLUS SIGN}% |
| 601 |
\tikz@lib@prepare@active{\*}{*}{ASTERISK}% |
| 602 |
\tikz@lib@prepare@active{\'}{'}{APOSTROPHE}% |
| 603 |
\tikz@lib@prepare@active{\!}{!}{EXCLAMATION MARK}% |
| 604 |
\tikz@lib@prepare@active{\"}{"}{QUOTATION MARK}% |
| 605 |
\tikz@lib@prepare@active{\:}{:}{COLON}% |
| 606 |
\tikz@lib@prepare@active{\;}{;}{SEMINCOLON}% |
| 607 |
\tikz@lib@prepare@active{\<}{<}{LESS THAN SIGN}% |
| 608 |
\tikz@lib@prepare@active{\=}{=}{EQUALS SIGN}% |
| 609 |
\tikz@lib@prepare@active{\>}{>}{GREATER THAN SIGN}% |
| 610 |
\tikz@lib@prepare@active{\?}{?}{QUESTION MARK}% |
| 611 |
%\tikz@lib@prepare@active{\@}{@}{COMMERCIAL AT}% |
| 612 |
\tikz@lib@prepare@active{\`}{`}{GRAVE ACCENT}% |
| 613 |
{\catcode`\%=11\catcode`\#=11 |
| 614 |
\tikz@lib@prepare@active{\%}{%}{PERCENT SIGN} |
| 615 |
\tikz@lib@prepare@active{\#}{#}{NUMBER SIGN} |
| 616 |
} |
| 617 |
|
| 618 |
\pgfutil@g@addto@macro\tikzlibgraphactivations{\catcode`\\=13\relax}% |
| 619 |
{% |
| 620 |
\catcode`\|=0\relax |
| 621 |
\catcode`\\=13\relax |
| 622 |
|pgfutil@g@addto@macro|tikzlibgraphactivations{|def\{@REVERSE SOLIDUS@}}% |
| 623 |
}% |
| 624 |
{% |
| 625 |
\gdef\tikzlibgraphscommercialat{@COMMERCIAL AT@}% |
| 626 |
\let\g=\pgfutil@g@addto@macro |
| 627 |
\catcode`\@=13\relax |
| 628 |
\g\tikzlibgraphactivations{\catcode`\@=13\relax\let@=\tikzlibgraphscommercialat}% |
| 629 |
}% |
| 630 |
|
| 631 |
\def\tikzlibgraphactivationsbrace{% |
| 632 |
\catcode`\{=13\relax% |
| 633 |
\catcode`\}=13\relax% |
| 634 |
\catcode`\<=1\relax% |
| 635 |
\catcode`\>=2\relax% |
| 636 |
}% |
| 637 |
{% |
| 638 |
\catcode`\{=13\relax% |
| 639 |
\catcode`\}=13\relax% |
| 640 |
\catcode`\<=1\relax% |
| 641 |
\catcode`\>=2\relax% |
| 642 |
\pgfutil@g@addto@macro\tikzlibgraphactivationsbrace<\def{<@LEFT CURLY BRACE@>> %} |
| 643 |
\pgfutil@g@addto@macro\tikzlibgraphactivationsbrace<\def}<@RIGHT CURLY BRACE@>> %{ |
| 644 |
>% |
| 645 |
|
| 646 |
% A normal node |
| 647 |
|
| 648 |
% First, check for special quote syntax: |
| 649 |
|
| 650 |
\def\tikz@lib@graph@node{\tikz@lib@graph@check@quotes\tikz@lib@graph@node@normal}% |
| 651 |
|
| 652 |
\def\tikz@lib@graph@node@normal{% |
| 653 |
\pgfutil@ifnextchar({\tikz@lib@graph@node@dressed}{\tikz@lib@graph@node@naked}% |
| 654 |
}% |
| 655 |
|
| 656 |
\def\tikz@lib@graph@node@dressed(#1){% |
| 657 |
% Add extra braces around nodes to protect dashes |
| 658 |
\tikz@lib@graph@node@naked{(#1)}% |
| 659 |
}% |
| 660 |
|
| 661 |
\def\tikz@lib@graph@node@naked#1-{% |
| 662 |
% Detect trailing < |
| 663 |
\tikz@lib@graph@@node#1<\pgf@stop% |
| 664 |
}% |
| 665 |
|
| 666 |
\def\tikz@lib@graph@@node#1<#2\pgf@stop% |
| 667 |
{ |
| 668 |
% |
| 669 |
% #1 will be a node (not a group) |
| 670 |
% |
| 671 |
% Syntax: node name [options] |
| 672 |
% |
| 673 |
% Grab node name |
| 674 |
\tikz@lib@graph@grab@name#1\pgf@stop% |
| 675 |
\tikz@lib@graph@stored@actions% |
| 676 |
\pgfutil@ifnextchar\pgf@stop@eodashes{% |
| 677 |
\tikz@lib@graph@graph@done% |
| 678 |
}{% |
| 679 |
% |
| 680 |
% Now, get arrow kind |
| 681 |
% |
| 682 |
\def\pgf@test{#2}% |
| 683 |
\ifx\pgf@test\pgfutil@empty% |
| 684 |
\expandafter\tikz@lib@graph@no@back@arrow% |
| 685 |
\else% |
| 686 |
\expandafter\tikz@lib@graph@back@arrow% |
| 687 |
\fi% |
| 688 |
}% |
| 689 |
}% |
| 690 |
|
| 691 |
\def\tikz@lib@graph@no@back@arrow{% |
| 692 |
\pgfutil@ifnextchar>\tikz@lib@graph@forward@arrow{% |
| 693 |
\pgfutil@ifnextchar-\tikz@lib@graph@undirected@arrow{% |
| 694 |
\pgfutil@ifnextchar!\tikz@lib@graph@no@arrow{% |
| 695 |
\tikzerror{One of the arrow types <-, --, ->, -!- or <-> expected}% |
| 696 |
\tikz@lib@graph@undirected@arrow% |
| 697 |
}% |
| 698 |
}% |
| 699 |
}% |
| 700 |
}% |
| 701 |
|
| 702 |
\def\tikz@lib@graph@undirected@arrow-{% |
| 703 |
\def\tikz@lib@graph@arrow@type{--}% |
| 704 |
\tikz@lib@graph@after@arrow% |
| 705 |
}% |
| 706 |
|
| 707 |
\def\tikz@lib@graph@forward@arrow>{% |
| 708 |
\def\tikz@lib@graph@arrow@type{->}% |
| 709 |
\tikz@lib@graph@after@arrow% |
| 710 |
}% |
| 711 |
|
| 712 |
\def\tikz@lib@graph@bi@arrow>{% |
| 713 |
\def\tikz@lib@graph@arrow@type{<->}% |
| 714 |
\tikz@lib@graph@after@arrow% |
| 715 |
}% |
| 716 |
|
| 717 |
\def\tikz@lib@graph@no@arrow!-{% |
| 718 |
\def\tikz@lib@graph@arrow@type{-!-}% |
| 719 |
\tikz@lib@graph@after@arrow% |
| 720 |
}% |
| 721 |
|
| 722 |
\def\tikz@lib@graph@back@arrow{% |
| 723 |
\pgfutil@ifnextchar>{\tikz@lib@graph@bi@arrow}{% |
| 724 |
\def\tikz@lib@graph@arrow@type{<-}% |
| 725 |
\tikz@lib@graph@after@arrow% |
| 726 |
}% |
| 727 |
}% |
| 728 |
|
| 729 |
\def\tikz@lib@graph@after@arrow{% |
| 730 |
\pgfutil@ifnextchar[{\tikz@lib@graph@after@arrow@opt}{\tikz@lib@graph@after@arrow@opt[]}%] |
| 731 |
}% |
| 732 |
|
| 733 |
\def\tikz@lib@graph@after@arrow@opt[#1]{% |
| 734 |
% |
| 735 |
% Ok, first recolor |
| 736 |
% |
| 737 |
\tikzgraphinvokeoperator{recolor source by=source''} |
| 738 |
\tikzgraphinvokeoperator{recolor target by=target'} |
| 739 |
% Save action for next node |
| 740 |
\expandafter\def\expandafter\tikz@lib@graph@stored@actions\expandafter{% |
| 741 |
\expandafter\tikz@lib@graph@joiner\expandafter{\tikz@lib@graph@arrow@type}{#1}}% |
| 742 |
% |
| 743 |
\tikzgdeventgroupcallback{descendants}% |
| 744 |
\tikz@lib@graph@parse@one% |
| 745 |
}% |
| 746 |
|
| 747 |
\def\tikz@lib@graph@joiner#1#2{% |
| 748 |
\tikzgraphinvokeoperator{recolor source by=source'} |
| 749 |
\tikzgraphinvokeoperator{recolor source'' by=source} |
| 750 |
{% |
| 751 |
\tikz@enable@edge@quotes% |
| 752 |
\pgfkeyssetvalue{/tikz/graphs/default edge kind}{#1}% |
| 753 |
\pgfkeys{/tikz/graphs/.cd,@operators=,% |
| 754 |
/tikz/graphs/.unknown/.code=\tikz@lib@graph@unknown@edge@option{##1},#2}% |
| 755 |
\pgfkeysgetvalue{/tikz/graphs/@operators}\pgf@temp% |
| 756 |
\ifx\pgf@temp\pgfutil@empty% |
| 757 |
\edef\pgf@temp{\noexpand\pgfkeys{/tikz/graphs/.cd,\pgfkeysvalueof{/tikz/graphs/default edge operator}}}% |
| 758 |
\pgf@temp% |
| 759 |
\pgfkeysgetvalue{/tikz/graphs/@operators}\pgf@temp% |
| 760 |
\fi% |
| 761 |
\pgf@temp% |
| 762 |
}% |
| 763 |
\tikzgraphinvokeoperator{not source',not target'} |
| 764 |
}% |
| 765 |
|
| 766 |
\def\tikz@lib@graph@unknown@edge@option#1{% |
| 767 |
\def\tikz@temp{/tikz/graphs/@edges styling/.append=} |
| 768 |
\expandafter\expandafter\expandafter\pgfkeys% |
| 769 |
\expandafter\expandafter\expandafter{\expandafter\tikz@temp\expandafter{\expandafter,\pgfkeyscurrentname={#1}}} |
| 770 |
}% |
| 771 |
|
| 772 |
\def\tikz@lib@graph@graph@done\pgf@stop@eodashes{% |
| 773 |
% Get local depth and width outside |
| 774 |
\xdef\tikz@lib@graph@chain@depth{\pgfkeysvalueof{/tikz/graphs/placement/local depth}} |
| 775 |
\xdef\tikz@lib@graph@chain@width{\pgfkeysvalueof{/tikz/graphs/placement/local width}} |
| 776 |
% Get node list outside... |
| 777 |
\expandafter% |
| 778 |
\endgroup% |
| 779 |
\expandafter\expandafter\expandafter\def% |
| 780 |
\expandafter\expandafter\expandafter\tikz@lib@graph@node@list% |
| 781 |
\expandafter\expandafter\expandafter{\expandafter\tikz@lib@graph@node@list\tikz@lib@graph@node@list}% |
| 782 |
% Compute new local depth and width of group... |
| 783 |
\tikz@lib@graph@placement@after@chain@update |
| 784 |
% |
| 785 |
\pgfutil@ifnextchar\pgf@stop@eogroup% |
| 786 |
\tikz@lib@graph@graph@group@done% |
| 787 |
\tikz@lib@graph@main@parser% |
| 788 |
}% |
| 789 |
|
| 790 |
\def\tikz@lib@graph@graph@group@done\pgf@stop@eogroup{% |
| 791 |
\pgfkeysvalueof{/tikz/graphs/@operators}% |
| 792 |
}% |
| 793 |
|
| 794 |
|
| 795 |
|
| 796 |
% |
| 797 |
% Handle node |
| 798 |
% |
| 799 |
\def\tikz@lib@graph@grab@name{% |
| 800 |
\pgfutil@ifnextchar\foreach\tikz@lib@graph@do@foreach\tikz@lib@graph@parse@node@text% |
| 801 |
}% |
| 802 |
|
| 803 |
\def\tikz@lib@graph@do@foreach\foreach#1in{% |
| 804 |
\pgfutil@ifnextchar\bgroup{\tikz@lib@graph@do@foreach@normal{#1}}{\def\tikz@temp{#1}\tikz@lib@graph@do@foreach@macro}% |
| 805 |
}% |
| 806 |
\def\tikz@lib@graph@do@foreach@macro#1{% |
| 807 |
\expandafter\expandafter\expandafter\tikz@lib@graph@do@foreach@normal\expandafter\tikz@temp\expandafter{#1}% |
| 808 |
}% |
| 809 |
|
| 810 |
\def\tikz@lib@graph@do@foreach@normal#1#2#3\pgf@stop{% |
| 811 |
% Ok, we do a parse on a foreach loop. |
| 812 |
\begingroup |
| 813 |
\let\tikz@lib@graph@node@list@saved\pgfutil@empty% |
| 814 |
\xdef\tikz@lib@graph@saved@placement{% |
| 815 |
{\pgfkeysvalueof{/tikz/graphs/placement/local depth}}% |
| 816 |
{\pgfkeysvalueof{/tikz/graphs/placement/local width}}% |
| 817 |
{\pgfkeysvalueof{/tikz/graphs/placement/chain count}}% |
| 818 |
{\pgfkeysvalueof{/tikz/graphs/placement/element count}}% |
| 819 |
{\pgfkeysvalueof{/tikz/graphs/placement/width}}% |
| 820 |
{\pgfkeysvalueof{/tikz/graphs/placement/depth}}% |
| 821 |
}% |
| 822 |
\foreach #1 in {#2}% |
| 823 |
{% |
| 824 |
\let\tikz@lib@graph@node@list\tikz@lib@graph@node@list@saved% |
| 825 |
\expandafter\tikz@lib@graph@setup@placement\tikz@lib@graph@saved@placement% |
| 826 |
\tikz@lib@graph@parse@group{#3}% |
| 827 |
\xdef\tikz@lib@graph@saved@placement{% |
| 828 |
{\pgfkeysvalueof{/tikz/graphs/placement/local depth}}% |
| 829 |
{\pgfkeysvalueof{/tikz/graphs/placement/local width}}% |
| 830 |
{\pgfkeysvalueof{/tikz/graphs/placement/chain count}}% |
| 831 |
{\pgfkeysvalueof{/tikz/graphs/placement/element count}}% |
| 832 |
{\pgfkeysvalueof{/tikz/graphs/placement/width}}% |
| 833 |
{\pgfkeysvalueof{/tikz/graphs/placement/depth}}% |
| 834 |
}% |
| 835 |
% TODO: Need to also save hints! |
| 836 |
\global\let\tikz@lib@graph@node@list@saved\tikz@lib@graph@node@list% |
| 837 |
}% |
| 838 |
\expandafter% |
| 839 |
\endgroup% |
| 840 |
\expandafter\expandafter\expandafter\def% |
| 841 |
\expandafter\expandafter\expandafter\tikz@lib@graph@node@list% |
| 842 |
\expandafter\expandafter\expandafter{\expandafter\tikz@lib@graph@node@list\tikz@lib@graph@node@list@saved}% |
| 843 |
\expandafter\tikz@lib@graph@setup@placement\tikz@lib@graph@saved@placement% |
| 844 |
}% |
| 845 |
|
| 846 |
\def\tikz@lib@graph@setup@placement#1#2#3#4#5#6{% |
| 847 |
\pgfkeyssetvalue{/tikz/graphs/placement/local depth}{#1}% |
| 848 |
\pgfkeyssetvalue{/tikz/graphs/placement/local width}{#2}% |
| 849 |
\pgfkeyssetvalue{/tikz/graphs/placement/chain count}{#3}% |
| 850 |
\pgfkeyssetvalue{/tikz/graphs/placement/element count}{#4}% |
| 851 |
\pgfkeyssetvalue{/tikz/graphs/placement/width}{#5}% |
| 852 |
\pgfkeyssetvalue{/tikz/graphs/placement/depth}{#6}% |
| 853 |
}% |
| 854 |
|
| 855 |
\def\tikz@lib@graph@parse@node@text#1\pgf@stop{% |
| 856 |
% |
| 857 |
% Ok, first test whether #1 contains "//" |
| 858 |
% |
| 859 |
\pgfutil@in@{//}{#1 } |
| 860 |
\ifpgfutil@in@% |
| 861 |
% Ok, a layout node: |
| 862 |
\tikz@lib@parse@layout@node#1\pgf@stop% |
| 863 |
\else% |
| 864 |
\tikz@lib@graph@fake@nodefalse |
| 865 |
\let\tikz@lib@graph@node@parsed\tikz@lib@graph@node@opt@normal% |
| 866 |
\def\tikz@lib@graph@empty@node@parsed{\tikzgdeventcallback{node}{}}% |
| 867 |
\tikz@lib@parse@normal@node#1[\pgf@stop% |
| 868 |
\fi% |
| 869 |
}% |
| 870 |
|
| 871 |
\newif\iftikzgraphsautonumbernodes |
| 872 |
\newcount\tikz@lib@auto@number |
| 873 |
|
| 874 |
\def\tikz@lib@do@autonumber{% |
| 875 |
\ifx\tikz@lib@graph@name@only\pgfutil@empty% |
| 876 |
\else% |
| 877 |
\edef\tikz@lib@graph@name@only{\tikz@lib@graph@name@only\tikz@lib@auto@sep\the\tikz@lib@auto@number}% |
| 878 |
\global\advance\tikz@lib@auto@number by1\relax% |
| 879 |
\fi% |
| 880 |
}% |
| 881 |
|
| 882 |
% |
| 883 |
% Parse the normal part of a node (name and, possibly, text after slash) |
| 884 |
% |
| 885 |
|
| 886 |
\def\tikz@lib@parse@normal@node#1[{ |
| 887 |
% |
| 888 |
% Test whether #1 contains "/" or "__" |
| 889 |
% |
| 890 |
\pgfutil@in@{/}{#1}% |
| 891 |
\ifpgfutil@in@% |
| 892 |
\tikz@lib@parse@node@with@slash#1\pgf@stop% |
| 893 |
\else |
| 894 |
\pgfutil@in@{__}{#1}% |
| 895 |
\ifpgfutil@in@% |
| 896 |
\tikz@lib@parse@node@with@doubleunder#1\pgf@stop% |
| 897 |
\else |
| 898 |
\edef\pgf@marshal{\noexpand\pgfkeys@spdef\noexpand\tikz@lib@graph@name@only{#1}}% |
| 899 |
\pgf@marshal% |
| 900 |
\let\tikz@lib@graph@node@text\tikz@lib@graph@name@only% |
| 901 |
\edef\tikz@lib@graph@name{\tikz@lib@graph@path\tikz@lib@graph@name@only}% |
| 902 |
\fi% |
| 903 |
\fi% |
| 904 |
\tikz@lib@graph@handle@node@cont% |
| 905 |
}% |
| 906 |
|
| 907 |
\def\tikz@lib@parse@node@with@slash#1/{ |
| 908 |
\pgfkeys@spdef\tikz@lib@graph@name@only{#1}% |
| 909 |
\ifx\tikz@lib@graph@name@only\pgfutil@empty% |
| 910 |
\global\advance\tikz@fig@count by1\relax |
| 911 |
\edef\tikz@lib@graph@name@only{tikz@f@\the\tikz@fig@count}% |
| 912 |
\fi% |
| 913 |
\edef\tikz@lib@graph@name{\tikz@lib@graph@path\tikz@lib@graph@name@only}% |
| 914 |
\pgfutil@ifnextchar"\tikz@lg@slash@quote{\pgfutil@ifnextchar\tikz@active@quotes@token\tikz@lg@slash@quote@active\tikz@lg@slash@cont} |
| 915 |
}% |
| 916 |
\def\tikz@lg@slash@quote"#1"#2\pgf@stop{% |
| 917 |
\iftikz@handle@active@nodes% |
| 918 |
\def\tikz@lib@graph@node@text{\scantokens{#1}}% |
| 919 |
\else |
| 920 |
\def\tikz@lib@graph@node@text{#1}% |
| 921 |
\fi% |
| 922 |
}% |
| 923 |
{\catcode`\"=13\relax |
| 924 |
\gdef\tikz@lg@slash@quote@active"#1"#2\pgf@stop{% |
| 925 |
\iftikz@handle@active@nodes% |
| 926 |
\def\tikz@lib@graph@node@text{\scantokens{#1}}% |
| 927 |
\else |
| 928 |
\def\tikz@lib@graph@node@text{#1}% |
| 929 |
\fi% |
| 930 |
}% |
| 931 |
}% |
| 932 |
\def\tikz@lg@slash@cont#1\pgf@stop{% |
| 933 |
\iftikz@handle@active@nodes% |
| 934 |
\def\tikz@lib@graph@node@text{\scantokens{#1}}% |
| 935 |
\else |
| 936 |
\def\tikz@lib@graph@node@text{#1}% |
| 937 |
\fi% |
| 938 |
}% |
| 939 |
|
| 940 |
\def\tikz@lib@parse@node@with@doubleunder#1__{\tikz@lib@parse@node@with@slash{#1}/}% |
| 941 |
|
| 942 |
\def\tikz@lg@find@fresh@name{% |
| 943 |
\edef\tikz@lib@graph@name@only{\tikz@lib@graph@name@only'}% |
| 944 |
\edef\tikz@lib@graph@name{\tikz@lib@graph@path\tikz@lib@graph@name@only}% |
| 945 |
\tikz@lg@if@local@node{\tikz@lib@graph@name}{\tikz@lg@find@fresh@name}{}% |
| 946 |
}% |
| 947 |
|
| 948 |
|
| 949 |
% |
| 950 |
% We have now parsed everything up to the opening "[". We continue |
| 951 |
% |
| 952 |
|
| 953 |
\def\tikz@lib@graph@handle@node@cont{% |
| 954 |
\iftikzgraphsautonumbernodes% |
| 955 |
\tikz@lib@do@autonumber% |
| 956 |
\fi% |
| 957 |
\iftikz@lib@graph@fresh@node% |
| 958 |
\tikz@lg@if@local@node{\tikz@lib@graph@name}{\tikz@lg@find@fresh@name}{}% |
| 959 |
\fi% |
| 960 |
\let\tikzgraphnodeas\tikzgraphnodeas@default% |
| 961 |
\pgfutil@ifnextchar\pgf@stop{% |
| 962 |
\ifx\tikz@lib@graph@name@only\pgfutil@empty% |
| 963 |
\expandafter\tikz@lib@graph@node@empty@done% |
| 964 |
\else |
| 965 |
\expandafter\tikz@lib@graph@node@opt\expandafter[\expandafter]\expandafter[% |
| 966 |
\fi% |
| 967 |
}{\tikz@lib@graph@node@opt[}% |
| 968 |
}% |
| 969 |
|
| 970 |
\def\tikzgraphnodeas@default{% |
| 971 |
\tikz@lib@graph@typesetter% |
| 972 |
}% |
| 973 |
|
| 974 |
\let\tikz@lib@graph@empty@node@parsed\relax% |
| 975 |
|
| 976 |
\def\tikz@lib@graph@node@opt[#1]#2[\pgf@stop{% |
| 977 |
\tikz@lib@graph@node@parsed{#1}% |
| 978 |
}% |
| 979 |
|
| 980 |
\def\tikz@lib@graph@node@empty@done\pgf@stop{\tikz@lib@graph@empty@node@parsed}% |
| 981 |
|
| 982 |
% |
| 983 |
% Parse a layout node |
| 984 |
% |
| 985 |
|
| 986 |
\def\tikz@lib@parse@layout@node#1//{% |
| 987 |
\pgf@lib@graph@empty@layout@nodefalse% |
| 988 |
\let\tikz@lib@graph@node@parsed\tikz@lib@layout@node@parsed% |
| 989 |
\let\tikz@lib@graph@empty@node@parsed\tikz@lib@graph@empty@layout@node@parsed |
| 990 |
\tikz@lib@parse@normal@node#1[\pgf@stop% |
| 991 |
}% |
| 992 |
|
| 993 |
\newif\ifpgf@lib@graph@empty@layout@node |
| 994 |
|
| 995 |
\def\tikz@lib@layout@node@parsed{% |
| 996 |
\tikz@lib@layout@parse@rest% |
| 997 |
}% |
| 998 |
|
| 999 |
\def\tikz@lib@graph@empty@layout@node@parsed{% |
| 1000 |
\pgf@lib@graph@empty@layout@nodetrue |
| 1001 |
\tikz@lib@layout@parse@rest{}% |
| 1002 |
}% |
| 1003 |
|
| 1004 |
\def\tikz@lib@layout@parse@rest#1{% |
| 1005 |
\def\tikz@lib@layout@node@options{#1}% |
| 1006 |
\pgfutil@ifnextchar[{\tikz@lib@layout@node@opt}{\tikz@lib@layout@node@opt[]}%} |
| 1007 |
}% |
| 1008 |
|
| 1009 |
\def\tikz@lib@layout@node@parsed#1{% |
| 1010 |
\def\tikz@lib@layout@node@options{#1}% |
| 1011 |
\pgfutil@ifnextchar[{\tikz@lib@layout@node@opt}{\tikz@lib@layout@node@opt[]}%} |
| 1012 |
}% |
| 1013 |
|
| 1014 |
\def\tikz@lib@layout@node@opt[#1]{% |
| 1015 |
\def\tikz@lib@layout@options{#1}% |
| 1016 |
\pgfutil@ifnextchar\bgroup{\tikz@lib@layout@start}{\tikzerror{Opening brace at beginning of sublayout expected}}% |
| 1017 |
}% |
| 1018 |
|
| 1019 |
|
| 1020 |
% |
| 1021 |
% Typeset a normal node |
| 1022 |
% |
| 1023 |
|
| 1024 |
\def\tikz@lib@graph@node@opt@normal#1{% |
| 1025 |
\expandafter\tikz@lib@graph@test@use@list\tikz@lib@graph@name@only\pgf@stop |
| 1026 |
\iftikz@lib@graph@use@list% |
| 1027 |
% Ok, make a list of the nodes stored in #1: |
| 1028 |
\let\tikz@lg@temp\pgfutil@empty% |
| 1029 |
\foreach \tikz@lg@node@name in \tikz@lib@graph@use@list {\expandafter\tikz@lib@graph@handle@use\expandafter{\tikz@lg@node@name}} |
| 1030 |
% Ok, now add the nodes to the node list |
| 1031 |
\expandafter\expandafter\expandafter\def% |
| 1032 |
\expandafter\expandafter\expandafter\tikz@lib@graph@node@list% |
| 1033 |
\expandafter\expandafter\expandafter{% |
| 1034 |
\expandafter\tikz@lib@graph@node@list\tikz@lg@temp}% |
| 1035 |
% Then color and initialize them: |
| 1036 |
\let\tikz@lg@do\tikz@lib@graph@do@use% |
| 1037 |
\tikz@lg@temp% |
| 1038 |
\else% |
| 1039 |
\edef\tikz@lib@graph@name{\tikz@lib@graph@path\tikz@lib@graph@name@only}% |
| 1040 |
\expandafter\ifx\csname tikz@lib@graph@def@\tikz@lib@graph@name@only\endcsname\relax% |
| 1041 |
\pgfkeysgetvalue{/tikz/graphs/placement/level}\tikz@temp% |
| 1042 |
\c@pgf@counta=\tikz@temp\relax% |
| 1043 |
\advance\c@pgf@counta by1\relax% |
| 1044 |
\edef\tikz@temp{\the\c@pgf@counta}% |
| 1045 |
\pgfkeyslet{/tikz/graphs/placement/level}\tikz@temp% |
| 1046 |
\tikzgraphsset{ |
| 1047 |
level/.try=\pgfkeysvalueof{/tikz/graphs/placement/level}, |
| 1048 |
level \pgfkeysvalueof{/tikz/graphs/placement/level}/.try |
| 1049 |
} |
| 1050 |
{% |
| 1051 |
\edef\tikz@lib@graph@node@list{\noexpand\tikz@lg@do{\tikz@lib@graph@name}}% |
| 1052 |
\global\tikz@lib@graph@node@createdfalse% |
| 1053 |
\pgfkeyslet{/tikz/graphs/@operators}\pgfutil@empty% |
| 1054 |
\tikz@lib@activate@source@target@edge@syntax% |
| 1055 |
\tikz@lg@if@local@node{\tikz@lib@graph@name}% |
| 1056 |
{\tikz@lg@local@node@handle{#1}}% |
| 1057 |
{% |
| 1058 |
\tikz@lg@init@color{\tikz@lib@graph@name}{\tikz@lgc@all@true\tikz@lgc@source@true\tikz@lgc@target@true}% |
| 1059 |
\iftikz@lib@graph@all% |
| 1060 |
\tikzgraphsset{#1}\pgfkeysvalueof{/tikz/graphs/@operators}% |
| 1061 |
\else% |
| 1062 |
\pgfkeys{/tikz/graphs/placement/place}% |
| 1063 |
\let\tikzgraphnodetext\tikz@lib@graph@node@text% |
| 1064 |
\let\tikzgraphnodename\tikz@lib@graph@name@only% |
| 1065 |
\let\tikzgraphnodepath\tikz@lib@graph@path% |
| 1066 |
\let\tikzgraphnodefullname\tikz@lib@graph@name% |
| 1067 |
\iftikz@lib@graph@fake@node% |
| 1068 |
{% run options in protected mode... |
| 1069 |
\pgfkeys{ |
| 1070 |
/tikz/graphs/.cd,% |
| 1071 |
.unknown/.code=, |
| 1072 |
/tikz/graphs/@nodes styling,% |
| 1073 |
#1}% |
| 1074 |
\pgfkeysgetvalue{/tikz/graphs/@operators}\tikz@lib@graph@op@save% |
| 1075 |
\global\let\tikz@lib@graph@op@save\tikz@lib@graph@op@save% |
| 1076 |
}% |
| 1077 |
\else% |
| 1078 |
\node [% |
| 1079 |
name=\tikz@lib@graph@name,% |
| 1080 |
execute at end node={% |
| 1081 |
\pgfkeysgetvalue{/tikz/graphs/@operators}\tikz@lib@graph@op@save% |
| 1082 |
\global\let\tikz@lib@graph@op@save\tikz@lib@graph@op@save% |
| 1083 |
},% |
| 1084 |
graphs/redirect unknown to tikz, |
| 1085 |
/tikz/graphs/.cd,% |
| 1086 |
/tikz/graphs/@nodes styling,% |
| 1087 |
#1]% |
| 1088 |
{% |
| 1089 |
\tikzgraphnodeas% |
| 1090 |
};% |
| 1091 |
\fi% |
| 1092 |
\tikz@lib@graph@op@save\global\let\tikz@lib@graph@op@save\relax%% |
| 1093 |
\global\tikz@lib@graph@node@createdtrue% |
| 1094 |
\fi |
| 1095 |
}% |
| 1096 |
}% |
| 1097 |
\iftikz@lib@graph@node@created\tikz@lib@graph@placement@update\fi% |
| 1098 |
\expandafter\expandafter\expandafter\def% |
| 1099 |
\expandafter\expandafter\expandafter\tikz@lib@graph@node@list% |
| 1100 |
\expandafter\expandafter\expandafter{% |
| 1101 |
\expandafter\tikz@lib@graph@node@list\expandafter\tikz@lg@do\expandafter{\tikz@lib@graph@name}}% |
| 1102 |
\iftikz@lib@graph@trie\tikzgraphsset{name=\tikz@lib@graph@name@only}\fi% |
| 1103 |
\else |
| 1104 |
% The name of the node is a graph name |
| 1105 |
\tikz@lib@graph@handle@graph{#1}% |
| 1106 |
\fi |
| 1107 |
\fi% |
| 1108 |
}% |
| 1109 |
|
| 1110 |
\newif\iftikz@lib@graph@fake@node |
| 1111 |
|
| 1112 |
\newif\iftikz@lib@graph@use@list |
| 1113 |
\def\tikz@lib@graph@test@use@list{% |
| 1114 |
\pgfutil@ifnextchar({\tikz@lib@graph@use@list@grap}{\tikz@lib@graph@test@use@list@done}%) |
| 1115 |
}% |
| 1116 |
|
| 1117 |
\def\tikz@lib@graph@test@use@list@done#1\pgf@stop{\tikz@lib@graph@use@listfalse}% |
| 1118 |
\def\tikz@lib@graph@use@list@grap(#1)\pgf@stop{\def\tikz@lib@graph@use@list{#1}\tikz@lib@graph@use@listtrue}% |
| 1119 |
|
| 1120 |
|
| 1121 |
% |
| 1122 |
% Typeset a layout node |
| 1123 |
% |
| 1124 |
|
| 1125 |
\def\tikz@lib@layout@start#1#2\pgf@stop{% |
| 1126 |
\tikz@lib@ensure@gd@loaded% |
| 1127 |
% Parameters are: |
| 1128 |
% |
| 1129 |
% Node name is \tikz@lib@graph@name@only |
| 1130 |
% Node text is \tikz@lib@graph@node@text |
| 1131 |
% Node options are \tikz@lib@layout@node@options |
| 1132 |
% Layout options are \tikz@lib@layout@options |
| 1133 |
% Layout is #1 |
| 1134 |
% Rest is #2 (should be empty or just whitespace) |
| 1135 |
\tikz@lib@graph@fake@nodefalse% |
| 1136 |
\ifpgf@lib@graph@empty@layout@node% |
| 1137 |
\else% |
| 1138 |
\ifx\tikz@lib@graph@name\pgfutil@empty% |
| 1139 |
\tikzerror{Internal error: Node has no name, but it should!}% |
| 1140 |
\else |
| 1141 |
\tikz@lib@graph@fake@nodetrue% |
| 1142 |
\expandafter\tikz@lib@graph@node@opt@normal\expandafter{\tikz@lib@layout@node@options}% |
| 1143 |
\fi% |
| 1144 |
\fi% |
| 1145 |
\edef\tikz@lib@graph@name{\tikz@lib@graph@path\tikz@lib@graph@name@only}% |
| 1146 |
% |
| 1147 |
% Prepare tikz node options |
| 1148 |
% |
| 1149 |
\expandafter\expandafter\expandafter\def% |
| 1150 |
\expandafter\expandafter\expandafter\tikz@lib@layout@node@options\expandafter\expandafter\expandafter{\expandafter\tikz@lib@layout@startup@node@options\tikz@lib@layout@node@options,}% |
| 1151 |
\begingroup |
| 1152 |
% Create a subgraph node, if name is given. |
| 1153 |
\iftikz@lib@graph@fake@node% |
| 1154 |
\expandafter\expandafter\expandafter% |
| 1155 |
\expandafter\expandafter\expandafter\expandafter\tikz@lib@make@subgraph@node% |
| 1156 |
\expandafter\expandafter\expandafter% |
| 1157 |
\expandafter\expandafter\expandafter\expandafter{% |
| 1158 |
\expandafter\expandafter\expandafter\tikz@lib@graph@name% |
| 1159 |
\expandafter\expandafter\expandafter}% |
| 1160 |
\expandafter\expandafter\expandafter{% |
| 1161 |
\expandafter\tikz@lib@graph@node@text\expandafter}\expandafter{\tikz@lib@layout@node@options} |
| 1162 |
\fi% |
| 1163 |
% |
| 1164 |
% Here comes the scope: |
| 1165 |
% |
| 1166 |
\expandafter\expandafter\expandafter\scope\expandafter\expandafter\expandafter[\expandafter\tikz@lib@layout@node@options@prefix\tikz@lib@layout@options] |
| 1167 |
\tikzgdeventgroupcallback{array}% |
| 1168 |
\let\tikz@lib@graph@node@list\pgfutil@empty% |
| 1169 |
\tikz@lib@graph@start@hint@group% |
| 1170 |
\tikz@lib@graph@parse@group{#1}% |
| 1171 |
\tikz@lib@graph@end@hint@group% |
| 1172 |
\def\tikz@lg@old@col{\tikz@lgc@source@true}% |
| 1173 |
\let\tikz@lg@new@col\pgfutil@empty% |
| 1174 |
\let\tikz@lg@do\tikz@lg@change@color% |
| 1175 |
\tikz@lib@graph@node@list% |
| 1176 |
\def\tikz@lg@old@col{\tikz@lgc@target@true}% |
| 1177 |
\tikz@lib@graph@node@list% |
| 1178 |
\expandafter% |
| 1179 |
\endscope\expandafter% |
| 1180 |
\endgroup% |
| 1181 |
\expandafter\expandafter\expandafter\def% |
| 1182 |
\expandafter\expandafter\expandafter\tikz@lib@graph@node@list% |
| 1183 |
\expandafter\expandafter\expandafter{\expandafter\tikz@lib@graph@node@list\tikz@lib@graph@node@list}% |
| 1184 |
\tikz@lib@graph@hint@aftergroup% |
| 1185 |
}% |
| 1186 |
\def\tikz@lib@make@subgraph@node#1#2#3{% |
| 1187 |
\pgfgdsubgraphnode{#1}{#3}{\pgfgdsubgraphnodecontents{#2}}% |
| 1188 |
}% |
| 1189 |
\def\tikz@lib@layout@startup@node@options{% |
| 1190 |
/utils/exec=\tikzlibignorecomparisonsINTERNAL, |
| 1191 |
/tikz/graphs/.cd,% |
| 1192 |
redirect unknown to tikz,% |
| 1193 |
anchor=base,% |
| 1194 |
/tikz/every subgraph node/.try,% |
| 1195 |
}% |
| 1196 |
\def\tikzlibignorecomparisonsINTERNAL{% |
| 1197 |
\pgfkeys{/handlers/first char syntax=true} |
| 1198 |
\pgfkeyssetvalue{/handlers/first char syntax/\expandafter\meaning\string>}{\pgfutil@gobble}% |
| 1199 |
\pgfkeyssetvalue{/handlers/first char syntax/\expandafter\meaning\string<}{\pgfutil@gobble}% |
| 1200 |
}% |
| 1201 |
\def\tikz@lib@layout@node@options@prefix{graphs/.cd,}% |
| 1202 |
|
| 1203 |
\ifx\tikz@lib@ensure@gd@loaded\pgfutil@undefined% |
| 1204 |
\def\tikz@lib@ensure@gd@loaded{\tikzerror{You must say \string\usetikzlibrary{graphdrawing} to use the (sub)layout syntax}}% |
| 1205 |
\fi |
| 1206 |
|
| 1207 |
\def\tikz@lg@local@node@handle#1{% |
| 1208 |
% |
| 1209 |
% Handle late options and operators |
| 1210 |
\tikzgraphsset{source,target,.unknown/.code=,#1}% |
| 1211 |
\tikzgdlatenodeoptionacallback{\tikz@pp@name\tikz@lib@graph@name}% |
| 1212 |
\node also[graphs/redirect unknown to tikz,/tikz/graphs/.cd,#1](\tikz@lib@graph@name);% |
| 1213 |
\pgfkeysvalueof{/tikz/graphs/@operators}% |
| 1214 |
}% |
| 1215 |
|
| 1216 |
\tikzgraphsset{redirect unknown to tikz/.style={ |
| 1217 |
/tikz/graphs/.unknown/.code={% |
| 1218 |
\let\tikz@key\pgfkeyscurrentname% |
| 1219 |
\pgfkeys{tikz/.cd,\tikz@key={##1},/tikz/graphs/.cd}% |
| 1220 |
}} |
| 1221 |
}% |
| 1222 |
|
| 1223 |
\def\tikz@lib@activate@source@target@edge@syntax{% |
| 1224 |
\pgfkeys{/handlers/first char syntax=true} |
| 1225 |
\pgfkeyssetvalue{/handlers/first char syntax/\expandafter\meaning\string>}{\tikz@lg@parse@more}% |
| 1226 |
\pgfkeyssetvalue{/handlers/first char syntax/\expandafter\meaning\string<}{\tikz@lg@parse@less}% |
| 1227 |
}% |
| 1228 |
|
| 1229 |
\def\tikz@lg@parse@less#1{\tikz@lg@parse@less@#1\pgf@stop}% |
| 1230 |
\def\tikz@lg@parse@less@<{\pgfutil@ifnextchar"{\tikz@lg@parse@quote{source}}{\tikz@lg@parse@noquote{source}}}% |
| 1231 |
\def\tikz@lg@parse@more#1{\tikz@lg@parse@more@#1\pgf@stop}% |
| 1232 |
\def\tikz@lg@parse@more@>{\pgfutil@ifnextchar"{\tikz@lg@parse@quote{target}}{\tikz@lg@parse@noquote{target}}}% |
| 1233 |
|
| 1234 |
\def\tikz@lg@parse@noquote#1#2\pgf@stop{{\tikzgraphsset{#1 edge style={#2}}}}% |
| 1235 |
\def\tikz@lg@parse@quote#1#2\pgf@stop{% |
| 1236 |
{\tikzgraphsset{/tikz/node quotes mean={#1 edge node={node [every edge quotes,##2]{##1}}},/utils/exec=\tikz@enable@node@quotes,#2}}% |
| 1237 |
}% |
| 1238 |
|
| 1239 |
\tikzgraphsset{ |
| 1240 |
clear >/.style=target edge clear, |
| 1241 |
clear </.style=source edge clear |
| 1242 |
}% |
| 1243 |
|
| 1244 |
|
| 1245 |
% Positioning |
| 1246 |
|
| 1247 |
\def\tikz@lib@graph@x{0}% |
| 1248 |
\def\tikz@lib@graph@y{0}% |
| 1249 |
|
| 1250 |
\tikzgraphsset{ |
| 1251 |
x/.code=\def\tikz@lib@graph@x{#1}\tikz@lib@graphs@check@at, |
| 1252 |
y/.code=\def\tikz@lib@graph@y{#1}\tikz@lib@graphs@check@at |
| 1253 |
}% |
| 1254 |
\def\tikz@lib@graphs@check@at{% |
| 1255 |
\expandafter\expandafter\expandafter\def% |
| 1256 |
\expandafter\expandafter\expandafter\tikz@temp% |
| 1257 |
\expandafter\expandafter\expandafter{% |
| 1258 |
\expandafter\expandafter\expandafter(% |
| 1259 |
\expandafter\expandafter\expandafter{\expandafter\tikz@lib@graph@x\expandafter}% |
| 1260 |
\expandafter,\expandafter{\tikz@lib@graph@y})}% |
| 1261 |
\pgfqkeys{/tikz}{at/.expand once=\tikz@temp}% |
| 1262 |
}% |
| 1263 |
|
| 1264 |
|
| 1265 |
\newif\iftikz@lib@graph@trie |
| 1266 |
\tikzgraphsset{ |
| 1267 |
trie/.is if=tikz@lib@graph@trie, |
| 1268 |
put node text on incoming |
| 1269 |
edges/.style={nodes={/utils/exec=\tikz@lg@make@edge@node{target}{#1}}}, |
| 1270 |
put node text on outgoing |
| 1271 |
edges/.style={nodes={/utils/exec=\tikz@lg@make@edge@node{source}{#1}}}, |
| 1272 |
edge quotes/.style={/tikz/every edge quotes/.style={#1}}, |
| 1273 |
edge quotes center/.style={edge quotes={anchor=center}}, |
| 1274 |
edge quotes mid/.style={edge quotes={anchor=mid}} |
| 1275 |
}% |
| 1276 |
|
| 1277 |
\def\tikz@lg@make@edge@node#1#2{% |
| 1278 |
\def\pgf@marshal{node[#2]}% |
| 1279 |
\expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\pgf@marshal\expandafter\expandafter\expandafter{\expandafter\pgf@marshal\expandafter{\tikzgraphnodetext}}% |
| 1280 |
\pgfkeysalso{#1 edge node/.expand once=\pgf@marshal,as=}% |
| 1281 |
}% |
| 1282 |
|
| 1283 |
\newif\iftikz@lib@graph@fresh@node |
| 1284 |
\tikzgraphsset{fresh nodes/.is if=tikz@lib@graph@fresh@node}% |
| 1285 |
|
| 1286 |
\tikzgraphsset{number nodes/.code=% |
| 1287 |
\pgfmathsetcount\tikz@lib@auto@number{#1}% |
| 1288 |
\tikzgraphsautonumbernodestrue,% |
| 1289 |
number nodes/.default=1,% |
| 1290 |
number nodes sep/.code=\def\tikz@lib@auto@sep{#1} |
| 1291 |
}% |
| 1292 |
\def\tikz@lib@auto@sep{\space}% |
| 1293 |
|
| 1294 |
\newif\iftikz@lib@graph@node@created |
| 1295 |
|
| 1296 |
\def\tikz@lib@graph@handle@use#1{% |
| 1297 |
% Is #1 the name of a node set? |
| 1298 |
\expandafter\let\expandafter\pgf@temp\csname tikz@lg@node@set #1\endcsname |
| 1299 |
\ifx\pgf@temp\relax |
| 1300 |
\pgfutil@g@addto@macro\tikz@lg@temp{\tikz@lg@do{#1}} |
| 1301 |
\else% |
| 1302 |
\expandafter\pgfutil@g@addto@macro\expandafter\tikz@lg@temp\expandafter{\pgf@temp} |
| 1303 |
\fi |
| 1304 |
}% |
| 1305 |
|
| 1306 |
\def\tikz@lib@graph@do@use#1{% |
| 1307 |
\tikz@lg@init@color{#1}{\tikz@lgc@all@true\tikz@lgc@source@true\tikz@lgc@target@true}% |
| 1308 |
}% |
| 1309 |
|
| 1310 |
\tikzgraphsset{ |
| 1311 |
typeset/.store in=\tikz@lib@graph@typesetter, |
| 1312 |
math nodes/.style={/tikz/graphs/typeset=$\tikzgraphnodetext$}, |
| 1313 |
empty nodes/.style={/tikz/graphs/typeset=}, |
| 1314 |
typeset=\tikzgraphnodetext |
| 1315 |
}% |
| 1316 |
|
| 1317 |
|
| 1318 |
% |
| 1319 |
% Handle scope |
| 1320 |
% |
| 1321 |
\def\tikz@lib@graph@scope#1{ |
| 1322 |
\begingroup% |
| 1323 |
\tikzgdeventgroupcallback{array}% |
| 1324 |
\let\tikz@lib@graph@node@list\pgfutil@empty% |
| 1325 |
\tikz@lib@graph@start@hint@group% |
| 1326 |
\tikz@lib@graph@parse@group{#1}% |
| 1327 |
\tikz@lib@graph@end@hint@group% |
| 1328 |
\expandafter% |
| 1329 |
\endgroup% |
| 1330 |
\expandafter\expandafter\expandafter\def% |
| 1331 |
\expandafter\expandafter\expandafter\tikz@lib@graph@node@list% |
| 1332 |
\expandafter\expandafter\expandafter{\expandafter\tikz@lib@graph@node@list\tikz@lib@graph@node@list}% |
| 1333 |
\tikz@lib@graph@hint@aftergroup% |
| 1334 |
\tikz@lib@graph@stored@actions% |
| 1335 |
\pgfutil@ifnextchar-{\tikz@lib@graph@scope@minus}{% |
| 1336 |
\pgfutil@ifnextchar<{\tikz@lib@graph@scope@less}{% |
| 1337 |
\tikzerror{One of the arrow types <-, --, ->, -!-, or <-> expected}% |
| 1338 |
}% |
| 1339 |
}% |
| 1340 |
}% |
| 1341 |
|
| 1342 |
\def\tikz@lib@graph@scope@minus-{ |
| 1343 |
\pgfutil@ifnextchar>\tikz@lib@graph@forward@arrow{% |
| 1344 |
\pgfutil@ifnextchar-\tikz@lib@graph@undirected@arrow{% |
| 1345 |
\pgfutil@ifnextchar!\tikz@lib@graph@no@arrow{% |
| 1346 |
\pgfutil@ifnextchar\pgf@stop@eodashes\tikz@lib@graph@graph@done{% |
| 1347 |
\tikzerror{One of the arrow types <-, --, ->, -!-, or <-> expected}% |
| 1348 |
\tikz@lib@graph@undirected@arrow% |
| 1349 |
}% |
| 1350 |
}% |
| 1351 |
}% |
| 1352 |
}% |
| 1353 |
}% |
| 1354 |
|
| 1355 |
\def\tikz@lib@graph@scope@less<-{\tikz@lib@graph@back@arrow}% |
| 1356 |
|
| 1357 |
|
| 1358 |
|
| 1359 |
|
| 1360 |
% |
| 1361 |
% Predefining graphs |
| 1362 |
% |
| 1363 |
|
| 1364 |
\tikzgraphsset{ |
| 1365 |
declare/.code 2 args={\expandafter\def\csname tikz@lib@graph@def@#1\endcsname{\tikz@lib@graph@do@graph{#2}}}% |
| 1366 |
}% |
| 1367 |
|
| 1368 |
\def\tikz@lib@graph@handle@graph#1{% |
| 1369 |
\begingroup% |
| 1370 |
\let\tikz@lib@graph@node@list\pgfutil@empty% |
| 1371 |
\tikzgraphsset{@extra group options/.style={#1}}% |
| 1372 |
\tikz@lib@graph@start@hint@group% |
| 1373 |
\csname tikz@lib@graph@def@\tikz@lib@graph@name@only\endcsname% |
| 1374 |
\tikz@lib@graph@end@hint@group% |
| 1375 |
\expandafter% |
| 1376 |
\endgroup% |
| 1377 |
\expandafter\expandafter\expandafter\def% |
| 1378 |
\expandafter\expandafter\expandafter\tikz@lib@graph@node@list% |
| 1379 |
\expandafter\expandafter\expandafter{\expandafter\tikz@lib@graph@node@list\tikz@lib@graph@node@list}% |
| 1380 |
\tikz@lib@graph@hint@aftergroup% |
| 1381 |
}% |
| 1382 |
|
| 1383 |
\def\tikz@lib@graph@do@graph#1{% |
| 1384 |
\tikz@lib@graph@parse@group{#1}% |
| 1385 |
}% |
| 1386 |
|
| 1387 |
\let\tikz@lib@graph@path\pgfutil@empty |
| 1388 |
|
| 1389 |
\tikzgraphsset{ |
| 1390 |
name separator/.store in=\tikz@lib@graph@name@separator, |
| 1391 |
name separator=\space, |
| 1392 |
name/.code={% |
| 1393 |
\edef\tikz@lib@graph@path{\tikz@lib@graph@path#1\tikz@lib@graph@name@separator}% |
| 1394 |
}% |
| 1395 |
}% |
| 1396 |
|
| 1397 |
|
| 1398 |
% |
| 1399 |
% Colors |
| 1400 |
% |
| 1401 |
\def\tikz@lg@newif{\csname newif\endcsname}% |
| 1402 |
\tikzgraphsset{ |
| 1403 |
as/.code=\def\tikzgraphnodeas{#1},% |
| 1404 |
color class/.style={% |
| 1405 |
/utils/exec=\expandafter\tikz@lg@newif\csname iftikz@lgc@#1@\endcsname, |
| 1406 |
#1/.style={operator={% |
| 1407 |
\edef\tikz@lg@col{\expandafter\noexpand\csname tikz@lgc@#1@true\endcsname}% |
| 1408 |
\let\tikz@lg@do\tikz@lg@colorize% |
| 1409 |
\tikz@lib@graph@node@list% |
| 1410 |
}}, |
| 1411 |
not #1/.style={operator={% |
| 1412 |
\edef\tikz@lg@old@col{\expandafter\noexpand\csname tikz@lgc@#1@true\endcsname}% |
| 1413 |
\let\tikz@lg@new@col\pgfutil@empty% |
| 1414 |
\let\tikz@lg@do\tikz@lg@change@color% |
| 1415 |
\tikz@lib@graph@node@list% |
| 1416 |
}}, |
| 1417 |
recolor #1 by/.style={operator={% |
| 1418 |
\edef\tikz@lg@old@col{\expandafter\noexpand\csname tikz@lgc@#1@true\endcsname}% |
| 1419 |
\edef\tikz@lg@new@col{\expandafter\noexpand\csname tikz@lgc@##1@true\endcsname}% |
| 1420 |
\let\tikz@lg@do\tikz@lg@change@color% |
| 1421 |
\tikz@lib@graph@node@list% |
| 1422 |
}}, |
| 1423 |
!#1/.style=not #1, |
| 1424 |
}, |
| 1425 |
color class=source, |
| 1426 |
color class=source', |
| 1427 |
color class=source'', |
| 1428 |
color class=target, |
| 1429 |
color class=target', |
| 1430 |
color class=all |
| 1431 |
}% |
| 1432 |
|
| 1433 |
\def\tikz@lg@init@color#1#2{% |
| 1434 |
\expandafter\gdef\csname tikz@lgc@#1\endcsname{#2}% |
| 1435 |
}% |
| 1436 |
|
| 1437 |
\def\tikz@lib@graph@cleanup#1{% |
| 1438 |
\expandafter\global\expandafter\let\csname tikz@lgc@#1\endcsname\relax% |
| 1439 |
\ifcsname tikz@lgca@@#1\endcsname\expandafter\global\expandafter\let\csname tikz@lgca@@#1\endcsname\relax\fi% |
| 1440 |
\ifcsname tikz@lgcb@@#1\endcsname\expandafter\global\expandafter\let\csname tikz@lgcb@@#1\endcsname\relax\fi% |
| 1441 |
}% |
| 1442 |
|
| 1443 |
\def\tikz@lg@colorize#1{% |
| 1444 |
\expandafter\let\expandafter\pgf@temp\csname tikz@lgc@#1\endcsname% |
| 1445 |
\expandafter\expandafter\expandafter\def% |
| 1446 |
\expandafter\expandafter\expandafter\pgf@temp% |
| 1447 |
\expandafter\expandafter\expandafter{% |
| 1448 |
\expandafter\tikz@lg@col\pgf@temp}% |
| 1449 |
\expandafter\global\expandafter\let\csname tikz@lgc@#1\endcsname\pgf@temp% |
| 1450 |
}% |
| 1451 |
|
| 1452 |
\def\tikz@lg@change@color#1{% |
| 1453 |
\def\tikz@lg@temp@save{#1}% |
| 1454 |
\let\tikz@lg@collect\pgfutil@empty% |
| 1455 |
\expandafter\let\expandafter\pgf@temp\csname tikz@lgc@#1\endcsname% |
| 1456 |
\expandafter\tikz@lg@change@check\pgf@temp\pgf@stop% |
| 1457 |
}% |
| 1458 |
\def\tikz@lg@change@check#1{% |
| 1459 |
\ifx#1\pgf@stop% |
| 1460 |
\tikz@lg@change@write@back% |
| 1461 |
\else% |
| 1462 |
\def\pgf@temp{#1}% |
| 1463 |
\ifx\pgf@temp\tikz@lg@old@col% |
| 1464 |
\expandafter\tikz@lg@change@add\expandafter{\tikz@lg@new@col}% Found! |
| 1465 |
\else% |
| 1466 |
\tikz@lg@change@add{#1}% |
| 1467 |
\fi% |
| 1468 |
\expandafter\tikz@lg@change@check |
| 1469 |
\fi% |
| 1470 |
}% |
| 1471 |
\def\tikz@lg@change@add#1{% |
| 1472 |
\expandafter\def\expandafter\tikz@lg@collect\expandafter{\tikz@lg@collect#1}% |
| 1473 |
}% |
| 1474 |
|
| 1475 |
\def\tikz@lg@change@write@back{% |
| 1476 |
\expandafter\global\expandafter\let\csname tikz@lgc@\tikz@lg@temp@save\endcsname\tikz@lg@collect% |
| 1477 |
}% |
| 1478 |
|
| 1479 |
|
| 1480 |
|
| 1481 |
\def\tikz@lg@if@has@color#1#2#3#4{% |
| 1482 |
{% |
| 1483 |
\csname tikz@lgc@#1\endcsname% |
| 1484 |
\expandafter\let\expandafter\pgf@temp\csname iftikz@lgc@#2@\endcsname% |
| 1485 |
\ifx\pgf@temp\relax% |
| 1486 |
\tikz@lib@reset@temp% |
| 1487 |
\fi% |
| 1488 |
\pgf@temp% |
| 1489 |
\global\tikz@color@testtrue% |
| 1490 |
\else% |
| 1491 |
\global\tikz@color@testfalse% |
| 1492 |
\fi% |
| 1493 |
}% |
| 1494 |
\iftikz@color@test#3\else#4\fi% |
| 1495 |
}% |
| 1496 |
\newif\iftikz@color@test |
| 1497 |
|
| 1498 |
\def\tikz@lg@if@local@node#1#2#3{\expandafter\ifx\csname tikz@lgc@#1\endcsname\relax#3\else#2\fi}% |
| 1499 |
|
| 1500 |
\def\tikz@lib@reset@temp{\let\pgf@temp\iffalse}% |
| 1501 |
|
| 1502 |
% |
| 1503 |
% Handle connection annotations |
| 1504 |
% |
| 1505 |
\def\tikz@lib@annotate@#1#2#3#4{% |
| 1506 |
\expandafter\ifx\csname tikz@lgc#1@@#2\endcsname\relax% |
| 1507 |
\expandafter\gdef\csname tikz@lgc#1@@#2\endcsname{{#3}{#4}}% |
| 1508 |
\else% |
| 1509 |
\expandafter\expandafter\expandafter\tikz@lib@annotate@read\csname tikz@lgc#1@@#2\endcsname{#3}{#4}% |
| 1510 |
\expandafter\global\expandafter\let\csname tikz@lgc#1@@#2\endcsname\pgf@temp% |
| 1511 |
\fi% |
| 1512 |
}% |
| 1513 |
\def\tikz@lib@annotate@read#1#2#3#4{\def\pgf@temp{{#1,#3}{#2#4}}}% |
| 1514 |
|
| 1515 |
\tikzgraphsset{ |
| 1516 |
source edge style/.code=\tikz@lib@annotate@{a}{\tikz@lib@graph@name}{#1}{}, |
| 1517 |
source edge node/.code=\tikz@lib@annotate@{a}{\tikz@lib@graph@name}{}{#1}, |
| 1518 |
source edge clear/.code={ |
| 1519 |
\expandafter\global\expandafter\let\csname tikz@lgca@@\tikz@lib@graph@name\endcsname\relax% |
| 1520 |
}, |
| 1521 |
target edge style/.code=\tikz@lib@annotate@{b}{\tikz@lib@graph@name}{#1}{}, |
| 1522 |
target edge node/.code=\tikz@lib@annotate@{b}{\tikz@lib@graph@name}{}{#1}, |
| 1523 |
target edge clear/.code={% |
| 1524 |
\expandafter\global\expandafter\let\csname tikz@lgcb@@\tikz@lib@graph@name\endcsname\relax% |
| 1525 |
} |
| 1526 |
}% |
| 1527 |
|
| 1528 |
|
| 1529 |
|
| 1530 |
% Packing a node list: Replace the node list by a new node list where |
| 1531 |
% each node is mentioned at most once. |
| 1532 |
|
| 1533 |
\def\tikz@lib@graph@pack@node@list{% |
| 1534 |
{% |
| 1535 |
\let\tikz@lg@packed\pgfutil@empty% |
| 1536 |
\let\tikz@lg@do\tikz@lg@packer% |
| 1537 |
\tikz@lib@graph@node@list% |
| 1538 |
\expandafter |
| 1539 |
}\expandafter% |
| 1540 |
\def\expandafter\tikz@lib@graph@node@list\expandafter{\tikz@lg@packed}% |
| 1541 |
}% |
| 1542 |
|
| 1543 |
\def\tikz@lg@packer#1{% |
| 1544 |
\expandafter\ifx\csname tikz@lg@p@#1\endcsname\pgf@stop% |
| 1545 |
\else% |
| 1546 |
\expandafter\let\csname tikz@lg@p@#1\endcsname\pgf@stop% |
| 1547 |
\expandafter\def\expandafter\tikz@lg@packed\expandafter{\tikz@lg@packed\tikz@lg@do{#1}} |
| 1548 |
\fi |
| 1549 |
}% |
| 1550 |
|
| 1551 |
% |
| 1552 |
% Color functions |
| 1553 |
% |
| 1554 |
|
| 1555 |
% Do something for all nodes having a certain color |
| 1556 |
% |
| 1557 |
% #1 = the color name |
| 1558 |
% #2 = a macro |
| 1559 |
% |
| 1560 |
% Description: |
| 1561 |
% |
| 1562 |
% For each node having color #1, the macro #2 will be called. This |
| 1563 |
% macro should take a single parameter, which will be set |
| 1564 |
% to the node's name. |
| 1565 |
|
| 1566 |
\def\tikzgraphforeachcolorednode#1#2{% |
| 1567 |
\tikz@lib@graph@pack@node@list% |
| 1568 |
\expandafter\def\expandafter\iftikz@lib@graph@color@picker\expandafter{\csname iftikz@lgc@#1@\endcsname}% |
| 1569 |
\let\tikz@lib@graph@action#2% |
| 1570 |
\let\tikz@lg@do\tikz@lg@pick% |
| 1571 |
\tikz@lib@graph@node@list% |
| 1572 |
}% |
| 1573 |
\def\tikz@lg@pick#1{ |
| 1574 |
{% |
| 1575 |
\csname tikz@lgc@#1\endcsname% |
| 1576 |
\iftikz@lib@graph@color@picker |
| 1577 |
\global\tikz@color@testtrue% |
| 1578 |
\else% |
| 1579 |
\global\tikz@color@testfalse% |
| 1580 |
\fi% |
| 1581 |
}% |
| 1582 |
\iftikz@color@test\tikz@lib@graph@action{#1}\fi% |
| 1583 |
}% |
| 1584 |
|
| 1585 |
|
| 1586 |
|
| 1587 |
% Prepare a color |
| 1588 |
% |
| 1589 |
% #1 is the color name |
| 1590 |
% #2 is a counter |
| 1591 |
% #3 is a prefix |
| 1592 |
% |
| 1593 |
% Description: |
| 1594 |
% |
| 1595 |
% You can call this function inside a connector. It will do the |
| 1596 |
% following: First, its counts how many nodes exist that have color |
| 1597 |
% #1. This number is stored in the counter passed as #2. Furthermore, |
| 1598 |
% let <name> be the name of the <i>-th vertex that has color #1. Then, a |
| 1599 |
% macro called \#3<i> will store <name>. For instance, if #1 is "red" |
| 1600 |
% and the third red node is called foo and if #3 is "bar", then a |
| 1601 |
% macro called "\bar3" is set to "foo" as if you had said |
| 1602 |
% "\expandafter\def\csname bar3\endcsname{foo}". |
| 1603 |
% |
| 1604 |
% The bottom line of all this is that after a preparation you can |
| 1605 |
% easily iterate over nodes having a certain color. If you wish to |
| 1606 |
% iterate over a single color, it will be quicker and easier to call |
| 1607 |
% \tikzgraphforeachcolorednode, but if you need to iterate over two |
| 1608 |
% colors simultaneously, it will be better to first prepare the color. |
| 1609 |
|
| 1610 |
\def\tikzgraphpreparecolor#1#2#3{% |
| 1611 |
\let\tikz@lib@graph@count#2% |
| 1612 |
\tikz@lib@graph@count0\relax |
| 1613 |
\def\tikz@lib@graph@prefix{#3}% |
| 1614 |
\tikzgraphforeachcolorednode{#1}\tikz@lib@graph@prepare% |
| 1615 |
}% |
| 1616 |
|
| 1617 |
\def\tikz@lib@graph@prepare#1{% |
| 1618 |
\advance\tikz@lib@graph@count by1\relax% |
| 1619 |
\expandafter\def\csname\tikz@lib@graph@prefix\the\tikz@lib@graph@count\endcsname{#1}% |
| 1620 |
}% |
| 1621 |
|
| 1622 |
|
| 1623 |
|
| 1624 |
|
| 1625 |
% |
| 1626 |
% The bipartite connector |
| 1627 |
% |
| 1628 |
|
| 1629 |
\tikzgraphsset{ |
| 1630 |
complete bipartite/.style 2 args={operator={ |
| 1631 |
\def\tikz@lg@shoreb{#2}% |
| 1632 |
\tikzgraphforeachcolorednode{#1}\tikz@lib@graph@bipartite@outer |
| 1633 |
}}, |
| 1634 |
complete bipartite/.default={target'}{source'}, |
| 1635 |
induced complete bipartite/.style 2 args={ |
| 1636 |
induced independent set={#1}, |
| 1637 |
induced independent set={#2}, |
| 1638 |
complete bipartite={#1}{#2} |
| 1639 |
}, |
| 1640 |
induced complete bipartite/.default={target'}{source'}, |
| 1641 |
}% |
| 1642 |
|
| 1643 |
\def\tikz@lib@graph@bipartite@outer#1{% |
| 1644 |
\def\tikz@lib@graph@from{#1}% |
| 1645 |
{% |
| 1646 |
\tikzgraphforeachcolorednode{\tikz@lg@shoreb}\tikz@lib@graph@bipartite@inner% |
| 1647 |
}% |
| 1648 |
}% |
| 1649 |
|
| 1650 |
\def\tikz@lib@graph@bipartite@inner#1{% |
| 1651 |
\def\pgf@temp{#1}% |
| 1652 |
\ifx\pgf@temp\tikz@lib@graph@from\else% |
| 1653 |
\tikz@lib@graph@default@new@edge{\tikz@lib@graph@from}{#1}% |
| 1654 |
\fi% |
| 1655 |
}% |
| 1656 |
|
| 1657 |
\def\tikz@lib@graph@default@new@edge#1#2{% |
| 1658 |
\pgfkeysgetvalue{/tikz/graphs/@edges styling}\pgf@temp |
| 1659 |
\pgfkeysgetvalue{/tikz/graphs/@edges node}\pgf@temp@b |
| 1660 |
\let\tikz@lib@add@temp\pgfutil@empty% |
| 1661 |
\tikz@lib@graph@add@edge@annotations{a}{#1} |
| 1662 |
\tikz@lib@graph@add@edge@annotations{b}{#2} |
| 1663 |
\expandafter\expandafter\expandafter\def% |
| 1664 |
\expandafter\expandafter\expandafter\pgf@temp% |
| 1665 |
\expandafter\expandafter\expandafter{\expandafter\pgf@temp\tikz@lib@add@temp}% |
| 1666 |
\expandafter\expandafter\expandafter\tikz@lib@graph@default@new@edge@% |
| 1667 |
\expandafter\expandafter\expandafter{\expandafter\pgf@temp\expandafter}\expandafter{\pgf@temp@b}{#1}{#2}% |
| 1668 |
}% |
| 1669 |
\def\tikz@lib@graph@default@new@edge@#1#2#3#4{% |
| 1670 |
\iftikz@lib@graph@simple% |
| 1671 |
\edef\tikz@temp{{\pgfkeysvalueof{/tikz/graphs/default edge kind}}{#3}{#4}} |
| 1672 |
\expandafter\tikz@lib@graph@set@simple@edge\tikz@temp{#1}{#2}% |
| 1673 |
\else% |
| 1674 |
\pgfkeys{/tikz/graphs/.cd,new \pgfkeysvalueof{/tikz/graphs/default edge kind}={#3}{#4}{#1}{#2}}% |
| 1675 |
\fi% |
| 1676 |
}% |
| 1677 |
\def\tikz@lib@graph@add@edge@annotations#1#2{% |
| 1678 |
\ifcsname tikz@lgc#1@@#2\endcsname% |
| 1679 |
\expandafter\let\expandafter\tikz@lg@temp@\csname tikz@lgc#1@@#2\endcsname% |
| 1680 |
\ifx\tikz@lg@temp@\relax\else |
| 1681 |
\expandafter\tikz@lib@graph@add@edge@annotations@\tikz@lg@temp@% |
| 1682 |
\let\tikz@lib@add@temp\tikz@lib@final@edge@style |
| 1683 |
\fi% |
| 1684 |
\fi% |
| 1685 |
}% |
| 1686 |
\def\tikz@lib@graph@add@edge@annotations@#1#2{ |
| 1687 |
\expandafter\def\expandafter\pgf@temp\expandafter{\pgf@temp,#1}% |
| 1688 |
\expandafter\def\expandafter\pgf@temp@b\expandafter{\pgf@temp@b#2}% |
| 1689 |
}% |
| 1690 |
\def\tikz@lib@final@edge@style{,after source and target edge/.try}% |
| 1691 |
|
| 1692 |
% |
| 1693 |
% The clique connector |
| 1694 |
% |
| 1695 |
|
| 1696 |
\tikzgraphsset{ |
| 1697 |
clique/.style={operator={ |
| 1698 |
\tikzgraphpreparecolor{#1}\c@pgf@counta{tikz@lg}% |
| 1699 |
\tikz@lg@clique@loop% |
| 1700 |
}}, |
| 1701 |
clique/.default=all |
| 1702 |
}% |
| 1703 |
|
| 1704 |
\def\tikz@lg@clique@loop{% |
| 1705 |
\ifnum\c@pgf@counta=0\relax% |
| 1706 |
\else |
| 1707 |
\c@pgf@countb=\c@pgf@counta\relax% |
| 1708 |
\tikz@lg@clique@loop@inner% |
| 1709 |
\advance\c@pgf@counta by-1\relax% |
| 1710 |
\expandafter\tikz@lg@clique@loop% |
| 1711 |
\fi% |
| 1712 |
}% |
| 1713 |
|
| 1714 |
\def\tikz@lg@clique@loop@inner{% |
| 1715 |
\advance\c@pgf@countb by-1\relax% |
| 1716 |
\ifnum\c@pgf@countb>0\relax% |
| 1717 |
\tikz@lib@graph@default@new@edge{\csname tikz@lg\the\c@pgf@countb\endcsname}{\csname tikz@lg\the\c@pgf@counta\endcsname}% |
| 1718 |
\expandafter\tikz@lg@clique@loop@inner% |
| 1719 |
\fi% |
| 1720 |
}% |
| 1721 |
|
| 1722 |
|
| 1723 |
% |
| 1724 |
% The independent set connector |
| 1725 |
% |
| 1726 |
|
| 1727 |
\tikzgraphsset{ |
| 1728 |
induced independent set/.style={operator={ |
| 1729 |
\pgfkeysgetvalue{/tikz/graphs/default edge kind}\tikz@lg@default% |
| 1730 |
\pgfkeyssetvalue{/tikz/graphs/default edge kind}{-!-}% |
| 1731 |
\tikzgraphpreparecolor{#1}\c@pgf@counta{tikz@lg}% |
| 1732 |
\tikz@lg@indep@loop% |
| 1733 |
\pgfkeyslet{/tikz/graphs/default edge kind}\tikz@lg@default% |
| 1734 |
}}, |
| 1735 |
induced independent set/.default=all |
| 1736 |
}% |
| 1737 |
|
| 1738 |
\def\tikz@lg@indep@loop{% |
| 1739 |
\ifnum\c@pgf@counta=0\relax% |
| 1740 |
\else |
| 1741 |
\c@pgf@countb=\c@pgf@counta\relax% |
| 1742 |
\tikz@lg@indep@loop@inner% |
| 1743 |
\advance\c@pgf@counta by-1\relax% |
| 1744 |
\expandafter\tikz@lg@indep@loop% |
| 1745 |
\fi% |
| 1746 |
}% |
| 1747 |
|
| 1748 |
\def\tikz@lg@indep@loop@inner{% |
| 1749 |
\advance\c@pgf@countb by-1\relax% |
| 1750 |
\ifnum\c@pgf@countb>0\relax% |
| 1751 |
\tikz@lib@graph@default@new@edge{\csname tikz@lg\the\c@pgf@counta\endcsname}{\csname tikz@lg\the\c@pgf@countb\endcsname}% |
| 1752 |
\expandafter\tikz@lg@indep@loop@inner% |
| 1753 |
\fi% |
| 1754 |
}% |
| 1755 |
|
| 1756 |
|
| 1757 |
% |
| 1758 |
% The path connector |
| 1759 |
% |
| 1760 |
|
| 1761 |
\tikzgraphsset{ |
| 1762 |
path/.style={operator={% |
| 1763 |
\let\tikz@lg@prev\relax% |
| 1764 |
\tikzgraphforeachcolorednode{#1}\tikz@lib@graph@path@do% |
| 1765 |
}}, |
| 1766 |
path/.default=all, |
| 1767 |
induced path/.style={induced independent set={#1},path={#1}}, |
| 1768 |
induced path/.default=all, |
| 1769 |
}% |
| 1770 |
|
| 1771 |
\def\tikz@lib@graph@path@do#1{% |
| 1772 |
\ifx\tikz@lg@prev\relax% |
| 1773 |
\else% |
| 1774 |
\tikz@lib@graph@default@new@edge{\tikz@lg@prev}{#1}% |
| 1775 |
\fi |
| 1776 |
\def\tikz@lg@prev{#1}% |
| 1777 |
}% |
| 1778 |
|
| 1779 |
|
| 1780 |
% |
| 1781 |
% The cycle connector |
| 1782 |
% |
| 1783 |
|
| 1784 |
\tikzgraphsset{ |
| 1785 |
cycle/.style={operator={% |
| 1786 |
\let\tikz@lg@prev\relax% |
| 1787 |
\let\tikz@lg@first\relax% |
| 1788 |
\tikzgraphforeachcolorednode{#1}\tikz@lib@graph@cycle@do% |
| 1789 |
\ifx\tikz@lg@first\relax% |
| 1790 |
\else% |
| 1791 |
\tikz@lib@graph@default@new@edge{\tikz@lg@prev}{\tikz@lg@first}% |
| 1792 |
\fi% |
| 1793 |
}}, |
| 1794 |
cycle/.default=all, |
| 1795 |
induced cycle/.style={induced independent set={#1},cycle={#1}}, |
| 1796 |
induced cycle/.default=all, |
| 1797 |
}% |
| 1798 |
|
| 1799 |
\def\tikz@lib@graph@cycle@do#1{% |
| 1800 |
\ifx\tikz@lg@prev\relax% |
| 1801 |
\def\tikz@lg@prev{#1}% |
| 1802 |
\let\tikz@lg@first\tikz@lg@prev% |
| 1803 |
\else% |
| 1804 |
\tikz@lib@graph@default@new@edge{\tikz@lg@prev}{#1}% |
| 1805 |
\def\tikz@lg@prev{#1}% |
| 1806 |
\fi% |
| 1807 |
}% |
| 1808 |
|
| 1809 |
|
| 1810 |
|
| 1811 |
|
| 1812 |
% |
| 1813 |
% The matching and star connector |
| 1814 |
% |
| 1815 |
|
| 1816 |
\tikzgraphsset{ |
| 1817 |
matching and star/.style 2 args={operator=% |
| 1818 |
{% |
| 1819 |
\tikzgraphpreparecolor{#1}\c@pgf@counta{tikz@lg} |
| 1820 |
\c@pgf@countb=0\relax% |
| 1821 |
\let\tikz@lg@prev\relax |
| 1822 |
\tikzgraphforeachcolorednode{#2}\tikz@lib@graph@flow@do% |
| 1823 |
\tikz@lib@graph@flow@rest% |
| 1824 |
}% |
| 1825 |
}, |
| 1826 |
matching and star/.default={target'}{source'} |
| 1827 |
}% |
| 1828 |
|
| 1829 |
\def\tikz@lib@graph@flow@do#1{% |
| 1830 |
\advance\c@pgf@countb by1\relax% |
| 1831 |
\ifnum\c@pgf@countb>\c@pgf@counta\relax% |
| 1832 |
\c@pgf@countb=\c@pgf@counta\relax% |
| 1833 |
\fi% |
| 1834 |
\ifnum\c@pgf@countb>0\relax% |
| 1835 |
\tikz@lib@graph@default@new@edge{\csname tikz@lg\the\c@pgf@countb\endcsname}{#1}% |
| 1836 |
\fi% |
| 1837 |
\def\tikz@lg@prev{#1}% |
| 1838 |
}% |
| 1839 |
|
| 1840 |
\def\tikz@lib@graph@flow@rest{% |
| 1841 |
\ifnum\c@pgf@countb<\c@pgf@counta\relax% |
| 1842 |
\ifnum\c@pgf@countb>0\relax% |
| 1843 |
\advance\c@pgf@countb by1\relax% |
| 1844 |
\tikz@lib@graph@default@new@edge{\csname tikz@lg\the\c@pgf@countb\endcsname}{\tikz@lg@prev}% |
| 1845 |
\expandafter\tikz@lib@graph@flow@rest% |
| 1846 |
\fi% |
| 1847 |
\fi% |
| 1848 |
}% |
| 1849 |
|
| 1850 |
|
| 1851 |
|
| 1852 |
% |
| 1853 |
% The matching connector |
| 1854 |
% |
| 1855 |
|
| 1856 |
\tikzgraphsset{ |
| 1857 |
matching/.style 2 args={operator= |
| 1858 |
{% |
| 1859 |
\tikzgraphpreparecolor{#1}\c@pgf@counta{tikz@lg} |
| 1860 |
\c@pgf@countb=0\relax% |
| 1861 |
\tikzgraphforeachcolorednode{#2}\tikz@lib@graph@matching@do% |
| 1862 |
}% |
| 1863 |
}, |
| 1864 |
matching/.default={target'}{source'} |
| 1865 |
}% |
| 1866 |
|
| 1867 |
\def\tikz@lib@graph@matching@do#1{% |
| 1868 |
\advance\c@pgf@countb by1\relax% |
| 1869 |
\ifnum\c@pgf@countb>\c@pgf@counta\relax% |
| 1870 |
\else% |
| 1871 |
\tikz@lib@graph@default@new@edge{\csname tikz@lg\the\c@pgf@countb\endcsname}{#1}% |
| 1872 |
\fi% |
| 1873 |
}% |
| 1874 |
|
| 1875 |
|
| 1876 |
|
| 1877 |
|
| 1878 |
|
| 1879 |
% |
| 1880 |
% The butterfly connector |
| 1881 |
% |
| 1882 |
|
| 1883 |
\tikzgraphsset{ |
| 1884 |
butterfly/.style={operator= |
| 1885 |
{}{% |
| 1886 |
\pgfkeys{/tikz/graphs/butterfly/.cd,#1}% |
| 1887 |
\ifnum\pgfkeysvalueof{/tikz/graphs/butterfly/level}=0\relax% |
| 1888 |
\tikzgraphinvokeoperator{matching and star={\pgfkeysvalueof{/tikz/graphs/butterfly/from}}{\pgfkeysvalueof{/tikz/graphs/butterfly/to}}}% |
| 1889 |
\else% |
| 1890 |
{% |
| 1891 |
\tikzgraphpreparecolor{\pgfkeysvalueof{/tikz/graphs/butterfly/from}}\c@pgf@counta{tikz@lg} |
| 1892 |
\c@pgf@countb=0\relax% |
| 1893 |
\tikzgraphforeachcolorednode{\pgfkeysvalueof{/tikz/graphs/butterfly/to}}\tikz@lib@graph@butterfly@do% |
| 1894 |
}% |
| 1895 |
\iftikz@butterfly@prime\else\tikzgraphinvokeoperator{matching and star={\pgfkeysvalueof{/tikz/graphs/butterfly/from}}{\pgfkeysvalueof{/tikz/graphs/butterfly/to}}}\fi% |
| 1896 |
\fi% |
| 1897 |
}% |
| 1898 |
}, |
| 1899 |
butterfly/.default=, |
| 1900 |
butterfly/level/.initial=1, |
| 1901 |
butterfly/from/.initial=target', |
| 1902 |
butterfly/to/.initial=source', |
| 1903 |
butterfly'/.style={operator={}{\tikz@butterfly@primetrue\pgfkeysalso{butterfly={#1}}}}, |
| 1904 |
butterfly'/.default=, |
| 1905 |
}% |
| 1906 |
|
| 1907 |
\newif\iftikz@butterfly@prime |
| 1908 |
|
| 1909 |
\def\tikz@lib@graph@butterfly@do#1{% |
| 1910 |
\advance\c@pgf@countb by1\relax% |
| 1911 |
% Compute other side... |
| 1912 |
\c@pgf@countc=\pgfkeysvalueof{/tikz/graphs/butterfly/level}\relax% |
| 1913 |
{% |
| 1914 |
% Computer countb mod (2level) |
| 1915 |
\count0=\c@pgf@countc\relax% |
| 1916 |
\multiply\count0 by2\relax% |
| 1917 |
\count1=\c@pgf@countb\relax% |
| 1918 |
\advance\count1 by-1\relax% |
| 1919 |
\count2=\count1\relax% |
| 1920 |
\count3=\count1\relax% |
| 1921 |
\divide\count1 by\count0\relax% |
| 1922 |
\multiply\count1 by\count0\relax% |
| 1923 |
\advance\count2 by-\count1\relax% |
| 1924 |
% count0 = 2*level |
| 1925 |
% count2 = countb mod (2level) (starting with 0) |
| 1926 |
% count1 = countb - count2 (starting with 0) |
| 1927 |
\ifnum\count2<\c@pgf@countc\relax% |
| 1928 |
\advance\count3 by \c@pgf@countc\relax% |
| 1929 |
\else% |
| 1930 |
\advance\count3 by -\c@pgf@countc\relax% |
| 1931 |
\fi% |
| 1932 |
\expandafter% |
| 1933 |
}% |
| 1934 |
\expandafter\c@pgf@countc\the\count3\relax% |
| 1935 |
\advance\c@pgf@countc by1\relax% |
| 1936 |
\ifnum\c@pgf@countc>\c@pgf@counta\relax% |
| 1937 |
\c@pgf@countc=\c@pgf@counta\relax% |
| 1938 |
\fi% |
| 1939 |
\tikz@lib@graph@default@new@edge{\csname tikz@lg\the\c@pgf@countc\endcsname}{#1}% |
| 1940 |
}% |
| 1941 |
|
| 1942 |
|
| 1943 |
|
| 1944 |
|
| 1945 |
% |
| 1946 |
% The no edges connector |
| 1947 |
% |
| 1948 |
\tikzgraphsset{no edges/.style={operator=\relax}}% |
| 1949 |
|
| 1950 |
|
| 1951 |
|
| 1952 |
|
| 1953 |
% |
| 1954 |
% The grid connector |
| 1955 |
% |
| 1956 |
\tikzgraphsset{ |
| 1957 |
grid/.style={operator={ |
| 1958 |
\tikzgraphpreparecolor{#1}\c@pgf@counta{tikz@lg}% |
| 1959 |
\c@pgf@countb=0\relax% |
| 1960 |
\tikzgraphpreparewrapafter% |
| 1961 |
\tikz@lg@grid@loop% |
| 1962 |
}% |
| 1963 |
}, |
| 1964 |
grid/.default=all |
| 1965 |
}% |
| 1966 |
|
| 1967 |
\def\tikzgraphpreparewrapafter{% |
| 1968 |
\pgfkeysgetvalue{/tikz/graphs/wrap after}\tikz@temp% |
| 1969 |
\ifnum\tikz@temp=0\relax% |
| 1970 |
\pgfmathparse{sqrt(\tikzgraphVnum)}% |
| 1971 |
\pgfmathint{\pgfmathresult}% |
| 1972 |
\edef\tikzgraphwrapafter{\pgfmathresult}% |
| 1973 |
\else% |
| 1974 |
\edef\tikzgraphwrapafter{\tikz@temp} |
| 1975 |
\fi% |
| 1976 |
}% |
| 1977 |
|
| 1978 |
\def\tikz@lg@grid@loop{% |
| 1979 |
\ifnum\c@pgf@counta=0\relax% |
| 1980 |
\else% |
| 1981 |
\advance\c@pgf@countb by 1\relax% |
| 1982 |
\pgfmathmod{\c@pgf@countb-1}{\tikzgraphwrapafter}% |
| 1983 |
\pgfmathint{\pgfmathresult}% |
| 1984 |
\ifnum\pgfmathresult>0% |
| 1985 |
\pgfmathsubtract{\c@pgf@countb}{1}% |
| 1986 |
\pgfmathint{\pgfmathresult}% |
| 1987 |
\tikz@lib@graph@default@new@edge{\csname tikz@lg\the\c@pgf@countb\endcsname}{\csname tikz@lg\pgfmathresult\endcsname}% |
| 1988 |
\fi% |
| 1989 |
\pgfmathparse{\c@pgf@countb <= \tikzgraphwrapafter}% |
| 1990 |
\ifnum\pgfmathresult=0% |
| 1991 |
\pgfmathsubtract{\c@pgf@countb}{\tikzgraphwrapafter}% |
| 1992 |
\pgfmathint{\pgfmathresult}% |
| 1993 |
\tikz@lib@graph@default@new@edge{\csname tikz@lg\pgfmathresult\endcsname}{\csname tikz@lg\the\c@pgf@countb\endcsname}% |
| 1994 |
\fi% |
| 1995 |
\advance\c@pgf@counta by-1\relax% |
| 1996 |
\expandafter\tikz@lg@grid@loop% |
| 1997 |
\fi% |
| 1998 |
}% |
| 1999 |
|
| 2000 |
|
| 2001 |
|
| 2002 |
|
| 2003 |
% Positioning |
| 2004 |
% |
| 2005 |
% It is not the job of the graph library to compute good positions for |
| 2006 |
% nodes in a graph. However, some basic support is provided for simple |
| 2007 |
% cases. |
| 2008 |
% |
| 2009 |
% The idea is at follows: Graphs are specified hierarchically. For |
| 2010 |
% instance, consider the following graph specification: |
| 2011 |
% |
| 2012 |
% graph { a, b, c -> d -> {e -> f -> g, h} -> i, j -> k } |
| 2013 |
% |
| 2014 |
% Here, we have the *group* {e->f->g,h} inside the larger graph |
| 2015 |
% specification. Each group consists of sequence of *chains* like |
| 2016 |
% e->f->g or j->k. |
| 2017 |
% |
| 2018 |
% In order to facilitate the automatic positioning of nodes, the graph |
| 2019 |
% library will provide you with information about the position of |
| 2020 |
% nodes inside their groups and chains. |
| 2021 |
% |
| 2022 |
% As a chain is being parsed, a counter stored in |
| 2023 |
% /tikz/graphs/placement/element count is available that is advanced for |
| 2024 |
% each element in the chain. |
| 2025 |
% |
| 2026 |
% Additionally, a counter stored in placement/width is |
| 2027 |
% available. This "logical" width is defined recursively as follows: The |
| 2028 |
% width of a single node is computed by calling the key |
| 2029 |
% placement/logical node width, which should return a real or logical |
| 2030 |
% width of the node passed as a parameter in the macro \pgfmathresult. The |
| 2031 |
% width of a chain is the sum of the widths of its elements. The |
| 2032 |
% width of a group is the maximum of the widths of its elements. |
| 2033 |
% |
| 2034 |
% |
| 2035 |
% Symmetrically, as a group is being constructed, a counter stored in |
| 2036 |
% placement/chain count is available that is advanced for each chain |
| 2037 |
% in the group. The number placement/depth is the defined |
| 2038 |
% recursively as follows: For a single node, the depth is |
| 2039 |
% computed by the key placement/logical node depth. The depth |
| 2040 |
% of a group is the sum of the depths of its elements. The depth of a |
| 2041 |
% chain is the maximum of the depth of its elements. |
| 2042 |
% |
| 2043 |
% |
| 2044 |
% The above keys get updated automatically. You should setup the key |
| 2045 |
% placement/compute position such that it uses the above keys to |
| 2046 |
% compute a good position for a new node based on the above |
| 2047 |
% keys. Typically, this key should execute node={shift=(...)} to setup |
| 2048 |
% the necessary shift for a new node. |
| 2049 |
% |
| 2050 |
% The key placement/compute position should not be called |
| 2051 |
% directly. Instead, the key placement/place should be used. This key |
| 2052 |
% has two effects: First, it calls placement/compute position. Second, |
| 2053 |
% it resets the length and normal counters. It will setup a completely |
| 2054 |
% new counting of lengths and counters inside the current scope. |
| 2055 |
% |
| 2056 |
% The placement/place key is executed automatically whenever a new |
| 2057 |
% node is automatically created. Furthermore, placement strategies |
| 2058 |
% will call this key. |
| 2059 |
|
| 2060 |
\tikzgraphsset{ |
| 2061 |
placement/.cd, |
| 2062 |
compute position/.code=\tikz@lib@graph@linear@pos, |
| 2063 |
place/.code={% |
| 2064 |
\pgfkeys{/tikz/graphs/placement/compute position}% |
| 2065 |
\aftergroup\tikz@lib@graph@reset@locals% |
| 2066 |
\pgfkeyssetvalue{/tikz/graphs/placement/element count}{0}% |
| 2067 |
\pgfkeyssetvalue{/tikz/graphs/placement/chain count}{0}% |
| 2068 |
\pgfkeyssetvalue{/tikz/graphs/placement/depth}{0}% |
| 2069 |
\pgfkeyssetvalue{/tikz/graphs/placement/width}{0}% |
| 2070 |
\pgfkeyssetvalue{/tikz/graphs/placement/local depth}{0}% |
| 2071 |
\pgfkeyssetvalue{/tikz/graphs/placement/local width}{0}% |
| 2072 |
}, |
| 2073 |
element count/.initial=0, |
| 2074 |
chain count/.initial=0, |
| 2075 |
depth/.initial=0, |
| 2076 |
width/.initial=0, |
| 2077 |
level/.initial=0, |
| 2078 |
logical node depth/.code=\def\pgfmathresult{1}, |
| 2079 |
logical node width/.code=\def\pgfmathresult{1}, |
| 2080 |
}% |
| 2081 |
|
| 2082 |
\def\tikz@lib@graph@reset@locals{% |
| 2083 |
\gdef\tikz@lib@graph@group@depth{0}% |
| 2084 |
\gdef\tikz@lib@graph@group@width{0}% |
| 2085 |
}% |
| 2086 |
|
| 2087 |
|
| 2088 |
% Arrange nodes evenly |
| 2089 |
% |
| 2090 |
% This strategy works as follows: You specify a "chain shift vector" |
| 2091 |
% and a "group shift vector". Then each new element on a chain is |
| 2092 |
% shifted by the chain shift vector relative to the previous element |
| 2093 |
% on the chain. Similarly for each new element of a group. |
| 2094 |
|
| 2095 |
\tikzgraphsset{ |
| 2096 |
Cartesian placement/.style={ |
| 2097 |
placement/place, |
| 2098 |
placement/compute position/.code=\tikz@lib@graph@linear@pos% |
| 2099 |
}, |
| 2100 |
chain shift/.initial={(1,0)}, |
| 2101 |
group shift/.initial={(0,-1)}, |
| 2102 |
grow right/.style={ |
| 2103 |
placement/place, |
| 2104 |
chain shift={(#1,0)}, |
| 2105 |
@auto anchor horizontal=center, |
| 2106 |
placement/logical node width/.code=\def\pgfmathresult{1} |
| 2107 |
}, |
| 2108 |
grow right/.default=1, |
| 2109 |
grow left/.style={ |
| 2110 |
placement/place, |
| 2111 |
chain shift={(-#1,0)}, |
| 2112 |
@auto anchor horizontal=center, |
| 2113 |
placement/logical node width/.code=\def\pgfmathresult{1} |
| 2114 |
}, |
| 2115 |
grow left/.default=1, |
| 2116 |
grow up/.style={ |
| 2117 |
placement/place, |
| 2118 |
chain shift={(0,#1)}, |
| 2119 |
@auto anchor horizontal=center, |
| 2120 |
placement/logical node width/.code=\def\pgfmathresult{1} |
| 2121 |
}, |
| 2122 |
grow up/.default=1, |
| 2123 |
grow down/.style={ |
| 2124 |
placement/place, |
| 2125 |
chain shift={(0,-#1)}, |
| 2126 |
@auto anchor vertical=center, |
| 2127 |
placement/logical node width/.code=\def\pgfmathresult{1} |
| 2128 |
}, |
| 2129 |
grow down/.default=1, |
| 2130 |
branch right/.style={ |
| 2131 |
placement/place, |
| 2132 |
group shift={(#1,0)}, |
| 2133 |
@auto anchor horizontal=center, |
| 2134 |
placement/logical node depth/.code=\def\pgfmathresult{1} |
| 2135 |
}, |
| 2136 |
branch right/.default=1, |
| 2137 |
branch left/.style={ |
| 2138 |
placement/place, |
| 2139 |
group shift={(-#1,0)}, |
| 2140 |
@auto anchor horizontal=center, |
| 2141 |
placement/logical node depth/.code=\def\pgfmathresult{1} |
| 2142 |
}, |
| 2143 |
branch left/.default=1, |
| 2144 |
branch up/.style={ |
| 2145 |
placement/place, |
| 2146 |
group shift={(0,#1)}, |
| 2147 |
@auto anchor vertical=center, |
| 2148 |
placement/logical node depth/.code=\def\pgfmathresult{1} |
| 2149 |
}, |
| 2150 |
branch up/.default=1, |
| 2151 |
branch down/.style={ |
| 2152 |
placement/place, |
| 2153 |
group shift={(0,-#1)}, |
| 2154 |
@auto anchor vertical=center, |
| 2155 |
placement/logical node depth/.code=\def\pgfmathresult{1} |
| 2156 |
}, |
| 2157 |
branch down/.default=1, |
| 2158 |
% |
| 2159 |
% Sep shifts |
| 2160 |
% |
| 2161 |
grow right sep/.style={ |
| 2162 |
Cartesian placement, |
| 2163 |
chain shift={(1pt,0)}, |
| 2164 |
@auto anchor horizontal=west, |
| 2165 |
placement/logical node width/.code=\tikz@lib@graph@width@sep{##1}{#1} |
| 2166 |
}, |
| 2167 |
grow right sep/.default=1em, |
| 2168 |
grow left sep/.style={ |
| 2169 |
Cartesian placement, |
| 2170 |
chain shift={(-1pt,0)}, |
| 2171 |
@auto anchor horizontal=east, |
| 2172 |
placement/logical node width/.code=\tikz@lib@graph@width@sep{##1}{#1} |
| 2173 |
}, |
| 2174 |
grow left sep/.default=1em, |
| 2175 |
grow up sep/.style={ |
| 2176 |
Cartesian placement, |
| 2177 |
chain shift={(0,1pt)}, |
| 2178 |
@auto anchor vertical=south, |
| 2179 |
placement/logical node width/.code=\tikz@lib@graph@depth@sep{##1}{#1} |
| 2180 |
}, |
| 2181 |
grow up sep/.default=1em, |
| 2182 |
grow down sep/.style={ |
| 2183 |
Cartesian placement, |
| 2184 |
chain shift={(0,-1pt)}, |
| 2185 |
@auto anchor vertical=north, |
| 2186 |
placement/logical node width/.code=\tikz@lib@graph@depth@sep{##1}{#1} |
| 2187 |
}, |
| 2188 |
grow down sep/.default=1em, |
| 2189 |
grow right sep/.style={ |
| 2190 |
Cartesian placement, |
| 2191 |
chain shift={(1pt,0)}, |
| 2192 |
@auto anchor horizontal=west, |
| 2193 |
placement/logical node width/.code=\tikz@lib@graph@width@sep{##1}{#1} |
| 2194 |
}, |
| 2195 |
% |
| 2196 |
branch right sep/.style={ |
| 2197 |
Cartesian placement, |
| 2198 |
group shift={(1pt,0)}, |
| 2199 |
@auto anchor horizontal=west, |
| 2200 |
placement/logical node depth/.code=\tikz@lib@graph@width@sep{##1}{#1} |
| 2201 |
}, |
| 2202 |
branch right sep/.default=1em, |
| 2203 |
branch left sep/.style={ |
| 2204 |
Cartesian placement, |
| 2205 |
group shift={(-1pt,0)}, |
| 2206 |
@auto anchor horizontal=east, |
| 2207 |
placement/logical node depth/.code=\tikz@lib@graph@width@sep{##1}{#1} |
| 2208 |
}, |
| 2209 |
branch left sep/.default=1em, |
| 2210 |
branch up sep/.style={ |
| 2211 |
Cartesian placement, |
| 2212 |
group shift={(0,1pt)}, |
| 2213 |
@auto anchor vertical=south, |
| 2214 |
placement/logical node depth/.code=\tikz@lib@graph@depth@sep{##1}{#1} |
| 2215 |
}, |
| 2216 |
branch up sep/.default=1em, |
| 2217 |
branch down sep/.style={ |
| 2218 |
Cartesian placement, |
| 2219 |
group shift={(0,-1pt)}, |
| 2220 |
@auto anchor vertical=north, |
| 2221 |
placement/logical node depth/.code=\tikz@lib@graph@depth@sep{##1}{#1} |
| 2222 |
}, |
| 2223 |
branch down sep/.default=1em, |
| 2224 |
% |
| 2225 |
@auto anchor horizontal/.style={ |
| 2226 |
nodes={anchor=\csname tikz@lib@graph@auto@\tikz@lib@graph@auto@h @\tikz@lib@graph@auto@v\endcsname}, |
| 2227 |
/utils/exec=\def\tikz@lib@graph@auto@h{#1} |
| 2228 |
}, |
| 2229 |
@auto anchor vertical/.style={ |
| 2230 |
nodes={anchor=\csname tikz@lib@graph@auto@\tikz@lib@graph@auto@h @\tikz@lib@graph@auto@v\endcsname}, |
| 2231 |
/utils/exec=\def\tikz@lib@graph@auto@v{#1} |
| 2232 |
}, |
| 2233 |
% |
| 2234 |
% |
| 2235 |
no placement/.style={ |
| 2236 |
placement/place, |
| 2237 |
placement/compute position/.code=% |
| 2238 |
} |
| 2239 |
}% |
| 2240 |
|
| 2241 |
\def\tikz@lib@graph@auto@h{center}% |
| 2242 |
\def\tikz@lib@graph@auto@v{center}% |
| 2243 |
|
| 2244 |
\def\tikz@lib@graph@auto@center@center{center}% |
| 2245 |
\def\tikz@lib@graph@auto@west@center{west}% |
| 2246 |
\def\tikz@lib@graph@auto@east@center{east}% |
| 2247 |
\def\tikz@lib@graph@auto@center@north{north}% |
| 2248 |
\def\tikz@lib@graph@auto@west@north{north west}% |
| 2249 |
\def\tikz@lib@graph@auto@east@north{north east}% |
| 2250 |
\def\tikz@lib@graph@auto@center@south{south}% |
| 2251 |
\def\tikz@lib@graph@auto@west@south{south west}% |
| 2252 |
\def\tikz@lib@graph@auto@east@south{south east}% |
| 2253 |
|
| 2254 |
\def\tikz@lib@graph@linear@pos{% |
| 2255 |
\pgfkeysgetvalue{/tikz/graphs/chain shift}\tikz@temp |
| 2256 |
\expandafter\tikz@scan@one@point\expandafter\pgf@process\tikz@temp |
| 2257 |
\pgf@process{\pgfpointscale{\pgfkeysvalueof{/tikz/graphs/placement/width}}{}}% |
| 2258 |
\pgf@xa=\pgf@x% |
| 2259 |
\pgf@ya=\pgf@y% |
| 2260 |
\pgfkeysgetvalue{/tikz/graphs/group shift}\tikz@temp |
| 2261 |
\expandafter\tikz@scan@one@point\expandafter\pgf@process\tikz@temp |
| 2262 |
\pgf@process{\pgfpointscale{\pgfkeysvalueof{/tikz/graphs/placement/depth}}{}}% |
| 2263 |
\advance\pgf@xa by\pgf@x% |
| 2264 |
\advance\pgf@ya by\pgf@y% |
| 2265 |
\edef\tikz@lib@graph@shift{(\the\pgf@xa,\the\pgf@ya)} |
| 2266 |
\pgfkeys{/tikz/graphs/nodes/.expanded={shift={\tikz@lib@graph@shift}}} |
| 2267 |
}% |
| 2268 |
|
| 2269 |
|
| 2270 |
\def\tikz@lib@graph@width@sep#1#2{% |
| 2271 |
\pgf@process{\pgfpointdiff{\pgfpointanchor{#1}{west}}{\pgfpointanchor{#1}{east}}}% |
| 2272 |
\pgfmathparse{#2+\the\pgf@x}% |
| 2273 |
}% |
| 2274 |
|
| 2275 |
\def\tikz@lib@graph@depth@sep#1#2{% |
| 2276 |
\pgf@process{\pgfpointdiff{\pgfpointanchor{#1}{south}}{\pgfpointanchor{#1}{north}}}% |
| 2277 |
\pgfmathparse{#2+\the\pgf@y}% |
| 2278 |
}% |
| 2279 |
|
| 2280 |
|
| 2281 |
% Circular arrangements |
| 2282 |
% |
| 2283 |
% This strategy works a bit like the arrange evenly strategy, but in |
| 2284 |
% polar coordinates. Both for the chains and the groups you specify a |
| 2285 |
% polar shift, which must be in the form "(delta degree:delta |
| 2286 |
% distance)". For each element in a chain, the delta degree is added |
| 2287 |
% to the chain degree, likewise for each element the delta distance is |
| 2288 |
% added. Similarly for groups. |
| 2289 |
% |
| 2290 |
% There is an initial degree and radius, stored in the key "phase" and |
| 2291 |
% "radius". |
| 2292 |
|
| 2293 |
\tikzgraphsset{, |
| 2294 |
circular placement/.style={ |
| 2295 |
placement/place, |
| 2296 |
placement/compute position/.code=\tikz@lib@graph@circular@pos,% |
| 2297 |
placement/logical node depth/.code=\def\pgfmathresult{1}, |
| 2298 |
placement/logical node width/.code=\def\pgfmathresult{1}, |
| 2299 |
}, |
| 2300 |
clockwise/.style={ |
| 2301 |
circular placement, |
| 2302 |
group polar shift={(-360/#1:0)} |
| 2303 |
}, |
| 2304 |
clockwise/.default=\tikzgraphVnum, |
| 2305 |
counterclockwise/.style={ |
| 2306 |
circular placement, |
| 2307 |
group polar shift={(360/#1:0)} |
| 2308 |
}, |
| 2309 |
counterclockwise/.default=\tikzgraphVnum, |
| 2310 |
chain polar shift/.initial={(0:1cm)}, |
| 2311 |
group polar shift/.initial={(60:0)}, |
| 2312 |
radius/.initial=1cm, |
| 2313 |
phase/.initial=90, |
| 2314 |
}% |
| 2315 |
|
| 2316 |
\def\tikz@lib@graph@circular@pos{% |
| 2317 |
\pgfkeysgetvalue{/tikz/graphs/chain polar shift}\tikz@temp |
| 2318 |
\expandafter\tikz@lib@graph@decompose@polar\tikz@temp% |
| 2319 |
\pgf@process{\pgfpointscale{\pgfkeysvalueof{/tikz/graphs/placement/width}}{}}% |
| 2320 |
\pgf@xa=\pgf@x% |
| 2321 |
\pgf@ya=\pgf@y% |
| 2322 |
\pgfkeysgetvalue{/tikz/graphs/group polar shift}\tikz@temp |
| 2323 |
\expandafter\tikz@lib@graph@decompose@polar\tikz@temp% |
| 2324 |
\pgf@process{\pgfpointscale{\pgfkeysvalueof{/tikz/graphs/placement/depth}}{}}% |
| 2325 |
\advance\pgf@xa by\pgf@x% |
| 2326 |
\advance\pgf@ya by\pgf@y% |
| 2327 |
\pgfmathparse{\pgfkeysvalueof{/tikz/graphs/radius}}% |
| 2328 |
\advance\pgf@ya by\pgfmathresult pt% |
| 2329 |
\pgfmathsetmacro\tikz@temp{\the\pgf@xa+\pgfkeysvalueof{/tikz/graphs/phase}}% |
| 2330 |
\edef\tikz@lib@graph@shift{(\tikz@temp:\the\pgf@ya)} |
| 2331 |
\pgfkeys{/tikz/graphs/nodes/.expanded={shift={\tikz@lib@graph@shift}}} |
| 2332 |
}% |
| 2333 |
|
| 2334 |
|
| 2335 |
\def\tikz@lib@graph@decompose@polar(#1:#2){% |
| 2336 |
\pgfmathsetlength\pgf@x{#1}% |
| 2337 |
\pgfmathsetlength\pgf@y{#2}% |
| 2338 |
}% |
| 2339 |
|
| 2340 |
|
| 2341 |
% Grid arrangements |
| 2342 |
% |
| 2343 |
\tikzgraphsset{ |
| 2344 |
grid placement/.style={ |
| 2345 |
placement/place, |
| 2346 |
placement/compute position/.code=\tikz@lib@graph@grid@pos,% |
| 2347 |
}, |
| 2348 |
}% |
| 2349 |
|
| 2350 |
|
| 2351 |
\def\tikz@lib@graph@grid@pos{% |
| 2352 |
% |
| 2353 |
% Make sure to set \tikzgraphwrapafter before we compute |
| 2354 |
% the positions of nodes in the grid |
| 2355 |
% |
| 2356 |
\tikzgraphpreparewrapafter% |
| 2357 |
% |
| 2358 |
% find out the coordinate in the grid |
| 2359 |
% |
| 2360 |
\pgfkeysgetvalue{/tikz/graphs/placement/depth}\tikz@temp@depth% |
| 2361 |
\pgfkeysgetvalue{/tikz/graphs/placement/width}\tikz@temp@width% |
| 2362 |
\pgfmathsetmacro{\tikz@temp}{max(\tikz@temp@depth, \tikz@temp@width)}% |
| 2363 |
\pgfmathsetmacro{\tikz@temp@col}{mod(\tikz@temp,\tikzgraphwrapafter)}% |
| 2364 |
\pgfmathsetmacro{\tikz@temp@row}{div(\tikz@temp,\tikzgraphwrapafter)}% |
| 2365 |
% |
| 2366 |
% multiply row by the group shift and col by the chain shift |
| 2367 |
% |
| 2368 |
\pgfkeysgetvalue{/tikz/graphs/group shift}\tikz@temp% |
| 2369 |
\expandafter\tikz@scan@one@point\expandafter\tikz@lib@graph@grid@pos@a\tikz@temp% |
| 2370 |
\pgfkeysgetvalue{/tikz/graphs/chain shift}\tikz@temp% |
| 2371 |
\expandafter\tikz@scan@one@point\expandafter\tikz@lib@graph@grid@pos@b\tikz@temp% |
| 2372 |
% |
| 2373 |
% apply the shift |
| 2374 |
% |
| 2375 |
\edef\tikz@lib@graph@shift{(\the\pgf@xa,\the\pgf@ya)} |
| 2376 |
\pgfkeys{/tikz/graphs/nodes/.expanded={shift={\tikz@lib@graph@shift}}} |
| 2377 |
}% |
| 2378 |
|
| 2379 |
\def\tikz@lib@graph@grid@pos@a#1{\pgf@process{\pgfpointscale{\tikz@temp@row}{#1}}\pgf@xa=\pgf@x\relax\pgf@ya=\pgf@y\relax}% |
| 2380 |
\def\tikz@lib@graph@grid@pos@b#1{\pgf@process{\pgfpointscale{\tikz@temp@col}{#1}}% |
| 2381 |
\advance\pgf@xa by\pgf@x\relax |
| 2382 |
\advance\pgf@ya by\pgf@y\relax}% |
| 2383 |
|
| 2384 |
\tikzgraphsset{ |
| 2385 |
% Grids: |
| 2386 |
wrap after/.initial=0, |
| 2387 |
% Node sets: |
| 2388 |
V/.code={% |
| 2389 |
\def\tikzgraphV{#1}% |
| 2390 |
\c@pgf@counta=0\foreach \tikz@dummy in {#1} {\global\advance\c@pgf@counta by1\relax}% |
| 2391 |
\edef\tikzgraphVnum{\the\c@pgf@counta} |
| 2392 |
}, |
| 2393 |
V={1}, |
| 2394 |
n/.style={V={1,...,#1},name shore V/.style={name=V}}, |
| 2395 |
W/.code={% |
| 2396 |
\def\tikzgraphW{#1}% |
| 2397 |
\c@pgf@counta=0\foreach \tikz@dummy in {#1} {\global\advance\c@pgf@counta by1\relax}% |
| 2398 |
\edef\tikzgraphWnum{\the\c@pgf@counta} |
| 2399 |
}, |
| 2400 |
W={1}, |
| 2401 |
m/.style={W={1,...,#1},name shore W/.style={name=W}}, |
| 2402 |
% Shores: |
| 2403 |
name shore V/.style=, |
| 2404 |
name shore W/.style=, |
| 2405 |
}% |
| 2406 |
|
| 2407 |
|
| 2408 |
|
| 2409 |
% |
| 2410 |
% Quick graphs |
| 2411 |
% |
| 2412 |
% Parsing the graph syntax can take a lot of time for large |
| 2413 |
% graphs. This is mainly due to the transformation of commas and |
| 2414 |
% semicolons and all the internal bookkeeping. |
| 2415 |
% |
| 2416 |
% For large graphs, the quick graph syntax offers a greatly reduced |
| 2417 |
% syntax that will be processed much more quickly. This syntax is |
| 2418 |
% compatible with the normal graph syntax in the sense that all |
| 2419 |
% specifications written in the reduced syntax are also legal in the |
| 2420 |
% normal syntax, but not the other way round. |
| 2421 |
% |
| 2422 |
% The following rules apply: |
| 2423 |
% |
| 2424 |
% 1) A quick graph consists of a sequence of either nodes, edges sequences, or |
| 2425 |
% groups. These are separated by commas or semicolons. |
| 2426 |
% |
| 2427 |
% 2) Every node is of the form |
| 2428 |
% |
| 2429 |
% "node name"/"node text"[options] |
| 2430 |
% |
| 2431 |
% Here, the quotation marks are mandatory. The part '/"node text"' may |
| 2432 |
% be missing, in which case the node name is used as the node |
| 2433 |
% text. The options may also be missing. The node name may not contain |
| 2434 |
% any "funny" characters (unlike in the normal graph command). |
| 2435 |
% |
| 2436 |
% 3) Every edge is of the form |
| 2437 |
% |
| 2438 |
% <node spec> <connector> <node spec> <connector> <node spec> ... <connector> <node spec>; |
| 2439 |
% |
| 2440 |
% Here, the <node spec> are node specifications as described above, |
| 2441 |
% the <connector> is one of the four connectors "->", "<-", "--", and |
| 2442 |
% "<->", followed by optional options in square |
| 2443 |
% brackets. The semicolon may be replaced by a comma. |
| 2444 |
% |
| 2445 |
% 4) Every group is of the form |
| 2446 |
% |
| 2447 |
% { [options] lines }; |
| 2448 |
% |
| 2449 |
% The options are compulsory, the lines must be a sequence of nodes, |
| 2450 |
% edges, and groups as described above. The semicolon can, again, be |
| 2451 |
% replaced by a comma. |
| 2452 |
% |
| 2453 |
% |
| 2454 |
% Things that are allowed in the normal syntax, but not in the quick |
| 2455 |
% syntax, include: |
| 2456 |
% |
| 2457 |
% - Connecting a node and a group as in a->{b,c}. |
| 2458 |
% - Node names without quotation marks. |
| 2459 |
% - Using subgraphs (graph macros). |
| 2460 |
% - Using graph sets. |
| 2461 |
% - Using graph color classes. |
| 2462 |
% - Using anonymous nodes. |
| 2463 |
% - Using the "fresh nodes" option. |
| 2464 |
% - Using sublayouts. |
| 2465 |
% - Using the -!- edge connector. |
| 2466 |
% - Using the "simple" option. |
| 2467 |
% - Using edge annotations. |
| 2468 |
% |
| 2469 |
% Example: |
| 2470 |
% |
| 2471 |
% \graph [quick] { |
| 2472 |
% "a"/"$a$"[red] -> "b"[blue] -> "c"; |
| 2473 |
% "b" -> "d"; |
| 2474 |
% "c" ->[thick] "e"; |
| 2475 |
% { [same layer] "c", "d" }; |
| 2476 |
% }; |
| 2477 |
% |
| 2478 |
% |
| 2479 |
|
| 2480 |
\tikzgraphsset{quick/.is if=tikz@graph@quick}% |
| 2481 |
\newif\iftikz@graph@quick |
| 2482 |
|
| 2483 |
\def\tikz@lib@graphs@parse@quick@graph{ |
| 2484 |
% Ok, we are before the initial brace. We open a group and start |
| 2485 |
% setting up some bookkeeping |
| 2486 |
\begingroup% |
| 2487 |
\global\tikz@qnode@count0\relax% |
| 2488 |
\let\tikzgraphnodepath\pgfutil@empty% |
| 2489 |
\tikz@q@outertrue% |
| 2490 |
\afterassignment\tikz@lib@graphs@quick@main\let\pgf@temp=% |
| 2491 |
}% |
| 2492 |
|
| 2493 |
\newcount\tikz@qnode@count |
| 2494 |
\newif\iftikz@q@outer |
| 2495 |
|
| 2496 |
\def\tikz@lib@graphs@quick@main{% |
| 2497 |
\afterassignment\tikz@lib@graphs@quick@handle\let\pgf@let@token=% |
| 2498 |
}% |
| 2499 |
\def\tikz@lib@graphs@quick@handle{% |
| 2500 |
\ifx\pgf@let@token"% |
| 2501 |
\expandafter\tikz@lib@graphs@quick@first@node% |
| 2502 |
\else% |
| 2503 |
\expandafter\tikz@lib@graphs@quick@other% |
| 2504 |
\fi% |
| 2505 |
}% |
| 2506 |
\def\tikz@lib@graphs@quick@other{% |
| 2507 |
\let\tikz@next\tikz@lib@graphs@quick@error% |
| 2508 |
\ifx\pgf@let@token\egroup% |
| 2509 |
\let\tikz@next\tikz@lib@graphs@quick@end@group% |
| 2510 |
\else% |
| 2511 |
\ifx\pgf@let@token\bgroup% |
| 2512 |
\let\tikz@next\tikz@lib@graphs@quick@start@group% |
| 2513 |
\else% |
| 2514 |
\ifx\pgf@let@token\par% |
| 2515 |
\let\tikz@next\tikz@lib@graphs@quick@main% |
| 2516 |
\fi% |
| 2517 |
\fi |
| 2518 |
\fi% |
| 2519 |
\tikz@next% |
| 2520 |
}% |
| 2521 |
|
| 2522 |
\def\tikz@lib@graphs@quick@error#1{\tikzerror{Unexpected token '\string#1' in quick graph syntax}\tikz@lib@graphs@quick@main}% |
| 2523 |
\def\tikz@lib@graphs@quick@start@group{% |
| 2524 |
\pgfutil@ifnextchar[\tikz@lib@graphs@quick@start@group@{\tikzerror{Group |
| 2525 |
in quick graph syntax must start with options.}} |
| 2526 |
}% |
| 2527 |
|
| 2528 |
\def\tikz@lib@graphs@quick@start@group@[#1]{% |
| 2529 |
\begingroup% |
| 2530 |
\tikz@q@outerfalse% |
| 2531 |
\tikzgraphsset{#1}% |
| 2532 |
\tikz@lib@graphs@quick@main% |
| 2533 |
}% |
| 2534 |
\def\tikz@lib@graphs@quick@end@group{% |
| 2535 |
\iftikz@q@outer% |
| 2536 |
\endgroup% |
| 2537 |
% Ok, cleanup! |
| 2538 |
\pgfutil@loop% |
| 2539 |
\ifnum\tikz@qnode@count>0\relax% |
| 2540 |
\expandafter\global\expandafter\let\csname tikz@gr@q@@\csname tikz@gr@qn@@\the\tikz@qnode@count\endcsname\endcsname\relax% |
| 2541 |
\expandafter\global\expandafter\let\csname tikz@gr@qn@@\the\tikz@qnode@count\endcsname\relax% |
| 2542 |
\global\advance\tikz@qnode@count by-1\relax% |
| 2543 |
\pgfutil@repeat% |
| 2544 |
\expandafter\tikz@lib@graph@main@done% |
| 2545 |
\else% |
| 2546 |
\endgroup% |
| 2547 |
\expandafter\tikz@lib@graphs@end@group@% |
| 2548 |
\fi% |
| 2549 |
}% |
| 2550 |
\def\tikz@lib@graphs@end@group@{% |
| 2551 |
\pgfutil@ifnextchar;{\expandafter\tikz@lib@graphs@quick@main\pgfutil@gobble}{% |
| 2552 |
\pgfutil@ifnextchar,{\expandafter\tikz@lib@graphs@quick@main\pgfutil@gobble}{% |
| 2553 |
\tikzerror{Graph groups in quick syntax must be followed by a semicolon or a comma.}% |
| 2554 |
}% |
| 2555 |
}% |
| 2556 |
}% |
| 2557 |
|
| 2558 |
|
| 2559 |
\def\tikz@lib@graphs@quick@first@node{% |
| 2560 |
\let\tikz@quick@prev@node\relax% |
| 2561 |
\tikz@lib@graphs@quick@node% |
| 2562 |
}% |
| 2563 |
|
| 2564 |
\def\tikz@lib@graphs@quick@node#1"{% |
| 2565 |
\def\tikzgraphnodename{#1}% |
| 2566 |
\let\tikzgraphnodetext\tikzgraphnodename% |
| 2567 |
\iftikzgraphsautonumbernodes |
| 2568 |
\edef\tikzgraphnodename{\tikzgraphnodename\tikz@lib@auto@sep\the\tikz@lib@auto@number}% |
| 2569 |
\global\advance\tikz@lib@auto@number by1\relax% |
| 2570 |
\fi |
| 2571 |
\pgfutil@ifnextchar/\tikz@lib@graphs@quick@text\tikz@lib@graphs@quick@opt% |
| 2572 |
}% |
| 2573 |
\def\tikz@lib@graphs@quick@text/"#1"{% |
| 2574 |
\def\tikzgraphnodetext{#1}% |
| 2575 |
\tikz@lib@graphs@quick@opt% |
| 2576 |
}% |
| 2577 |
\def\tikz@lib@graphs@quick@opt{% |
| 2578 |
\pgfutil@ifnextchar[\tikz@lib@graphs@quick@withopt{\tikz@lib@graphs@quick@withopt[]}%] |
| 2579 |
}% |
| 2580 |
\def\tikz@lib@graphs@quick@withopt[#1]{% |
| 2581 |
% Test, whether node already exists |
| 2582 |
\expandafter\ifx\csname tikz@gr@q@@\tikzgraphnodename\endcsname\relax% |
| 2583 |
% New node |
| 2584 |
\global\advance\tikz@qnode@count by1\relax% |
| 2585 |
\expandafter\global\expandafter\let\csname tikz@gr@q@@\tikzgraphnodename\endcsname\pgfutil@empty% not relax |
| 2586 |
\expandafter\global\expandafter\let\csname tikz@gr@qn@@\the\tikz@qnode@count\endcsname\tikzgraphnodename% back pointer |
| 2587 |
\let\tikzgraphnodefullname\tikzgraphnodename% |
| 2588 |
\let\tikzgraphnodeas\tikzgraphnodeas@default% |
| 2589 |
\node [% |
| 2590 |
name=\tikzgraphnodename,% |
| 2591 |
graphs/redirect unknown to tikz, |
| 2592 |
/tikz/graphs/.cd,% |
| 2593 |
/tikz/graphs/@nodes styling,% |
| 2594 |
#1]% |
| 2595 |
{% |
| 2596 |
\tikzgraphnodeas% |
| 2597 |
};% |
| 2598 |
\else% |
| 2599 |
% |
| 2600 |
% Handle late options and operators |
| 2601 |
\tikzgdlatenodeoptionacallback{\tikzgraphnodename}% |
| 2602 |
\node also[graphs/redirect unknown to tikz,/tikz/graphs/.cd,#1](\tikzgraphnodename);% |
| 2603 |
\fi% |
| 2604 |
% Connect, if necessary |
| 2605 |
\tikz@lig@graph@quikc@make@edge@if@necessary% |
| 2606 |
\tikz@lib@graphs@quick@scan@after@node% |
| 2607 |
}% |
| 2608 |
|
| 2609 |
\def\tikz@lig@graph@quikc@make@edge@if@necessary{% |
| 2610 |
\ifx\tikz@quick@prev@node\relax% |
| 2611 |
\else% |
| 2612 |
\tikz@lib@graphs@quick@make@edge% |
| 2613 |
\fi% |
| 2614 |
}% |
| 2615 |
|
| 2616 |
\def\tikz@lib@graphs@quick@scan@after@node{% |
| 2617 |
\pgfutil@ifnextchar,\tikz@lib@graphs@quick@comma{% |
| 2618 |
\pgfutil@ifnextchar;\tikz@lib@graphs@quick@semi{% |
| 2619 |
\pgfutil@ifnextchar\egroup{\tikz@lib@graphs@quick@semi;}{% |
| 2620 |
\pgfutil@ifnextchar\par{\expandafter\tikz@lib@graphs@quick@scan@after@node\tikz@lib@graphs@quick@gobble@par}% |
| 2621 |
\tikz@lib@graphs@quick@connector}}}% |
| 2622 |
}% |
| 2623 |
\long\def\tikz@lib@graphs@quick@gobble@par#1{}% |
| 2624 |
|
| 2625 |
\def\tikz@lib@graphs@quick@comma,{\tikz@lib@graphs@quick@main}% |
| 2626 |
\def\tikz@lib@graphs@quick@semi;{\tikz@lib@graphs@quick@main}% |
| 2627 |
\def\tikz@lib@graphs@quick@connector#1#2{% |
| 2628 |
\def\tikz@lib@graphs@quick@edge@kind{#1#2}% |
| 2629 |
\pgfutil@ifnextchar>\tikz@lib@graphs@back@edge{% |
| 2630 |
\pgfutil@ifnextchar[\tikz@lib@graphs@quick@connector@handle@opt{\tikz@lib@graphs@quick@connector@handle@opt[]}%] |
| 2631 |
}% |
| 2632 |
}% |
| 2633 |
\def\tikz@lib@graphs@back@edge#1{% |
| 2634 |
\expandafter\def\expandafter\tikz@lib@graphs@quick@edge@kind\expandafter{\tikz@lib@graphs@quick@edge@kind#1}% |
| 2635 |
\pgfutil@ifnextchar[\tikz@lib@graphs@quick@connector@handle@opt{\tikz@lib@graphs@quick@connector@handle@opt[]}%] |
| 2636 |
}% |
| 2637 |
\def\tikz@lib@graphs@quick@connector@handle@opt[#1]{% |
| 2638 |
\def\tikz@lib@graphs@quick@edge@options{#1}% |
| 2639 |
\let\tikz@quick@prev@node\tikzgraphnodename% |
| 2640 |
\tikz@lib@graphs@quick@scan@after@connector% |
| 2641 |
}% |
| 2642 |
\def\tikz@lib@graphs@quick@scan@after@connector{% |
| 2643 |
\pgfutil@ifnextchar\par{\expandafter\tikz@lib@graphs@quick@scan@after@connector\tikz@lib@graphs@quick@gobble@par}{% |
| 2644 |
\pgfutil@ifnextchar"{\expandafter\tikz@lib@graphs@quick@node\pgfutil@gobble}{% |
| 2645 |
\tikzerror{Quotation marks expected after edge connector}% |
| 2646 |
}% |
| 2647 |
}% |
| 2648 |
}% |
| 2649 |
|
| 2650 |
\def\tikz@lib@graphs@quick@make@edge{% |
| 2651 |
{ |
| 2652 |
\expandafter\tikz@lib@graphs@quick@make@edge@styling\expandafter{\tikz@lib@graphs@quick@edge@options}% |
| 2653 |
\expandafter\expandafter\expandafter\tikz@lib@graphs@quick@make@edge@for% |
| 2654 |
\expandafter\expandafter\expandafter{\expandafter\tikz@quick@prev@node\expandafter}\expandafter{\tikzgraphnodename}% |
| 2655 |
} |
| 2656 |
}% |
| 2657 |
|
| 2658 |
\def\tikz@lib@graphs@quick@make@edge@styling#1{% |
| 2659 |
\tikz@enable@edge@quotes% |
| 2660 |
\tikzgraphsset{.unknown/.code=\tikz@lib@graph@unknown@edge@option{##1},#1}% |
| 2661 |
}% |
| 2662 |
|
| 2663 |
\def\tikz@lib@graphs@quick@make@edge@for#1#2{% |
| 2664 |
\pgfkeysgetvalue{/tikz/graphs/@edges styling}\pgf@tempa |
| 2665 |
\pgfkeysgetvalue{/tikz/graphs/@edges node}\pgf@temp@b |
| 2666 |
\expandafter\expandafter\expandafter\tikz@lib@graphs@quick@make@edge@for@with% |
| 2667 |
\expandafter\expandafter\expandafter{\expandafter\pgf@tempa\expandafter}\expandafter{\pgf@temp@b}{#1}{#2}% |
| 2668 |
}% |
| 2669 |
|
| 2670 |
\def\tikz@lib@graphs@quick@make@edge@for@with#1#2#3#4{% |
| 2671 |
\tikzgraphsset{new \tikz@lib@graphs@quick@edge@kind={#3}{#4}{#1}{#2}}% |
| 2672 |
}% |
| 2673 |
|
| 2674 |
\endinput |