| 1 |
% tkz-graph.sty v2.0 |
| 2 |
% Copyright 2021 Alain Matthes |
| 3 |
% This work may be distributed and/or modified under the |
| 4 |
% conditions of the LaTeX Project Public License, either version 1.3 |
| 5 |
% of this license or (at your option) any later version. |
| 6 |
% The latest version of this license is in |
| 7 |
% http://www.latex-project.org/lppl.txt |
| 8 |
% and version 1.3 or later is part of all distributions of LaTeX |
| 9 |
% version 2005/12/01 or later. |
| 10 |
% |
| 11 |
% This work has the LPPL maintenance status “maintained”. |
| 12 |
% |
| 13 |
% The Current Maintainer of this work is Alain Matthes. |
| 14 |
|
| 15 |
%<---------------------------------------------------------------------------> |
| 16 |
% Objet : Création de graphes |
| 17 |
%<---------------------------------------------------------------------------> |
| 18 |
\def\fileversion{2.00} |
| 19 |
\def\filedate{2021/01/20} |
| 20 |
\typeout{2021/01/20 v 2.00 tkz-graph.sty} |
| 21 |
\NeedsTeXFormat{LaTeX2e} |
| 22 |
\ProvidesPackage{tkz-graph}[2021/01/20 2.00 base for graphs] |
| 23 |
%<---------------------------------------------------------------------------> |
| 24 |
|
| 25 |
\ifx\e@alloc\@undefined |
| 26 |
\RequirePackage{etex} |
| 27 |
\fi |
| 28 |
\RequirePackage{ifthen} |
| 29 |
\RequirePackage{xkeyval} |
| 30 |
\RequirePackage{tikz} |
| 31 |
\usetikzlibrary{arrows} |
| 32 |
%<---------------------------------------------------------------------------> |
| 33 |
% todo remove some counters |
| 34 |
\newcounter{tkz@gr@a} |
| 35 |
\newcounter{tkz@gr@b} |
| 36 |
\newcounter{tkz@gr@c} |
| 37 |
\newcounter{tkz@gr@e} |
| 38 |
\newcounter{tkz@gr@d} |
| 39 |
\newcounter{tkz@gr@p} |
| 40 |
\newcounter{tkz@gr@i} |
| 41 |
\newcounter{tkz@gr@n} |
| 42 |
\newcounter{tkz@gr@ta} |
| 43 |
\newcounter{tkz@gr@tb} |
| 44 |
%<---------------------------------------------------------------------------> |
| 45 |
% Init vertex |
| 46 |
%<---------------------------------------------------------------------------> |
| 47 |
%<---------------------------------------------------------------------------> |
| 48 |
\def\tkz@gr@background@color{white} |
| 49 |
\def\tkz@gr@text@color{black} |
| 50 |
\global\edef\tkz@suc@bkc{\tkz@gr@background@color} |
| 51 |
\global\edef\tkz@suc@txt{\tkz@gr@text@color} |
| 52 |
\pgfkeys{ |
| 53 |
/tkzsupcol/.cd, |
| 54 |
background/.code = {\global\edef\tkz@suc@bkc{#1}}, |
| 55 |
text/.code = {\global\edef\tkz@suc@txt{#1}}, |
| 56 |
} |
| 57 |
\def\tkzSetUpColors{\pgfutil@ifnextchar[{\tkz@SetUpColors}{\tkz@SetUpColors[]}} |
| 58 |
\def\tkz@SetUpColors[#1]{% |
| 59 |
\begingroup |
| 60 |
\pgfkeys{% |
| 61 |
/tkzsupcol/.cd, |
| 62 |
background = \tkz@gr@background@color, |
| 63 |
text = \tkz@gr@text@color |
| 64 |
} |
| 65 |
\pgfqkeys{/tkzsupcol}{#1} |
| 66 |
\pagecolor{\tkz@suc@bkc} |
| 67 |
\color{\tkz@suc@txt} |
| 68 |
\endgroup |
| 69 |
} |
| 70 |
|
| 71 |
\newcommand*{\GraphUnit}{1} |
| 72 |
\newcommand*{\VertexInnerSep}{2pt} |
| 73 |
\newcommand*{\VertexOuterSep}{0pt} |
| 74 |
\newcommand*{\VertexDistance}{3cm} |
| 75 |
\newcommand*{\VertexShape}{circle} |
| 76 |
\newcommand*{\VertexLineWidth}{0.5pt} |
| 77 |
\newcommand*{\VertexLineColor}{\tkz@suc@txt} |
| 78 |
\newcommand*{\VertexLightFillColor}{\tkz@suc@bkc} |
| 79 |
\newcommand*{\VertexDarkFillColor}{\tkz@suc@txt} |
| 80 |
\newcommand*{\VertexTextColor}{\tkz@suc@txt} |
| 81 |
\newcommand*{\VertexFillColor}{\tkz@suc@txt} |
| 82 |
\newcommand*{\VertexBallColor}{orange} |
| 83 |
\newcommand*{\VertexBigMinSize}{24pt} |
| 84 |
\newcommand*{\VertexInterMinSize}{18pt} |
| 85 |
\newcommand*{\VertexSmallMinSize}{12pt} |
| 86 |
\newcommand*{\EdgeFillColor}{orange} |
| 87 |
\newcommand*{\EdgeArtColor}{orange} |
| 88 |
\newcommand*{\EdgeColor}{\tkz@suc@txt} |
| 89 |
\newcommand*{\EdgeDoubleDistance}{1pt} |
| 90 |
\newcommand*{\EdgeLineWidth}{0.8pt} |
| 91 |
\newcommand*{\LabelTextColor}{\tkz@suc@txt} |
| 92 |
\newcommand*{\LabelFillColor}{\tkz@suc@bkc} |
| 93 |
|
| 94 |
\tikzset{pre/.style={<-,shorten <=1pt,>=stealth',semithick}} |
| 95 |
\tikzset{post/.style={->,shorten <=1pt,>=stealth',semithick}} |
| 96 |
%<---------------------------------------------------------------------------> |
| 97 |
% Simple Vertex |
| 98 |
%<---------------------------------------------------------------------------> |
| 99 |
\define@cmdkey [GR] {SVS} {Shape}{} |
| 100 |
\define@cmdkey [GR] {SVS} {MinSize}{} |
| 101 |
\define@cmdkey [GR] {SVS} {LineWidth}{} |
| 102 |
\define@cmdkey [GR] {SVS} {LineColor}{} |
| 103 |
\define@cmdkey [GR] {SVS} {FillColor}{} |
| 104 |
\define@cmdkey [GR] {SVS} {InnerSep}{} |
| 105 |
\define@cmdkey [GR] {SVS} {OuterSep}{} |
| 106 |
\presetkeys [GR] {SVS} {Shape = \VertexShape, |
| 107 |
MinSize = \VertexSmallMinSize, |
| 108 |
LineWidth = \VertexLineWidth, |
| 109 |
LineColor = \VertexLineColor, |
| 110 |
InnerSep = \VertexInnerSep, |
| 111 |
OuterSep = \VertexOuterSep, |
| 112 |
FillColor = \VertexFillColor}{} |
| 113 |
\newcommand*{\SetVertexSimple}[1][]{\GR@SetVertexSimple[#1]}% |
| 114 |
\def\GR@SetVertexSimple[#1]{% |
| 115 |
\setkeys[GR]{SVS}{#1}% |
| 116 |
\presetkeys[GR]{vertex}{NoLabel = true}{}% |
| 117 |
\tikzset{VertexStyle/.style = {draw, |
| 118 |
shape = \cmdGR@SVS@Shape, |
| 119 |
color = \cmdGR@SVS@LineColor, |
| 120 |
fill = \cmdGR@SVS@FillColor, |
| 121 |
inner sep = \cmdGR@SVS@InnerSep, |
| 122 |
outer sep = \cmdGR@SVS@OuterSep, |
| 123 |
minimum size = \cmdGR@SVS@MinSize, |
| 124 |
line width = \cmdGR@SVS@LineWidth}} |
| 125 |
\tikzset{EdgeStyle/.style = {line width = \EdgeLineWidth, |
| 126 |
\EdgeColor}} |
| 127 |
\tikzset{LabelStyle/.style={}}} |
| 128 |
%<---------------------------------------------------------------------------> |
| 129 |
% Shade Vertex |
| 130 |
%<---------------------------------------------------------------------------> |
| 131 |
\define@cmdkey [GR] {shade} {Shape}{} |
| 132 |
\define@cmdkey [GR] {shade} {MinSize}{} |
| 133 |
\define@cmdkey [GR] {shade} {LineWidth}{} |
| 134 |
\define@cmdkey [GR] {shade} {LineColor}{} |
| 135 |
\define@cmdkey [GR] {shade} {BallColor}{} |
| 136 |
\define@cmdkey [GR] {shade} {InnerSep}{} |
| 137 |
\define@cmdkey [GR] {shade} {OuterSep}{} |
| 138 |
\presetkeys [GR] {shade} {Shape = \VertexShape, |
| 139 |
MinSize = \VertexBigMinSize, |
| 140 |
LineWidth = \VertexLineWidth, |
| 141 |
LineColor = \VertexLineColor, |
| 142 |
InnerSep = \VertexInnerSep, |
| 143 |
OuterSep = \VertexOuterSep, |
| 144 |
BallColor = \VertexBallColor}{} |
| 145 |
\newcommand*{\SetVertexShade}[1][]{\GR@SetVertexShade[#1]}% |
| 146 |
\def\GR@SetVertexShade[#1]{% |
| 147 |
\setkeys[GR]{shade}{#1}% |
| 148 |
\presetkeys[GR]{vertex}{NoLabel = false}{}% |
| 149 |
\tikzset{VertexStyle/.style = {draw, |
| 150 |
shape = \cmdGR@shade@Shape, |
| 151 |
ball color = \cmdGR@shade@BallColor, |
| 152 |
inner sep = \cmdGR@shade@InnerSep, |
| 153 |
outer sep = \cmdGR@shade@OuterSep, |
| 154 |
minimum size = \cmdGR@shade@MinSize, |
| 155 |
line width = \VertexLineWidth}} |
| 156 |
\tikzset{EdgeStyle/.style = {line width = \EdgeLineWidth, |
| 157 |
\EdgeColor,% color outside |
| 158 |
double = \EdgeFillColor,% inside |
| 159 |
double distance = \EdgeDoubleDistance}}% |
| 160 |
\tikzset{LabelStyle/.style={}}} |
| 161 |
%<---------------------------------------------------------------------------> |
| 162 |
% Art Vertex |
| 163 |
%<---------------------------------------------------------------------------> |
| 164 |
\define@cmdkey [GR] {art} {Shape}{} |
| 165 |
\define@cmdkey [GR] {art} {MinSize}{} |
| 166 |
\define@cmdkey [GR] {art} {LineWidth}{} |
| 167 |
\define@cmdkey [GR] {art} {LineColor}{} |
| 168 |
\define@cmdkey [GR] {art} {BallColor}{} |
| 169 |
\define@cmdkey [GR] {art} {InnerSep}{} |
| 170 |
\define@cmdkey [GR] {art} {OuterSep}{} |
| 171 |
\presetkeys [GR] {art} {Shape = \VertexShape, |
| 172 |
MinSize = \VertexSmallMinSize, |
| 173 |
LineWidth = \VertexLineWidth, |
| 174 |
LineColor = \VertexLineColor, |
| 175 |
InnerSep = \VertexInnerSep, |
| 176 |
OuterSep = \VertexOuterSep, |
| 177 |
BallColor = \VertexBallColor}{} |
| 178 |
\newcommand*{\SetVertexArt}[1][]{\GR@SetVertexArt[#1]}% |
| 179 |
\def\GR@SetVertexArt[#1]{% |
| 180 |
\setkeys[GR]{art}{#1}% |
| 181 |
\presetkeys[GR]{vertex}{NoLabel = true}{}% |
| 182 |
\tikzset{VertexStyle/.style = {draw, |
| 183 |
shape = \cmdGR@art@Shape, |
| 184 |
ball color = \cmdGR@art@BallColor, |
| 185 |
inner sep = \cmdGR@art@InnerSep, |
| 186 |
outer sep = \cmdGR@art@OuterSep, |
| 187 |
minimum size = \cmdGR@art@MinSize, |
| 188 |
line width = \VertexLineWidth}} |
| 189 |
\tikzset{EdgeStyle/.style = {line width = \EdgeLineWidth, |
| 190 |
\EdgeArtColor}} |
| 191 |
\tikzset{LabelStyle/.style = {}}} |
| 192 |
%<---------------------------------------------------------------------------> |
| 193 |
% Normal Vertex |
| 194 |
%<---------------------------------------------------------------------------> |
| 195 |
\define@cmdkey [GR] {SVN} {Shape}{} |
| 196 |
\define@cmdkey [GR] {SVN} {MinSize}{} |
| 197 |
\define@cmdkey [GR] {SVN} {LineWidth}{} |
| 198 |
\define@cmdkey [GR] {SVN} {LineColor}{} |
| 199 |
\define@cmdkey [GR] {SVN} {FillColor}{} |
| 200 |
\define@cmdkey [GR] {SVN} {TextColor}{} |
| 201 |
\define@cmdkey [GR] {SVN} {InnerSep}{} |
| 202 |
\define@cmdkey [GR] {SVN} {OuterSep}{} |
| 203 |
\presetkeys [GR] {SVN} {Shape = \VertexShape, |
| 204 |
MinSize = \VertexInterMinSize, |
| 205 |
LineWidth = \VertexLineWidth, |
| 206 |
LineColor = \VertexLineColor, |
| 207 |
FillColor = \VertexLightFillColor, |
| 208 |
InnerSep = \VertexInnerSep, |
| 209 |
OuterSep = \VertexOuterSep, |
| 210 |
TextColor = \VertexTextColor}{} |
| 211 |
\newcommand*{\SetVertexNormal}[1][]{\GR@SetVertexNormal[#1]}% |
| 212 |
\def\GR@SetVertexNormal[#1]{% |
| 213 |
\setkeys[GR]{SVN}{#1}% |
| 214 |
\tikzset{VertexStyle/.style = {shape = \cmdGR@SVN@Shape, |
| 215 |
minimum size = \cmdGR@SVN@MinSize, |
| 216 |
line width = \cmdGR@SVN@LineWidth, |
| 217 |
color = \cmdGR@SVN@LineColor, |
| 218 |
fill = \cmdGR@SVN@FillColor, |
| 219 |
text = \cmdGR@SVN@TextColor, |
| 220 |
inner sep = \cmdGR@SVN@InnerSep, |
| 221 |
outer sep = \cmdGR@SVN@OuterSep, |
| 222 |
draw}} |
| 223 |
\tikzset{EdgeStyle/.style = {line width = \EdgeLineWidth, |
| 224 |
\EdgeColor}} |
| 225 |
\tikzset{LabelStyle/.style={}}} |
| 226 |
\SetVertexNormal% default |
| 227 |
%<---------------------------------------------------------------------------> |
| 228 |
\define@cmdkey [GR] {init} {unit}{} |
| 229 |
\define@choicekey*[GR]{init}{vstyle}[\val\nr]{Empty,% |
| 230 |
Hasse,% |
| 231 |
Simple,% |
| 232 |
Classic,% |
| 233 |
Normal,% |
| 234 |
Shade,% |
| 235 |
Dijkstra,% |
| 236 |
Welsh,% |
| 237 |
Art,% |
| 238 |
Shade Art}{% |
| 239 |
\edef\GR@init@vstyle{\nr} |
| 240 |
\ifcase\nr\relax |
| 241 |
% Empty |
| 242 |
\presetkeys [GR] {vertex} {LabelOut = false}{}% |
| 243 |
\tikzset{VertexStyle/.style = {shape = \VertexShape, |
| 244 |
color = \VertexLineColor, |
| 245 |
fill = \VertexLightFillColor, |
| 246 |
inner sep = \VertexInnerSep, |
| 247 |
outer sep = 0.5\pgflinewidth, |
| 248 |
text = \VertexTextColor, |
| 249 |
minimum size = \VertexSmallMinSize, |
| 250 |
line width = \VertexLineWidth}} |
| 251 |
\tikzset{EdgeStyle/.style = {line width = \EdgeLineWidth,\EdgeColor}} |
| 252 |
\tikzset{LabelStyle/.style={}} |
| 253 |
\or |
| 254 |
% Hasse |
| 255 |
\presetkeys [GR] {vertex} {NoLabel = true}{}% |
| 256 |
\tikzset{VertexStyle/.style = {draw, |
| 257 |
shape = \VertexShape, |
| 258 |
color = \VertexLineColor, |
| 259 |
fill = \VertexLightFillColor, |
| 260 |
inner sep = \VertexInnerSep, |
| 261 |
outer sep = 0.5\pgflinewidth, |
| 262 |
text = \VertexTextColor, |
| 263 |
minimum size = \VertexSmallMinSize, |
| 264 |
line width = \VertexLineWidth}} |
| 265 |
\tikzset{EdgeStyle/.style = {line width = \EdgeLineWidth, |
| 266 |
\EdgeColor}} |
| 267 |
\tikzset{LabelStyle/.style={}} |
| 268 |
\or |
| 269 |
% Simple |
| 270 |
\presetkeys [GR] {vertex} {NoLabel = true}{}% |
| 271 |
\tikzset{VertexStyle/.style = {draw, |
| 272 |
shape = \VertexShape, |
| 273 |
color = \VertexLineColor, |
| 274 |
fill = \VertexDarkFillColor, |
| 275 |
inner sep = \VertexInnerSep, |
| 276 |
outer sep = 0.5\pgflinewidth, |
| 277 |
text = \VertexTextColor, |
| 278 |
minimum size = \VertexSmallMinSize, |
| 279 |
line width = \VertexLineWidth}} |
| 280 |
\tikzset{EdgeStyle/.style = {line width = \EdgeLineWidth, |
| 281 |
\EdgeColor}} |
| 282 |
\tikzset{LabelStyle/.style={}} |
| 283 |
% Classic |
| 284 |
\or |
| 285 |
\presetkeys [GR] {vertex} {LabelOut = true}{}% |
| 286 |
\tikzset{VertexStyle/.style = {draw, |
| 287 |
shape = \VertexShape, |
| 288 |
color = \VertexLineColor, |
| 289 |
fill = \VertexDarkFillColor, |
| 290 |
inner sep = \VertexInnerSep, |
| 291 |
outer sep = 0.5\pgflinewidth, |
| 292 |
text = \VertexTextColor, |
| 293 |
minimum size = \VertexSmallMinSize, |
| 294 |
line width = \VertexLineWidth}} |
| 295 |
\tikzset{EdgeStyle/.style = {line width = \EdgeLineWidth, |
| 296 |
\EdgeColor}} |
| 297 |
\tikzset{LabelStyle/.style={}} |
| 298 |
% Normal |
| 299 |
\or |
| 300 |
\presetkeys [GR] {vertex} {LabelOut = false}{}% |
| 301 |
\tikzset{VertexStyle/.style = {draw, |
| 302 |
shape = \VertexShape, |
| 303 |
minimum size = \VertexInterMinSize, |
| 304 |
line width = \VertexLineWidth, |
| 305 |
color = \VertexLineColor, |
| 306 |
outer sep = 0.5\pgflinewidth, |
| 307 |
fill = \VertexLightFillColor, |
| 308 |
text = \VertexTextColor, |
| 309 |
line width = \VertexLineWidth}} |
| 310 |
\tikzset{EdgeStyle/.style = {line width = \EdgeLineWidth, |
| 311 |
\EdgeColor}} |
| 312 |
\tikzset{LabelStyle/.style={}} |
| 313 |
% Shade |
| 314 |
\or |
| 315 |
\presetkeys [GR] {vertex} {LabelOut = false}{}% |
| 316 |
\tikzset{VertexStyle/.style = {draw, |
| 317 |
shape = \VertexShape, |
| 318 |
ball color = \VertexBallColor, |
| 319 |
color = \VertexLineColor, |
| 320 |
text = \VertexTextColor, |
| 321 |
inner sep = \VertexInnerSep, |
| 322 |
outer sep = \VertexOuterSep, |
| 323 |
minimum size = \VertexBigMinSize, |
| 324 |
line width = \VertexLineWidth}} |
| 325 |
\tikzset{EdgeStyle/.style = {line width = \EdgeLineWidth, |
| 326 |
\EdgeColor,% color outside |
| 327 |
double = \EdgeFillColor,% inside |
| 328 |
double distance = \EdgeDoubleDistance}}% |
| 329 |
\tikzset{LabelStyle/.style={}} |
| 330 |
% Dijkstra |
| 331 |
\or |
| 332 |
\presetkeys [GR] {vertex} {LabelOut = false}{}% |
| 333 |
\tikzset{VertexStyle/.style = {draw, |
| 334 |
shape = \VertexShape, |
| 335 |
color = \VertexLineColor, |
| 336 |
fill = \VertexLightFillColor, |
| 337 |
inner sep = \VertexInnerSep, |
| 338 |
outer sep = 0.5\pgflinewidth, |
| 339 |
text = \VertexTextColor, |
| 340 |
minimum size = \VertexInterMinSize, |
| 341 |
line width = \VertexLineWidth}} |
| 342 |
\tikzset{EdgeStyle/.style = {line width = \EdgeLineWidth, |
| 343 |
\EdgeColor}} |
| 344 |
\tikzset{LabelStyle/.style={}} |
| 345 |
% Welsh |
| 346 |
\or |
| 347 |
\presetkeys [GR] {vertex} {LabelOut = true}{}% |
| 348 |
\tikzset{VertexStyle/.style = {draw, |
| 349 |
shape = \VertexShape, |
| 350 |
color = \VertexLineColor, |
| 351 |
fill = \VertexLightFillColor, |
| 352 |
inner sep = \VertexInnerSep, |
| 353 |
outer sep = \VertexOuterSep, |
| 354 |
text = \VertexTextColor, |
| 355 |
minimum size = \VertexSmallMinSize, |
| 356 |
line width = \VertexLineWidth}} |
| 357 |
\tikzset{EdgeStyle/.style = {line width = \EdgeLineWidth, |
| 358 |
\EdgeColor}}% |
| 359 |
\tikzset{LabelStyle/.style={}} |
| 360 |
% Art |
| 361 |
\or |
| 362 |
\presetkeys [GR] {vertex} {NoLabel = true}{}% |
| 363 |
\tikzset{VertexStyle/.style = {shape = \VertexShape, |
| 364 |
ball color = \VertexBallColor, |
| 365 |
color = \VertexLineColor, |
| 366 |
inner sep = \VertexInnerSep, |
| 367 |
outer sep = \VertexOuterSep, |
| 368 |
minimum size = \VertexSmallMinSize, |
| 369 |
line width = \VertexLineWidth}}% |
| 370 |
\tikzset{EdgeStyle/.style = {line width = \EdgeLineWidth, |
| 371 |
\EdgeArtColor}} |
| 372 |
\tikzset{LabelStyle/.style = {}} |
| 373 |
% ShadeArt |
| 374 |
\or |
| 375 |
\presetkeys [GR] {vertex} {NoLabel = true}{}% |
| 376 |
\tikzset{VertexStyle/.style = {shape = \VertexShape, |
| 377 |
ball color = \VertexBallColor, |
| 378 |
inner sep = \VertexInnerSep, |
| 379 |
outer sep = \VertexOuterSep, |
| 380 |
minimum size = \VertexSmallMinSize, |
| 381 |
line width = \VertexLineWidth}} |
| 382 |
\tikzset{EdgeStyle/.style = {line width = \EdgeLineWidth, |
| 383 |
\EdgeColor, |
| 384 |
double = \EdgeFillColor, |
| 385 |
double distance = .5\EdgeDoubleDistance}} |
| 386 |
\tikzset{LabelStyle/.style = {}} |
| 387 |
\fi% |
| 388 |
} |
| 389 |
|
| 390 |
\presetkeys [GR] {init} {vstyle = Normal,% |
| 391 |
unit = \GraphUnit}{} |
| 392 |
|
| 393 |
\newcommand*{\SetGraphUnit}[1]{\renewcommand{\GraphUnit}{#1}}% |
| 394 |
|
| 395 |
\newcommand*{\GraphInit}[1][]{\setkeys[GR]{init}{#1}% |
| 396 |
\edef\GraphUnit{\cmdGR@init@unit}% |
| 397 |
}% |
| 398 |
%<---------------------------------------------------------------------------> |
| 399 |
% Colors |
| 400 |
%<---------------------------------------------------------------------------> |
| 401 |
\newcommand*{\SetGraphShadeColor}[3]{% |
| 402 |
\tikzset{VertexStyle/.append style = {ball color=#1}} |
| 403 |
\tikzset{EdgeStyle/.append style = {color=#2,double=#3}} |
| 404 |
} |
| 405 |
\newcommand*{\SetGraphArtColor}[2]{% |
| 406 |
\tikzset{VertexStyle/.append style = {ball color=#1}} |
| 407 |
\tikzset{EdgeStyle/.append style = {color=#2}} |
| 408 |
} |
| 409 |
\newcommand*{\SetGraphColor}[2]{% |
| 410 |
\tikzset{VertexStyle/.append style = {fill=#1}} |
| 411 |
\tikzset{EdgeStyle/.append style = {color=#2}} |
| 412 |
} |
| 413 |
\newcommand*{\AddVertexColor}[2]{% |
| 414 |
\begingroup |
| 415 |
\tikzset{VertexStyle/.append style = {fill=#1}} |
| 416 |
\foreach \v in {#2} |
| 417 |
{\Vertex[Node,NoLabel]{\v}} |
| 418 |
\endgroup |
| 419 |
} |
| 420 |
%<---------------------------------------------------------------------------> |
| 421 |
\newcommand*{\SetVertexNoLabel}{% |
| 422 |
\presetkeys [GR] {vertex} {NoLabel = true}{}% |
| 423 |
} |
| 424 |
% add RV |
| 425 |
\newcommand*{\SetVertexLabel}{% |
| 426 |
\presetkeys [GR] {vertex} {NoLabel = false}{}% |
| 427 |
} |
| 428 |
%<---------------------------------------------------------------------------> |
| 429 |
\newcommand*{\SetVertexLabelOut}{% |
| 430 |
\presetkeys [GR] {vertex} {LabelOut = true}{}% |
| 431 |
} |
| 432 |
\newcommand*{\SetVertexLabelIn}{% |
| 433 |
\presetkeys [GR] {vertex} {LabelOut = false}{}% |
| 434 |
} |
| 435 |
\newcommand*{\SetVertexMath}{% |
| 436 |
\presetkeys [GR] {vertex} {Math = true}{}% |
| 437 |
\presetkeys [GR] {cl} {Math = true}{}% |
| 438 |
} |
| 439 |
\newcommand*{\SetVertexNoMath}{% |
| 440 |
\presetkeys [GR] {vertex} {Math = false}{}% |
| 441 |
\presetkeys [GR] {cl} {Math = false}{}% |
| 442 |
} |
| 443 |
%<---------------------------------------------------------------------------> |
| 444 |
% Init SetUpVertex |
| 445 |
%<---------------------------------------------------------------------------> |
| 446 |
\define@cmdkey [GR] {SUV} {Lpos}{} |
| 447 |
\define@cmdkey [GR] {SUV} {Ldist}{} |
| 448 |
\define@cmdkey [GR] {SUV} {Style}{} |
| 449 |
\define@cmdkey [GR] {SUV} {MinSize}{} |
| 450 |
\define@cmdkey [GR] {SUV} {LineWidth}{} |
| 451 |
\define@cmdkey [GR] {SUV} {TextColor}{} |
| 452 |
\define@cmdkey [GR] {SUV} {LineColor}{} |
| 453 |
\define@cmdkey [GR] {SUV} {FillColor}{} |
| 454 |
\define@cmdkey [GR] {SUV} {InnerSep}{} |
| 455 |
\define@cmdkey [GR] {SUV} {OuterSep}{} |
| 456 |
\define@cmdkey [GR] {SUV} {Unit}{} |
| 457 |
\define@boolkey [GR] {SUV} {NoLabel} [true]{} |
| 458 |
\define@boolkey [GR] {SUV} {LabelOut}[true]{} |
| 459 |
\define@boolkey [GR] {SUV} {Math}[true]{} |
| 460 |
\presetkeys [GR] {SUV} {Ldist = 0cm, |
| 461 |
Lpos = 0, |
| 462 |
Style = {}, |
| 463 |
LabelOut = false, |
| 464 |
NoLabel = false, |
| 465 |
Math = false, |
| 466 |
Unit = \GraphUnit, |
| 467 |
MinSize = \VertexInterMinSize, |
| 468 |
TextColor = \VertexTextColor, |
| 469 |
LineColor = \VertexLineColor, |
| 470 |
FillColor = \VertexLightFillColor, |
| 471 |
LineWidth = \VertexLineWidth, |
| 472 |
InnerSep = \VertexInnerSep, |
| 473 |
OuterSep = \VertexOuterSep}{} |
| 474 |
%<---------------------------------------------------------------------------> |
| 475 |
% SetUpVertex |
| 476 |
%<---------------------------------------------------------------------------> |
| 477 |
\newcommand*{\SetUpVertex}[1][]{\GR@SetUpVertex[#1]}% |
| 478 |
\def\GR@SetUpVertex[#1]{% |
| 479 |
\setkeys[GR]{SUV}{#1}% |
| 480 |
\presetkeys [GR] {vertex} {Lpos = \cmdGR@SUV@Lpos, |
| 481 |
Ldist = \cmdGR@SUV@Ldist, |
| 482 |
style = \cmdGR@SUV@Style, |
| 483 |
unit = \cmdGR@SUV@Unit}{}% |
| 484 |
\tikzset{VertexStyle/.append style = {inner sep = \cmdGR@SUV@InnerSep, |
| 485 |
outer sep = \cmdGR@SUV@OuterSep, |
| 486 |
minimum size = \cmdGR@SUV@MinSize, |
| 487 |
text = \cmdGR@SUV@TextColor, |
| 488 |
color = \cmdGR@SUV@LineColor, |
| 489 |
fill = \cmdGR@SUV@FillColor, |
| 490 |
line width = \cmdGR@SUV@LineWidth}} |
| 491 |
\ifGR@SUV@NoLabel% |
| 492 |
\presetkeys [GR] {vertex} {NoLabel = true}{}% |
| 493 |
\fi% |
| 494 |
\ifGR@SUV@LabelOut% |
| 495 |
\presetkeys [GR] {vertex} {LabelOut = true}{}% |
| 496 |
\fi% |
| 497 |
\ifGR@SUV@Math% |
| 498 |
\presetkeys [GR] {vertex} {Math = true}{}% |
| 499 |
\fi% |
| 500 |
} |
| 501 |
%<---------------------------------------------------------------------------> |
| 502 |
% Init Vertex |
| 503 |
%<---------------------------------------------------------------------------> |
| 504 |
\define@boolkey [GR] {vertex} {empty}[true]{} |
| 505 |
\define@cmdkey [GR] {vertex} {unit}{} |
| 506 |
\define@cmdkey [GR] {vertex} {x}{} |
| 507 |
\define@cmdkey [GR] {vertex} {y}{} |
| 508 |
\define@cmdkey [GR] {vertex} {a}{} |
| 509 |
\define@cmdkey [GR] {vertex} {d}{} |
| 510 |
\define@boolkey [GR] {vertex} {Node}[true]{} |
| 511 |
\define@cmdkey [GR] {vertex} {dir}{} |
| 512 |
\define@cmdkey [GR] {vertex} {style}{} |
| 513 |
\define@cmdkey [GR] {vertex} {position}{} |
| 514 |
\define@cmdkey [GR] {vertex} {L}{} |
| 515 |
\define@cmdkey [GR] {vertex} {Lpos}{} |
| 516 |
\define@cmdkey [GR] {vertex} {Ldist}{} |
| 517 |
\define@boolkey [GR] {vertex} {NoLabel}[true]{} |
| 518 |
\define@boolkey [GR] {vertex} {Math}[true]{} |
| 519 |
\define@boolkey [GR] {vertex} {LabelOut}[true]{} |
| 520 |
\presetkeys [GR] {vertex} {Node = false, |
| 521 |
NoLabel = false, |
| 522 |
LabelOut = false, |
| 523 |
empty = false, |
| 524 |
Math = false, |
| 525 |
x = {}, |
| 526 |
y = {}, |
| 527 |
a = {}, |
| 528 |
d = {}, |
| 529 |
unit = \GraphUnit, |
| 530 |
dir = \EA, |
| 531 |
position = {}, |
| 532 |
style = {}, |
| 533 |
L = {}, |
| 534 |
Ldist = 0cm, |
| 535 |
Lpos = 0}{} |
| 536 |
%<---------------------------------------------------------------------------> |
| 537 |
% Vertex |
| 538 |
%<---------------------------------------------------------------------------> |
| 539 |
\newcommand*{\Vertex}[1][]{\@vertex[#1]}% |
| 540 |
\def\@vertex[#1]#2{% |
| 541 |
\setkeys[GR]{vertex}{#1}% |
| 542 |
\@@vertex{#2}% |
| 543 |
} |
| 544 |
% coord rect todo coord polar and pos relative |
| 545 |
\def\@@vertex#1{% |
| 546 |
\def\nstyle{VertexStyle} |
| 547 |
%<---------------------------------------------------------------------------> |
| 548 |
\ifGR@vertex@Node% |
| 549 |
\pgfextractx{\pgf@x}{\pgfpointanchor{#1}{center}} |
| 550 |
\pgfextracty{\pgf@y}{\pgfpointanchor{#1}{center}} |
| 551 |
\edef\cmdGR@vertex@x{\pgf@x} |
| 552 |
\edef\cmdGR@vertex@y{\pgf@y} |
| 553 |
\fi% |
| 554 |
%<---------------------------------------------------------------------------> |
| 555 |
\ifGR@vertex@empty% |
| 556 |
\begin{scope} |
| 557 |
\ifthenelse{\not\equal{\cmdGR@vertex@x}{}}{% |
| 558 |
\protected@edef\@tempa{% |
| 559 |
\noexpand\node[inner sep = 0pt](#1)% |
| 560 |
at (\cmdGR@vertex@x,\cmdGR@vertex@y){}}% |
| 561 |
\@tempa;}{% |
| 562 |
\ifthenelse{\not\equal{\cmdGR@vertex@d}{}}{% |
| 563 |
\protected@edef\@tempa{% |
| 564 |
\noexpand\node[inner sep = 0pt](#1)% |
| 565 |
at (\cmdGR@vertex@a:\cmdGR@vertex@d){}}% |
| 566 |
\@tempa;}{% |
| 567 |
\protected@edef\@tempa{% |
| 568 |
\noexpand \node[inner sep = 0pt](#1)% |
| 569 |
[\cmdGR@vertex@position]{}}% |
| 570 |
\@tempa;}}% |
| 571 |
\end{scope} |
| 572 |
\else |
| 573 |
\begin{scope}[label distance = \cmdGR@vertex@Ldist] |
| 574 |
\ifGR@vertex@NoLabel |
| 575 |
\def\vertex@Label{}% |
| 576 |
\def\cmdGR@vertex@L{}% |
| 577 |
\def\vertex@Name{} |
| 578 |
\else% |
| 579 |
\ifGR@vertex@Math |
| 580 |
\ifthenelse{\equal{\cmdGR@vertex@L}{}}{% |
| 581 |
\def\vertex@Name{$#1$}}{\def\vertex@Name{$\cmdGR@vertex@L$}} |
| 582 |
\else |
| 583 |
\ifthenelse{\equal{\cmdGR@vertex@L}{}}{% |
| 584 |
\def\vertex@Name{#1}}{\def\vertex@Name{\cmdGR@vertex@L}} |
| 585 |
\fi% |
| 586 |
\ifGR@vertex@LabelOut% |
| 587 |
\def\nstyle{VertexStyle,% |
| 588 |
label={[text = \cmdGR@SVN@TextColor,\cmdGR@vertex@style]% |
| 589 |
\cmdGR@vertex@Lpos:\vertex@Name}} |
| 590 |
\def\vertex@Label{} |
| 591 |
\else% |
| 592 |
\def\vertex@Label{\vertex@Name} |
| 593 |
\fi |
| 594 |
\fi |
| 595 |
%<---------------------------------------------------------------------------> |
| 596 |
\ifthenelse{\not\equal{\cmdGR@vertex@x}{}}{% |
| 597 |
\protected@edef\@tempa{% |
| 598 |
\noexpand\node[outer sep=0pt,\cmdGR@vertex@style,\nstyle](#1) |
| 599 |
at (\cmdGR@vertex@x,\cmdGR@vertex@y){% |
| 600 |
\noexpand\vertex@Label}}% |
| 601 |
\@tempa;% |
| 602 |
}{% |
| 603 |
\ifthenelse{\not\equal{\cmdGR@vertex@d}{}}{% |
| 604 |
\protected@edef\@tempa{% |
| 605 |
\noexpand\node[outer sep=0pt,\cmdGR@vertex@style,\nstyle](#1) |
| 606 |
at (\cmdGR@vertex@a:\cmdGR@vertex@d){% |
| 607 |
\noexpand\vertex@Label}}% |
| 608 |
\@tempa;% |
| 609 |
}{% |
| 610 |
\protected@edef\@tempa{% |
| 611 |
\noexpand\node[outer sep=0pt,\cmdGR@vertex@style,\nstyle](#1)% |
| 612 |
[\cmdGR@vertex@position]{% |
| 613 |
\noexpand\vertex@Label}}% |
| 614 |
\@tempa;}}% |
| 615 |
\end{scope} |
| 616 |
\fi% |
| 617 |
} |
| 618 |
%<---------------------------------------------------------------------------> |
| 619 |
% End of Vertex |
| 620 |
%<---------------------------------------------------------------------------> |
| 621 |
% EA east of #2 |
| 622 |
%<---------------------------------------------------------------------------> |
| 623 |
\newcommand*{\EA}[1][]{\@droite[#1]}% |
| 624 |
\def\@droite[#1](#2)#3{% |
| 625 |
\begingroup% |
| 626 |
\setkeys[GR]{vertex}{#1}% |
| 627 |
\path (#2)--++(\cmdGR@vertex@unit,0) coordinate (#3); |
| 628 |
\Vertex[#1,Node]{#3} |
| 629 |
\endgroup% |
| 630 |
}% |
| 631 |
%<---------------------------------------------------------------------------> |
| 632 |
% WE west of #2 |
| 633 |
%<---------------------------------------------------------------------------> |
| 634 |
\newcommand*{\WE}[1][]{\@gauche[#1]}% |
| 635 |
\def\@gauche[#1](#2)#3{% |
| 636 |
\begingroup% |
| 637 |
\setkeys[GR]{vertex}{#1}% |
| 638 |
\path (#2)--++(-\cmdGR@vertex@unit,0) coordinate (#3); |
| 639 |
\Vertex[#1,Node]{#3} |
| 640 |
\endgroup% |
| 641 |
} |
| 642 |
%<---------------------------------------------------------------------------> |
| 643 |
% NO north of #2 |
| 644 |
%<---------------------------------------------------------------------------> |
| 645 |
\newcommand*{\NO}[1][]{\@haut[#1]}% |
| 646 |
\def\@haut[#1](#2)#3{% |
| 647 |
\begingroup% |
| 648 |
\setkeys[GR]{vertex}{#1}% |
| 649 |
\path (#2)--++(0,\cmdGR@vertex@unit) coordinate (#3); |
| 650 |
\Vertex[#1,Node]{#3} |
| 651 |
\endgroup% |
| 652 |
} |
| 653 |
%<---------------------------------------------------------------------------> |
| 654 |
% SO south of #2 |
| 655 |
%<---------------------------------------------------------------------------> |
| 656 |
\newcommand*{\SO}[1][]{\@bas[#1]}% |
| 657 |
\def\@bas[#1](#2)#3{% |
| 658 |
\begingroup% |
| 659 |
\setkeys[GR]{vertex}{#1}% |
| 660 |
\path (#2)--++(0,-\cmdGR@vertex@unit) coordinate (#3); |
| 661 |
\Vertex[#1,Node]{#3} |
| 662 |
\endgroup% |
| 663 |
} |
| 664 |
%<---------------------------------------------------------------------------> |
| 665 |
% NOEA north east of #2 |
| 666 |
%<---------------------------------------------------------------------------> |
| 667 |
\newcommand*{\NOEA}[1][]{\@hautdroite[#1]}% |
| 668 |
\def\@hautdroite[#1](#2)#3{% |
| 669 |
\begingroup% |
| 670 |
\setkeys[GR]{vertex}{#1}% |
| 671 |
\path (#2)--++(\cmdGR@vertex@unit,\cmdGR@vertex@unit) coordinate (#3); |
| 672 |
\Vertex[#1,Node]{#3} |
| 673 |
\endgroup% |
| 674 |
} |
| 675 |
|
| 676 |
%<---------------------------------------------------------------------------> |
| 677 |
% NOWE north west of #2 |
| 678 |
%<---------------------------------------------------------------------------> |
| 679 |
\newcommand*{\NOWE}[1][]{\@hautgauche[#1]}% |
| 680 |
\def\@hautgauche[#1](#2)#3{% |
| 681 |
\begingroup% |
| 682 |
\setkeys[GR]{vertex}{#1}% |
| 683 |
\path (#2)--++(-\cmdGR@vertex@unit,\cmdGR@vertex@unit) coordinate (#3); |
| 684 |
\Vertex[#1,Node]{#3} |
| 685 |
\endgroup% |
| 686 |
} |
| 687 |
%<---------------------------------------------------------------------------> |
| 688 |
% SOEA south east of #2 |
| 689 |
%<---------------------------------------------------------------------------> |
| 690 |
\newcommand*{\SOEA}[1][]{\@basdroite[#1]}% |
| 691 |
\def\@basdroite[#1](#2)#3{% |
| 692 |
\begingroup% |
| 693 |
\setkeys[GR]{vertex}{#1}% |
| 694 |
\path (#2)--++(\cmdGR@vertex@unit,-\cmdGR@vertex@unit) coordinate (#3); |
| 695 |
\Vertex[#1,Node]{#3} |
| 696 |
\endgroup% |
| 697 |
} |
| 698 |
%<---------------------------------------------------------------------------> |
| 699 |
% SOWE south west of #2 |
| 700 |
%<---------------------------------------------------------------------------> |
| 701 |
\newcommand*{\SOWE}[1][]{\@basgauche[#1]}% |
| 702 |
\def\@basgauche[#1](#2)#3{% |
| 703 |
\begingroup% |
| 704 |
\setkeys[GR]{vertex}{#1}% |
| 705 |
\path (#2)--++(-\cmdGR@vertex@unit,-\cmdGR@vertex@unit) coordinate (#3); |
| 706 |
\Vertex[#1,Node]{#3} |
| 707 |
\endgroup% |
| 708 |
} |
| 709 |
|
| 710 |
%<---------------------------------------------------------------------------> |
| 711 |
% Vertices |
| 712 |
%<---------------------------------------------------------------------------> |
| 713 |
\newcommand*{\Vertices}[1][]{\Vertices@NoStar[#1]}% |
| 714 |
\def\Vertices@NoStar[#1]#2#3{% |
| 715 |
\setkeys[GR]{vertex}{#1}% |
| 716 |
\begingroup% |
| 717 |
\setcounter{tkz@gr@p}{0} |
| 718 |
\@for\liste:=#3\do{% |
| 719 |
\stepcounter{tkz@gr@p}% |
| 720 |
\global\expandafter\let\csname label@\alph{tkz@gr@p}\endcsname\liste} |
| 721 |
\ifthenelse{\equal{#2}{line}}{% |
| 722 |
\setcounter{tkz@gr@p}{0} |
| 723 |
\foreach \fin in {#3}{% |
| 724 |
\ifthenelse{\value{tkz@gr@p}=0}{% |
| 725 |
\global\let\deb\fin |
| 726 |
\Vertex[#1]{\fin} |
| 727 |
\stepcounter{tkz@gr@p} |
| 728 |
}{% |
| 729 |
\cmdGR@vertex@dir[#1,x={},y={},a={},d={},Node=false](\deb){\fin} |
| 730 |
\global\let\deb\fin |
| 731 |
} |
| 732 |
}% |
| 733 |
}{ |
| 734 |
\ifthenelse{\equal{#2}{square}}{% |
| 735 |
\begin{scope}[rotate=45] |
| 736 |
\Vertex[#1,Lpos=-135]{\label@a} |
| 737 |
\EA[#1,Lpos=-45,x={},y={},Node=false](\label@a){\label@b} |
| 738 |
\NO[#1,Lpos=45, x={},y={},Node=false](\label@b){\label@c} |
| 739 |
\WE[#1,Lpos=135,x={},y={},Node=false](\label@c){\label@d} |
| 740 |
\end{scope} |
| 741 |
}{% |
| 742 |
\ifthenelse{\equal{#2}{tr1}}{% |
| 743 |
\Vertex[#1]{\label@a} |
| 744 |
\EA[#1,x={},y={},Node=false](\label@a){\label@b} |
| 745 |
\NO[#1,x={},y={},Node=false](\label@b){\label@c}}{% |
| 746 |
\ifthenelse{\equal{#2}{tr2}}{% |
| 747 |
\Vertex[#1]{\label@a} |
| 748 |
\NO[#1,x={},y={},Node=false](\label@a){\label@b} |
| 749 |
\EA[#1,x={},y={},Node=false](\label@b){\label@c}}{% |
| 750 |
\ifthenelse{\equal{#2}{tr3}}{% |
| 751 |
\Vertex[#1]{\label@a} |
| 752 |
\NO[#1,x={},y={},Node=false](\label@a){\label@b} |
| 753 |
\WE[#1,x={},y={},Node=false](\label@b){\label@c}}{% |
| 754 |
\ifthenelse{\equal{#2}{tr4}}{% |
| 755 |
\Vertex[#1]{\label@a} |
| 756 |
\WE[#1,x={},y={},Node=false](\label@a){\label@b} |
| 757 |
\NO[#1,x={},y={},Node=false](\label@b){\label@c}}{% |
| 758 |
\ifthenelse{\equal{#2}{circle}}{% |
| 759 |
\pgfmathdivide{360}{\value{tkz@gr@p}}% |
| 760 |
\global\let\gr@angle\pgfmathresult% |
| 761 |
\setcounter{tkz@gr@p}{0} |
| 762 |
\foreach \lab in {#3}{% |
| 763 |
\pgfmathmultiply{\gr@angle}{\thetkz@gr@p}% |
| 764 |
\let\gr@newangle\pgfmathresult% |
| 765 |
\pgfmathadd{\cmdGR@vertex@Lpos}{\gr@newangle} |
| 766 |
\let\gr@posangle\pgfmathresult% |
| 767 |
\Vertex[#1, |
| 768 |
a = \gr@newangle, |
| 769 |
d = \cmdGR@vertex@unit, |
| 770 |
Lpos = \gr@posangle]{\lab} |
| 771 |
\stepcounter{tkz@gr@p}% |
| 772 |
}% |
| 773 |
}{}% |
| 774 |
}}}}}}% |
| 775 |
\endgroup% |
| 776 |
} |
| 777 |
%<---------------------------------------------------------------------------> |
| 778 |
% Edge style |
| 779 |
%<---------------------------------------------------------------------------> |
| 780 |
\tikzset{LabelStyle/.style={}}% add 03/04/2009 |
| 781 |
\tikzset{EdgeStyle/.style={}} |
| 782 |
%<---------------------------------------------------------------------------> |
| 783 |
% Init SetUpEdge |
| 784 |
%<---------------------------------------------------------------------------> |
| 785 |
\define@cmdkey [GR] {SUE} {color}{} |
| 786 |
\define@cmdkey [GR] {SUE} {label}{} |
| 787 |
\define@cmdkey [GR] {SUE} {labelstyle}{} |
| 788 |
\define@cmdkey [GR] {SUE} {labeltext}{} |
| 789 |
\define@cmdkey [GR] {SUE} {labelcolor}{} |
| 790 |
\define@cmdkey [GR] {SUE} {style}{} |
| 791 |
\define@cmdkey [GR] {SUE} {lw}{} |
| 792 |
\presetkeys [GR] {SUE} {color = \EdgeColor, |
| 793 |
lw = \EdgeLineWidth, |
| 794 |
label = {}, |
| 795 |
labeltext = \LabelTextColor, |
| 796 |
labelcolor = \LabelFillColor, |
| 797 |
labelstyle = {}, |
| 798 |
style = {}}{} |
| 799 |
%<---------------------------------------------------------------------------> |
| 800 |
% SetUpEdge |
| 801 |
%<---------------------------------------------------------------------------> |
| 802 |
\newcommand*{\SetUpEdge}[1][]{\@SetUpEdge[#1]}% |
| 803 |
\def\@SetUpEdge[#1]{% |
| 804 |
\setkeys [GR] {SUE} {#1}% |
| 805 |
\presetkeys [GR] {edge} {color = \cmdGR@SUE@color, |
| 806 |
lw = \cmdGR@SUE@lw, |
| 807 |
label = \cmdGR@SUE@label, |
| 808 |
labeltext = \cmdGR@SUE@labeltext, |
| 809 |
labelcolor = \cmdGR@SUE@labelcolor, |
| 810 |
labelstyle = \cmdGR@SUE@labelstyle, |
| 811 |
style = \cmdGR@SUE@style}{} |
| 812 |
\tikzset{LabelStyle/.style={}} |
| 813 |
\tikzset{EdgeStyle/.style={}}} |
| 814 |
\newcommand*{\DisableEdgeStyle}{\tikzset{EdgeStyle/.style={}}} |
| 815 |
%<---------------------------------------------------------------------------> |
| 816 |
% Init Edge |
| 817 |
%<---------------------------------------------------------------------------> |
| 818 |
\define@cmdkey [GR] {edge} {color}{} |
| 819 |
\define@cmdkey [GR] {edge} {lw}{} |
| 820 |
\define@cmdkey [GR] {edge} {double}{} |
| 821 |
\define@cmdkey [GR] {edge} {incolor}{} |
| 822 |
\define@cmdkey [GR] {edge} {dd}{} |
| 823 |
\define@cmdkey [GR] {edge} {style}{} |
| 824 |
\define@cmdkey [GR] {edge} {label}{} |
| 825 |
\define@cmdkey [GR] {edge} {labeltext}{} |
| 826 |
\define@cmdkey [GR] {edge} {labelcolor}{} |
| 827 |
\define@cmdkey [GR] {edge} {labelstyle}{} |
| 828 |
\define@boolkey[GR] {edge} {local}[true]{} |
| 829 |
\presetkeys [GR] {edge} {style = {pos=.5}, |
| 830 |
lw = \EdgeLineWidth, |
| 831 |
label = {}, |
| 832 |
labeltext = \LabelTextColor, |
| 833 |
labelcolor = \LabelFillColor, |
| 834 |
labelstyle = {}, |
| 835 |
local = false, |
| 836 |
double = {}, |
| 837 |
dd = \EdgeDoubleDistance, |
| 838 |
incolor = \EdgeFillColor, |
| 839 |
color = \EdgeColor}{} |
| 840 |
%<---------------------------------------------------------------------------> |
| 841 |
% Edge |
| 842 |
%<---------------------------------------------------------------------------> |
| 843 |
\newcommand*{\Edge}[1][]{\@edge[#1]}% |
| 844 |
\def\@edge[#1](#2)(#3){% |
| 845 |
\setkeys[GR]{edge}{#1}% |
| 846 |
\begingroup% |
| 847 |
\ifthenelse{\equal{\cmdGR@edge@double}{}}{% |
| 848 |
\tikzset{LocalEdgeStyle/.style={color = \cmdGR@edge@color, |
| 849 |
line width = \cmdGR@edge@lw}}}{% |
| 850 |
\tikzset{LocalEdgeStyle/.style={line width = \cmdGR@edge@dd, |
| 851 |
color = \cmdGR@edge@double, |
| 852 |
double distance = \cmdGR@edge@lw, |
| 853 |
double = \cmdGR@edge@color}}}% |
| 854 |
\ifGR@edge@local% |
| 855 |
\tikzset{EdgeStyle/.style={}}% |
| 856 |
\fi |
| 857 |
\ifthenelse{\equal{\cmdGR@edge@label}{}}{% |
| 858 |
\protected@edef\@tempa{% |
| 859 |
\noexpand \draw[LocalEdgeStyle,\cmdGR@edge@style,EdgeStyle]}% |
| 860 |
\@tempa (#2) to (#3)}{% |
| 861 |
\protected@edef\@tempa{% |
| 862 |
\noexpand \draw[LocalEdgeStyle,\cmdGR@edge@style,EdgeStyle] (#2) to% |
| 863 |
node[fill = \cmdGR@edge@labelcolor, |
| 864 |
text = \cmdGR@edge@labeltext, |
| 865 |
\cmdGR@edge@labelstyle,LabelStyle]}\@tempa |
| 866 |
{\cmdGR@edge@label} (#3)}% |
| 867 |
; |
| 868 |
\endgroup% |
| 869 |
}% |
| 870 |
%<---------------------------------------------------------------------------> |
| 871 |
% Edges |
| 872 |
%<---------------------------------------------------------------------------> |
| 873 |
\newcommand*{\Edges}[1][]{\@edges[#1]}% |
| 874 |
\def\@edges[#1](#2){% |
| 875 |
\setkeys[GR]{edge}{#1}% |
| 876 |
\begingroup% |
| 877 |
\setcounter{tkz@gr@p}{0} |
| 878 |
\foreach \fin in {#2}{% |
| 879 |
\ifthenelse{\value{tkz@gr@p}=0}{% |
| 880 |
\global\let\deb\fin |
| 881 |
\stepcounter{tkz@gr@p}}{% |
| 882 |
\Edge[#1](\deb)(\fin) |
| 883 |
\global\let\deb\fin |
| 884 |
}% |
| 885 |
} |
| 886 |
\endgroup% |
| 887 |
}% |
| 888 |
%<---------------------------------------------------------------------------> |
| 889 |
% Init loop |
| 890 |
%<---------------------------------------------------------------------------> |
| 891 |
\define@choicekey*[GR]{loop}{dir}[\val\nr]{WE,EA,NO,SO,NOWE,NOEA,SOWE,SOEA}{% |
| 892 |
\ifcase\nr\relax |
| 893 |
\tikzset{LoopStyle/.style = {in=225, out=135, distance=\cmdGR@loop@dist}}% |
| 894 |
\or |
| 895 |
\tikzset{LoopStyle/.style = {in= 45, out=-45, distance=\cmdGR@loop@dist}}% |
| 896 |
\or |
| 897 |
\tikzset{LoopStyle/.style = {in=135, out= 45, distance=\cmdGR@loop@dist}}% |
| 898 |
\or |
| 899 |
\tikzset{LoopStyle/.style = {in=-45, out=-135, distance=\cmdGR@loop@dist}}% |
| 900 |
\or |
| 901 |
\tikzset{LoopStyle/.style = {in=180, out=90, distance=\cmdGR@loop@dist}}% |
| 902 |
\or |
| 903 |
\tikzset{LoopStyle/.style = {in=90, out=0, distance=\cmdGR@loop@dist}}% |
| 904 |
\or |
| 905 |
\tikzset{LoopStyle/.style = {in=-90, out=-180, distance=\cmdGR@loop@dist}}% |
| 906 |
\or |
| 907 |
\tikzset{LoopStyle/.style = {in=0, out=-90, distance=\cmdGR@loop@dist}}% |
| 908 |
\fi% |
| 909 |
} |
| 910 |
\define@cmdkey [GR] {loop} {color}{} |
| 911 |
\define@cmdkey [GR] {loop} {label}{} |
| 912 |
\define@cmdkey [GR] {loop} {labelstyle}{} |
| 913 |
\define@cmdkey [GR] {loop} {style}{} |
| 914 |
\define@cmdkey [GR] {loop} {dist}{} |
| 915 |
\presetkeys [GR] {loop} {style = {pre,thick},%` |
| 916 |
label = {},% |
| 917 |
labelstyle = {},% |
| 918 |
color = \tkz@suc@txt,% |
| 919 |
dist = 4cm,% |
| 920 |
dir = WE}{} |
| 921 |
%<---------------------------------------------------------------------------> |
| 922 |
% loop |
| 923 |
%<---------------------------------------------------------------------------> |
| 924 |
\newcommand*{\grLoop}[1][]{\tkzGR@loop[#1]}% |
| 925 |
\def\tkzGR@loop[#1](#2){% |
| 926 |
\setkeys[GR]{loop}{#1}% |
| 927 |
\protected@edef\@tempa{% |
| 928 |
\noexpand \draw[\cmdGR@loop@color] (#2)% |
| 929 |
edge [EdgeStyle,LoopStyle,\cmdGR@loop@style]% |
| 930 |
node [LabelStyle,\cmdGR@loop@labelstyle]% |
| 931 |
{\cmdGR@loop@label} (#2)}\@tempa;% |
| 932 |
}% |
| 933 |
%<---------------------------------------------------------------------------> |
| 934 |
% Init Graphes probabilistes |
| 935 |
%<---------------------------------------------------------------------------> |
| 936 |
\define@cmdkey [GR] {grpb} {unit}{} |
| 937 |
\define@cmdkey [GR] {grpb} {LposA}{} |
| 938 |
\define@cmdkey [GR] {grpb} {LposB}{} |
| 939 |
\define@cmdkey [GR] {grpb} {Ldist}{} |
| 940 |
\define@cmdkey [GR] {grpb} {LoopDist}{} |
| 941 |
\presetkeys [GR] {grpb} {LposA = 180,% |
| 942 |
LposB = 0,% |
| 943 |
Ldist = 0cm,% |
| 944 |
LoopDist = 4cm, |
| 945 |
unit = 4}{} |
| 946 |
%<---------------------------------------------------------------------------> |
| 947 |
% Graphes probabilistes |
| 948 |
%<---------------------------------------------------------------------------> |
| 949 |
\newcommand*{\grProb}[7][]{% |
| 950 |
\setkeys[GR]{grpb}{#1}% |
| 951 |
\tikzset{LabelStyle/.append style ={pos=.5}} |
| 952 |
\Vertex[Lpos=\cmdGR@grpb@LposA,Ldist=\cmdGR@grpb@Ldist,L=#2]{grA} |
| 953 |
\EA[unit=\cmdGR@grpb@unit,Lpos=\cmdGR@grpb@LposB, |
| 954 |
Ldist=\cmdGR@grpb@Ldist,L=#3](grA){grB} |
| 955 |
\Edge[style={post,bend left=60},label={$#4$},labelstyle={above}](grA)(grB) |
| 956 |
\Edge[style={post,bend left=60},label={$#5$},labelstyle={below}](grB)(grA) |
| 957 |
\grLoop[dist=\cmdGR@grpb@LoopDist,dir=WE,label={$#6$},labelstyle={left}](grA) |
| 958 |
\grLoop[dist=\cmdGR@grpb@LoopDist,dir=EA,label={$#7$},labelstyle={right}](grB) |
| 959 |
}% |
| 960 |
\newcommand*{\grProbThree}[7][]{% |
| 961 |
\setkeys[GR]{grpb}{#1}% |
| 962 |
\begin{scope}[] |
| 963 |
\tikzset{LabelStyle/.append style ={pos=.5}} |
| 964 |
\Vertices[empty,unit=\cmdGR@grpb@unit]{circle}{grA,grB,grC} |
| 965 |
\Vertex[Node,Lpos=\cmdGR@grpb@LposA,Ldist=\cmdGR@grpb@Ldist,L=#2]{grA} |
| 966 |
\Vertex[Node,Lpos=\cmdGR@grpb@LposA,Ldist=\cmdGR@grpb@Ldist,L=#3]{grB} |
| 967 |
\Vertex[Node,Lpos=\cmdGR@grpb@LposA,Ldist=\cmdGR@grpb@Ldist,L=#4]{grC} |
| 968 |
\foreach \x/\y/\z in {#5} {% |
| 969 |
\grLoop[dist=\cmdGR@grpb@LoopDist,dir=EA,label={$\x$}](grA) |
| 970 |
\Edge[style={post,bend right=20},label={$\y$}](grA)(grB) |
| 971 |
\Edge[style={post,bend right=20},label={$\z$}](grA)(grC)} |
| 972 |
\foreach \x/\y/\z in {#6} {% |
| 973 |
\grLoop[dist=\cmdGR@grpb@LoopDist,dir=NO,label={$\x$}](grB) |
| 974 |
\Edge[style={post,bend right=20},label={$\y$}](grB)(grA) |
| 975 |
\Edge[style={post,bend right=20},label={$\z$}](grB)(grC)} |
| 976 |
\foreach \x/\y/\z in {#7} {% |
| 977 |
\grLoop[dist=\cmdGR@grpb@LoopDist,dir=SO,label={$\x$}](grC) |
| 978 |
\Edge[style={post,bend right=20},label={$\y$}](grC)(grA) |
| 979 |
\Edge[style={post,bend right=20},label={$\z$}](grC)(grB)} |
| 980 |
\end{scope} |
| 981 |
} |
| 982 |
%<---------------------------------------------------------------------------> |
| 983 |
% End Graphes probabilistes |
| 984 |
%<---------------------------------------------------------------------------> |
| 985 |
\let\Loop\grLoop |
| 986 |
\newcommand{\SetVertexLabeledSmall}{% |
| 987 |
\SetVertexLabel% |
| 988 |
\tikzset{VertexStyle/.style = {draw, |
| 989 |
shape = circle, |
| 990 |
inner sep = 1pt, |
| 991 |
minimum size = 10pt}} |
| 992 |
\tikzset{EdgeStyle/.style = {double = \tkz@suc@txt, |
| 993 |
double distance = 1pt, |
| 994 |
color = \tkz@suc@bkc, |
| 995 |
line width = 0.7pt}} |
| 996 |
} |
| 997 |
\newcommand{\SetVertexNotLabeledSmall}{% |
| 998 |
\tikzset{EdgeStyle/.style = {double = \tkz@suc@txt, |
| 999 |
double distance = 1pt, |
| 1000 |
color = \tkz@suc@bkc, |
| 1001 |
line width = 0.7pt}} |
| 1002 |
\SetVertexNoLabel |
| 1003 |
\SetVertexSimple[MinSize=6pt,FillColor=gray] |
| 1004 |
\renewcommand*{\VertexLineWidth}{0pt} |
| 1005 |
}% |
| 1006 |
|
| 1007 |
\newcommand{\SetVertexForPresentation}[3]{% |
| 1008 |
\GraphInit[vstyle=Shade] |
| 1009 |
\SetVertexNoLabel |
| 1010 |
\renewcommand*{\VertexBigMinSize}{12pt}% |
| 1011 |
\renewcommand*{\EdgeDoubleDistance}{2pt}% |
| 1012 |
\renewcommand*{\EdgeLineWidth}{0.7pt}% |
| 1013 |
\SetGraphShadeColor{#1}{#2}{#3} |
| 1014 |
}% |
| 1015 |
|
| 1016 |
\newcommand{\setxyzvec}[1][20]{% |
| 1017 |
\pgfmathsetmacro{\xone}{cos(180+#1)}% |
| 1018 |
\pgfmathsetmacro{\yone}{sin(180+#1)}% |
| 1019 |
\pgfmathsetmacro{\xtwo}{cos(360-#1)}% |
| 1020 |
\pgfmathsetmacro{\ytwo}{sin(360-#1)}% |
| 1021 |
\pgfsetxvec{\pgfpoint{\xone cm}{\yone cm}}% |
| 1022 |
\pgfsetyvec{\pgfpoint{\xtwo cm}{\ytwo cm}}% |
| 1023 |
\pgfsetzvec{\pgfpoint{0cm}{1cm}}% |
| 1024 |
} |
| 1025 |
\endinput |
| 1026 |
|