% tkz-graph.sty v2.0 % Copyright 2021 Alain Matthes % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3 % of this license or (at your option) any later version. % The latest version of this license is in % http://www.latex-project.org/lppl.txt % and version 1.3 or later is part of all distributions of LaTeX % version 2005/12/01 or later. % % This work has the LPPL maintenance status “maintained”. % % The Current Maintainer of this work is Alain Matthes. %<---------------------------------------------------------------------------> % Objet : Création de graphes %<---------------------------------------------------------------------------> \def\fileversion{2.00} \def\filedate{2021/01/20} \typeout{2021/01/20 v 2.00 tkz-graph.sty} \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{tkz-graph}[2021/01/20 2.00 base for graphs] %<---------------------------------------------------------------------------> \ifx\e@alloc\@undefined \RequirePackage{etex} \fi \RequirePackage{ifthen} \RequirePackage{xkeyval} \RequirePackage{tikz} \usetikzlibrary{arrows} %<---------------------------------------------------------------------------> % todo remove some counters \newcounter{tkz@gr@a} \newcounter{tkz@gr@b} \newcounter{tkz@gr@c} \newcounter{tkz@gr@e} \newcounter{tkz@gr@d} \newcounter{tkz@gr@p} \newcounter{tkz@gr@i} \newcounter{tkz@gr@n} \newcounter{tkz@gr@ta} \newcounter{tkz@gr@tb} %<---------------------------------------------------------------------------> % Init vertex %<---------------------------------------------------------------------------> %<---------------------------------------------------------------------------> \def\tkz@gr@background@color{white} \def\tkz@gr@text@color{black} \global\edef\tkz@suc@bkc{\tkz@gr@background@color} \global\edef\tkz@suc@txt{\tkz@gr@text@color} \pgfkeys{ /tkzsupcol/.cd, background/.code = {\global\edef\tkz@suc@bkc{#1}}, text/.code = {\global\edef\tkz@suc@txt{#1}}, } \def\tkzSetUpColors{\pgfutil@ifnextchar[{\tkz@SetUpColors}{\tkz@SetUpColors[]}} \def\tkz@SetUpColors[#1]{% \begingroup \pgfkeys{% /tkzsupcol/.cd, background = \tkz@gr@background@color, text = \tkz@gr@text@color } \pgfqkeys{/tkzsupcol}{#1} \pagecolor{\tkz@suc@bkc} \color{\tkz@suc@txt} \endgroup } \newcommand*{\GraphUnit}{1} \newcommand*{\VertexInnerSep}{2pt} \newcommand*{\VertexOuterSep}{0pt} \newcommand*{\VertexDistance}{3cm} \newcommand*{\VertexShape}{circle} \newcommand*{\VertexLineWidth}{0.5pt} \newcommand*{\VertexLineColor}{\tkz@suc@txt} \newcommand*{\VertexLightFillColor}{\tkz@suc@bkc} \newcommand*{\VertexDarkFillColor}{\tkz@suc@txt} \newcommand*{\VertexTextColor}{\tkz@suc@txt} \newcommand*{\VertexFillColor}{\tkz@suc@txt} \newcommand*{\VertexBallColor}{orange} \newcommand*{\VertexBigMinSize}{24pt} \newcommand*{\VertexInterMinSize}{18pt} \newcommand*{\VertexSmallMinSize}{12pt} \newcommand*{\EdgeFillColor}{orange} \newcommand*{\EdgeArtColor}{orange} \newcommand*{\EdgeColor}{\tkz@suc@txt} \newcommand*{\EdgeDoubleDistance}{1pt} \newcommand*{\EdgeLineWidth}{0.8pt} \newcommand*{\LabelTextColor}{\tkz@suc@txt} \newcommand*{\LabelFillColor}{\tkz@suc@bkc} \tikzset{pre/.style={<-,shorten <=1pt,>=stealth',semithick}} \tikzset{post/.style={->,shorten <=1pt,>=stealth',semithick}} %<---------------------------------------------------------------------------> % Simple Vertex %<---------------------------------------------------------------------------> \define@cmdkey [GR] {SVS} {Shape}{} \define@cmdkey [GR] {SVS} {MinSize}{} \define@cmdkey [GR] {SVS} {LineWidth}{} \define@cmdkey [GR] {SVS} {LineColor}{} \define@cmdkey [GR] {SVS} {FillColor}{} \define@cmdkey [GR] {SVS} {InnerSep}{} \define@cmdkey [GR] {SVS} {OuterSep}{} \presetkeys [GR] {SVS} {Shape = \VertexShape, MinSize = \VertexSmallMinSize, LineWidth = \VertexLineWidth, LineColor = \VertexLineColor, InnerSep = \VertexInnerSep, OuterSep = \VertexOuterSep, FillColor = \VertexFillColor}{} \newcommand*{\SetVertexSimple}[1][]{\GR@SetVertexSimple[#1]}% \def\GR@SetVertexSimple[#1]{% \setkeys[GR]{SVS}{#1}% \presetkeys[GR]{vertex}{NoLabel = true}{}% \tikzset{VertexStyle/.style = {draw, shape = \cmdGR@SVS@Shape, color = \cmdGR@SVS@LineColor, fill = \cmdGR@SVS@FillColor, inner sep = \cmdGR@SVS@InnerSep, outer sep = \cmdGR@SVS@OuterSep, minimum size = \cmdGR@SVS@MinSize, line width = \cmdGR@SVS@LineWidth}} \tikzset{EdgeStyle/.style = {line width = \EdgeLineWidth, \EdgeColor}} \tikzset{LabelStyle/.style={}}} %<---------------------------------------------------------------------------> % Shade Vertex %<---------------------------------------------------------------------------> \define@cmdkey [GR] {shade} {Shape}{} \define@cmdkey [GR] {shade} {MinSize}{} \define@cmdkey [GR] {shade} {LineWidth}{} \define@cmdkey [GR] {shade} {LineColor}{} \define@cmdkey [GR] {shade} {BallColor}{} \define@cmdkey [GR] {shade} {InnerSep}{} \define@cmdkey [GR] {shade} {OuterSep}{} \presetkeys [GR] {shade} {Shape = \VertexShape, MinSize = \VertexBigMinSize, LineWidth = \VertexLineWidth, LineColor = \VertexLineColor, InnerSep = \VertexInnerSep, OuterSep = \VertexOuterSep, BallColor = \VertexBallColor}{} \newcommand*{\SetVertexShade}[1][]{\GR@SetVertexShade[#1]}% \def\GR@SetVertexShade[#1]{% \setkeys[GR]{shade}{#1}% \presetkeys[GR]{vertex}{NoLabel = false}{}% \tikzset{VertexStyle/.style = {draw, shape = \cmdGR@shade@Shape, ball color = \cmdGR@shade@BallColor, inner sep = \cmdGR@shade@InnerSep, outer sep = \cmdGR@shade@OuterSep, minimum size = \cmdGR@shade@MinSize, line width = \VertexLineWidth}} \tikzset{EdgeStyle/.style = {line width = \EdgeLineWidth, \EdgeColor,% color outside double = \EdgeFillColor,% inside double distance = \EdgeDoubleDistance}}% \tikzset{LabelStyle/.style={}}} %<---------------------------------------------------------------------------> % Art Vertex %<---------------------------------------------------------------------------> \define@cmdkey [GR] {art} {Shape}{} \define@cmdkey [GR] {art} {MinSize}{} \define@cmdkey [GR] {art} {LineWidth}{} \define@cmdkey [GR] {art} {LineColor}{} \define@cmdkey [GR] {art} {BallColor}{} \define@cmdkey [GR] {art} {InnerSep}{} \define@cmdkey [GR] {art} {OuterSep}{} \presetkeys [GR] {art} {Shape = \VertexShape, MinSize = \VertexSmallMinSize, LineWidth = \VertexLineWidth, LineColor = \VertexLineColor, InnerSep = \VertexInnerSep, OuterSep = \VertexOuterSep, BallColor = \VertexBallColor}{} \newcommand*{\SetVertexArt}[1][]{\GR@SetVertexArt[#1]}% \def\GR@SetVertexArt[#1]{% \setkeys[GR]{art}{#1}% \presetkeys[GR]{vertex}{NoLabel = true}{}% \tikzset{VertexStyle/.style = {draw, shape = \cmdGR@art@Shape, ball color = \cmdGR@art@BallColor, inner sep = \cmdGR@art@InnerSep, outer sep = \cmdGR@art@OuterSep, minimum size = \cmdGR@art@MinSize, line width = \VertexLineWidth}} \tikzset{EdgeStyle/.style = {line width = \EdgeLineWidth, \EdgeArtColor}} \tikzset{LabelStyle/.style = {}}} %<---------------------------------------------------------------------------> % Normal Vertex %<---------------------------------------------------------------------------> \define@cmdkey [GR] {SVN} {Shape}{} \define@cmdkey [GR] {SVN} {MinSize}{} \define@cmdkey [GR] {SVN} {LineWidth}{} \define@cmdkey [GR] {SVN} {LineColor}{} \define@cmdkey [GR] {SVN} {FillColor}{} \define@cmdkey [GR] {SVN} {TextColor}{} \define@cmdkey [GR] {SVN} {InnerSep}{} \define@cmdkey [GR] {SVN} {OuterSep}{} \presetkeys [GR] {SVN} {Shape = \VertexShape, MinSize = \VertexInterMinSize, LineWidth = \VertexLineWidth, LineColor = \VertexLineColor, FillColor = \VertexLightFillColor, InnerSep = \VertexInnerSep, OuterSep = \VertexOuterSep, TextColor = \VertexTextColor}{} \newcommand*{\SetVertexNormal}[1][]{\GR@SetVertexNormal[#1]}% \def\GR@SetVertexNormal[#1]{% \setkeys[GR]{SVN}{#1}% \tikzset{VertexStyle/.style = {shape = \cmdGR@SVN@Shape, minimum size = \cmdGR@SVN@MinSize, line width = \cmdGR@SVN@LineWidth, color = \cmdGR@SVN@LineColor, fill = \cmdGR@SVN@FillColor, text = \cmdGR@SVN@TextColor, inner sep = \cmdGR@SVN@InnerSep, outer sep = \cmdGR@SVN@OuterSep, draw}} \tikzset{EdgeStyle/.style = {line width = \EdgeLineWidth, \EdgeColor}} \tikzset{LabelStyle/.style={}}} \SetVertexNormal% default %<---------------------------------------------------------------------------> \define@cmdkey [GR] {init} {unit}{} \define@choicekey*[GR]{init}{vstyle}[\val\nr]{Empty,% Hasse,% Simple,% Classic,% Normal,% Shade,% Dijkstra,% Welsh,% Art,% Shade Art}{% \edef\GR@init@vstyle{\nr} \ifcase\nr\relax % Empty \presetkeys [GR] {vertex} {LabelOut = false}{}% \tikzset{VertexStyle/.style = {shape = \VertexShape, color = \VertexLineColor, fill = \VertexLightFillColor, inner sep = \VertexInnerSep, outer sep = 0.5\pgflinewidth, text = \VertexTextColor, minimum size = \VertexSmallMinSize, line width = \VertexLineWidth}} \tikzset{EdgeStyle/.style = {line width = \EdgeLineWidth,\EdgeColor}} \tikzset{LabelStyle/.style={}} \or % Hasse \presetkeys [GR] {vertex} {NoLabel = true}{}% \tikzset{VertexStyle/.style = {draw, shape = \VertexShape, color = \VertexLineColor, fill = \VertexLightFillColor, inner sep = \VertexInnerSep, outer sep = 0.5\pgflinewidth, text = \VertexTextColor, minimum size = \VertexSmallMinSize, line width = \VertexLineWidth}} \tikzset{EdgeStyle/.style = {line width = \EdgeLineWidth, \EdgeColor}} \tikzset{LabelStyle/.style={}} \or % Simple \presetkeys [GR] {vertex} {NoLabel = true}{}% \tikzset{VertexStyle/.style = {draw, shape = \VertexShape, color = \VertexLineColor, fill = \VertexDarkFillColor, inner sep = \VertexInnerSep, outer sep = 0.5\pgflinewidth, text = \VertexTextColor, minimum size = \VertexSmallMinSize, line width = \VertexLineWidth}} \tikzset{EdgeStyle/.style = {line width = \EdgeLineWidth, \EdgeColor}} \tikzset{LabelStyle/.style={}} % Classic \or \presetkeys [GR] {vertex} {LabelOut = true}{}% \tikzset{VertexStyle/.style = {draw, shape = \VertexShape, color = \VertexLineColor, fill = \VertexDarkFillColor, inner sep = \VertexInnerSep, outer sep = 0.5\pgflinewidth, text = \VertexTextColor, minimum size = \VertexSmallMinSize, line width = \VertexLineWidth}} \tikzset{EdgeStyle/.style = {line width = \EdgeLineWidth, \EdgeColor}} \tikzset{LabelStyle/.style={}} % Normal \or \presetkeys [GR] {vertex} {LabelOut = false}{}% \tikzset{VertexStyle/.style = {draw, shape = \VertexShape, minimum size = \VertexInterMinSize, line width = \VertexLineWidth, color = \VertexLineColor, outer sep = 0.5\pgflinewidth, fill = \VertexLightFillColor, text = \VertexTextColor, line width = \VertexLineWidth}} \tikzset{EdgeStyle/.style = {line width = \EdgeLineWidth, \EdgeColor}} \tikzset{LabelStyle/.style={}} % Shade \or \presetkeys [GR] {vertex} {LabelOut = false}{}% \tikzset{VertexStyle/.style = {draw, shape = \VertexShape, ball color = \VertexBallColor, color = \VertexLineColor, text = \VertexTextColor, inner sep = \VertexInnerSep, outer sep = \VertexOuterSep, minimum size = \VertexBigMinSize, line width = \VertexLineWidth}} \tikzset{EdgeStyle/.style = {line width = \EdgeLineWidth, \EdgeColor,% color outside double = \EdgeFillColor,% inside double distance = \EdgeDoubleDistance}}% \tikzset{LabelStyle/.style={}} % Dijkstra \or \presetkeys [GR] {vertex} {LabelOut = false}{}% \tikzset{VertexStyle/.style = {draw, shape = \VertexShape, color = \VertexLineColor, fill = \VertexLightFillColor, inner sep = \VertexInnerSep, outer sep = 0.5\pgflinewidth, text = \VertexTextColor, minimum size = \VertexInterMinSize, line width = \VertexLineWidth}} \tikzset{EdgeStyle/.style = {line width = \EdgeLineWidth, \EdgeColor}} \tikzset{LabelStyle/.style={}} % Welsh \or \presetkeys [GR] {vertex} {LabelOut = true}{}% \tikzset{VertexStyle/.style = {draw, shape = \VertexShape, color = \VertexLineColor, fill = \VertexLightFillColor, inner sep = \VertexInnerSep, outer sep = \VertexOuterSep, text = \VertexTextColor, minimum size = \VertexSmallMinSize, line width = \VertexLineWidth}} \tikzset{EdgeStyle/.style = {line width = \EdgeLineWidth, \EdgeColor}}% \tikzset{LabelStyle/.style={}} % Art \or \presetkeys [GR] {vertex} {NoLabel = true}{}% \tikzset{VertexStyle/.style = {shape = \VertexShape, ball color = \VertexBallColor, color = \VertexLineColor, inner sep = \VertexInnerSep, outer sep = \VertexOuterSep, minimum size = \VertexSmallMinSize, line width = \VertexLineWidth}}% \tikzset{EdgeStyle/.style = {line width = \EdgeLineWidth, \EdgeArtColor}} \tikzset{LabelStyle/.style = {}} % ShadeArt \or \presetkeys [GR] {vertex} {NoLabel = true}{}% \tikzset{VertexStyle/.style = {shape = \VertexShape, ball color = \VertexBallColor, inner sep = \VertexInnerSep, outer sep = \VertexOuterSep, minimum size = \VertexSmallMinSize, line width = \VertexLineWidth}} \tikzset{EdgeStyle/.style = {line width = \EdgeLineWidth, \EdgeColor, double = \EdgeFillColor, double distance = .5\EdgeDoubleDistance}} \tikzset{LabelStyle/.style = {}} \fi% } \presetkeys [GR] {init} {vstyle = Normal,% unit = \GraphUnit}{} \newcommand*{\SetGraphUnit}[1]{\renewcommand{\GraphUnit}{#1}}% \newcommand*{\GraphInit}[1][]{\setkeys[GR]{init}{#1}% \edef\GraphUnit{\cmdGR@init@unit}% }% %<---------------------------------------------------------------------------> % Colors %<---------------------------------------------------------------------------> \newcommand*{\SetGraphShadeColor}[3]{% \tikzset{VertexStyle/.append style = {ball color=#1}} \tikzset{EdgeStyle/.append style = {color=#2,double=#3}} } \newcommand*{\SetGraphArtColor}[2]{% \tikzset{VertexStyle/.append style = {ball color=#1}} \tikzset{EdgeStyle/.append style = {color=#2}} } \newcommand*{\SetGraphColor}[2]{% \tikzset{VertexStyle/.append style = {fill=#1}} \tikzset{EdgeStyle/.append style = {color=#2}} } \newcommand*{\AddVertexColor}[2]{% \begingroup \tikzset{VertexStyle/.append style = {fill=#1}} \foreach \v in {#2} {\Vertex[Node,NoLabel]{\v}} \endgroup } %<---------------------------------------------------------------------------> \newcommand*{\SetVertexNoLabel}{% \presetkeys [GR] {vertex} {NoLabel = true}{}% } % add RV \newcommand*{\SetVertexLabel}{% \presetkeys [GR] {vertex} {NoLabel = false}{}% } %<---------------------------------------------------------------------------> \newcommand*{\SetVertexLabelOut}{% \presetkeys [GR] {vertex} {LabelOut = true}{}% } \newcommand*{\SetVertexLabelIn}{% \presetkeys [GR] {vertex} {LabelOut = false}{}% } \newcommand*{\SetVertexMath}{% \presetkeys [GR] {vertex} {Math = true}{}% \presetkeys [GR] {cl} {Math = true}{}% } \newcommand*{\SetVertexNoMath}{% \presetkeys [GR] {vertex} {Math = false}{}% \presetkeys [GR] {cl} {Math = false}{}% } %<---------------------------------------------------------------------------> % Init SetUpVertex %<---------------------------------------------------------------------------> \define@cmdkey [GR] {SUV} {Lpos}{} \define@cmdkey [GR] {SUV} {Ldist}{} \define@cmdkey [GR] {SUV} {Style}{} \define@cmdkey [GR] {SUV} {MinSize}{} \define@cmdkey [GR] {SUV} {LineWidth}{} \define@cmdkey [GR] {SUV} {TextColor}{} \define@cmdkey [GR] {SUV} {LineColor}{} \define@cmdkey [GR] {SUV} {FillColor}{} \define@cmdkey [GR] {SUV} {InnerSep}{} \define@cmdkey [GR] {SUV} {OuterSep}{} \define@cmdkey [GR] {SUV} {Unit}{} \define@boolkey [GR] {SUV} {NoLabel} [true]{} \define@boolkey [GR] {SUV} {LabelOut}[true]{} \define@boolkey [GR] {SUV} {Math}[true]{} \presetkeys [GR] {SUV} {Ldist = 0cm, Lpos = 0, Style = {}, LabelOut = false, NoLabel = false, Math = false, Unit = \GraphUnit, MinSize = \VertexInterMinSize, TextColor = \VertexTextColor, LineColor = \VertexLineColor, FillColor = \VertexLightFillColor, LineWidth = \VertexLineWidth, InnerSep = \VertexInnerSep, OuterSep = \VertexOuterSep}{} %<---------------------------------------------------------------------------> % SetUpVertex %<---------------------------------------------------------------------------> \newcommand*{\SetUpVertex}[1][]{\GR@SetUpVertex[#1]}% \def\GR@SetUpVertex[#1]{% \setkeys[GR]{SUV}{#1}% \presetkeys [GR] {vertex} {Lpos = \cmdGR@SUV@Lpos, Ldist = \cmdGR@SUV@Ldist, style = \cmdGR@SUV@Style, unit = \cmdGR@SUV@Unit}{}% \tikzset{VertexStyle/.append style = {inner sep = \cmdGR@SUV@InnerSep, outer sep = \cmdGR@SUV@OuterSep, minimum size = \cmdGR@SUV@MinSize, text = \cmdGR@SUV@TextColor, color = \cmdGR@SUV@LineColor, fill = \cmdGR@SUV@FillColor, line width = \cmdGR@SUV@LineWidth}} \ifGR@SUV@NoLabel% \presetkeys [GR] {vertex} {NoLabel = true}{}% \fi% \ifGR@SUV@LabelOut% \presetkeys [GR] {vertex} {LabelOut = true}{}% \fi% \ifGR@SUV@Math% \presetkeys [GR] {vertex} {Math = true}{}% \fi% } %<---------------------------------------------------------------------------> % Init Vertex %<---------------------------------------------------------------------------> \define@boolkey [GR] {vertex} {empty}[true]{} \define@cmdkey [GR] {vertex} {unit}{} \define@cmdkey [GR] {vertex} {x}{} \define@cmdkey [GR] {vertex} {y}{} \define@cmdkey [GR] {vertex} {a}{} \define@cmdkey [GR] {vertex} {d}{} \define@boolkey [GR] {vertex} {Node}[true]{} \define@cmdkey [GR] {vertex} {dir}{} \define@cmdkey [GR] {vertex} {style}{} \define@cmdkey [GR] {vertex} {position}{} \define@cmdkey [GR] {vertex} {L}{} \define@cmdkey [GR] {vertex} {Lpos}{} \define@cmdkey [GR] {vertex} {Ldist}{} \define@boolkey [GR] {vertex} {NoLabel}[true]{} \define@boolkey [GR] {vertex} {Math}[true]{} \define@boolkey [GR] {vertex} {LabelOut}[true]{} \presetkeys [GR] {vertex} {Node = false, NoLabel = false, LabelOut = false, empty = false, Math = false, x = {}, y = {}, a = {}, d = {}, unit = \GraphUnit, dir = \EA, position = {}, style = {}, L = {}, Ldist = 0cm, Lpos = 0}{} %<---------------------------------------------------------------------------> % Vertex %<---------------------------------------------------------------------------> \newcommand*{\Vertex}[1][]{\@vertex[#1]}% \def\@vertex[#1]#2{% \setkeys[GR]{vertex}{#1}% \@@vertex{#2}% } % coord rect todo coord polar and pos relative \def\@@vertex#1{% \def\nstyle{VertexStyle} %<---------------------------------------------------------------------------> \ifGR@vertex@Node% \pgfextractx{\pgf@x}{\pgfpointanchor{#1}{center}} \pgfextracty{\pgf@y}{\pgfpointanchor{#1}{center}} \edef\cmdGR@vertex@x{\pgf@x} \edef\cmdGR@vertex@y{\pgf@y} \fi% %<---------------------------------------------------------------------------> \ifGR@vertex@empty% \begin{scope} \ifthenelse{\not\equal{\cmdGR@vertex@x}{}}{% \protected@edef\@tempa{% \noexpand\node[inner sep = 0pt](#1)% at (\cmdGR@vertex@x,\cmdGR@vertex@y){}}% \@tempa;}{% \ifthenelse{\not\equal{\cmdGR@vertex@d}{}}{% \protected@edef\@tempa{% \noexpand\node[inner sep = 0pt](#1)% at (\cmdGR@vertex@a:\cmdGR@vertex@d){}}% \@tempa;}{% \protected@edef\@tempa{% \noexpand \node[inner sep = 0pt](#1)% [\cmdGR@vertex@position]{}}% \@tempa;}}% \end{scope} \else \begin{scope}[label distance = \cmdGR@vertex@Ldist] \ifGR@vertex@NoLabel \def\vertex@Label{}% \def\cmdGR@vertex@L{}% \def\vertex@Name{} \else% \ifGR@vertex@Math \ifthenelse{\equal{\cmdGR@vertex@L}{}}{% \def\vertex@Name{$#1$}}{\def\vertex@Name{$\cmdGR@vertex@L$}} \else \ifthenelse{\equal{\cmdGR@vertex@L}{}}{% \def\vertex@Name{#1}}{\def\vertex@Name{\cmdGR@vertex@L}} \fi% \ifGR@vertex@LabelOut% \def\nstyle{VertexStyle,% label={[text = \cmdGR@SVN@TextColor,\cmdGR@vertex@style]% \cmdGR@vertex@Lpos:\vertex@Name}} \def\vertex@Label{} \else% \def\vertex@Label{\vertex@Name} \fi \fi %<---------------------------------------------------------------------------> \ifthenelse{\not\equal{\cmdGR@vertex@x}{}}{% \protected@edef\@tempa{% \noexpand\node[outer sep=0pt,\cmdGR@vertex@style,\nstyle](#1) at (\cmdGR@vertex@x,\cmdGR@vertex@y){% \noexpand\vertex@Label}}% \@tempa;% }{% \ifthenelse{\not\equal{\cmdGR@vertex@d}{}}{% \protected@edef\@tempa{% \noexpand\node[outer sep=0pt,\cmdGR@vertex@style,\nstyle](#1) at (\cmdGR@vertex@a:\cmdGR@vertex@d){% \noexpand\vertex@Label}}% \@tempa;% }{% \protected@edef\@tempa{% \noexpand\node[outer sep=0pt,\cmdGR@vertex@style,\nstyle](#1)% [\cmdGR@vertex@position]{% \noexpand\vertex@Label}}% \@tempa;}}% \end{scope} \fi% } %<---------------------------------------------------------------------------> % End of Vertex %<---------------------------------------------------------------------------> % EA east of #2 %<---------------------------------------------------------------------------> \newcommand*{\EA}[1][]{\@droite[#1]}% \def\@droite[#1](#2)#3{% \begingroup% \setkeys[GR]{vertex}{#1}% \path (#2)--++(\cmdGR@vertex@unit,0) coordinate (#3); \Vertex[#1,Node]{#3} \endgroup% }% %<---------------------------------------------------------------------------> % WE west of #2 %<---------------------------------------------------------------------------> \newcommand*{\WE}[1][]{\@gauche[#1]}% \def\@gauche[#1](#2)#3{% \begingroup% \setkeys[GR]{vertex}{#1}% \path (#2)--++(-\cmdGR@vertex@unit,0) coordinate (#3); \Vertex[#1,Node]{#3} \endgroup% } %<---------------------------------------------------------------------------> % NO north of #2 %<---------------------------------------------------------------------------> \newcommand*{\NO}[1][]{\@haut[#1]}% \def\@haut[#1](#2)#3{% \begingroup% \setkeys[GR]{vertex}{#1}% \path (#2)--++(0,\cmdGR@vertex@unit) coordinate (#3); \Vertex[#1,Node]{#3} \endgroup% } %<---------------------------------------------------------------------------> % SO south of #2 %<---------------------------------------------------------------------------> \newcommand*{\SO}[1][]{\@bas[#1]}% \def\@bas[#1](#2)#3{% \begingroup% \setkeys[GR]{vertex}{#1}% \path (#2)--++(0,-\cmdGR@vertex@unit) coordinate (#3); \Vertex[#1,Node]{#3} \endgroup% } %<---------------------------------------------------------------------------> % NOEA north east of #2 %<---------------------------------------------------------------------------> \newcommand*{\NOEA}[1][]{\@hautdroite[#1]}% \def\@hautdroite[#1](#2)#3{% \begingroup% \setkeys[GR]{vertex}{#1}% \path (#2)--++(\cmdGR@vertex@unit,\cmdGR@vertex@unit) coordinate (#3); \Vertex[#1,Node]{#3} \endgroup% } %<---------------------------------------------------------------------------> % NOWE north west of #2 %<---------------------------------------------------------------------------> \newcommand*{\NOWE}[1][]{\@hautgauche[#1]}% \def\@hautgauche[#1](#2)#3{% \begingroup% \setkeys[GR]{vertex}{#1}% \path (#2)--++(-\cmdGR@vertex@unit,\cmdGR@vertex@unit) coordinate (#3); \Vertex[#1,Node]{#3} \endgroup% } %<---------------------------------------------------------------------------> % SOEA south east of #2 %<---------------------------------------------------------------------------> \newcommand*{\SOEA}[1][]{\@basdroite[#1]}% \def\@basdroite[#1](#2)#3{% \begingroup% \setkeys[GR]{vertex}{#1}% \path (#2)--++(\cmdGR@vertex@unit,-\cmdGR@vertex@unit) coordinate (#3); \Vertex[#1,Node]{#3} \endgroup% } %<---------------------------------------------------------------------------> % SOWE south west of #2 %<---------------------------------------------------------------------------> \newcommand*{\SOWE}[1][]{\@basgauche[#1]}% \def\@basgauche[#1](#2)#3{% \begingroup% \setkeys[GR]{vertex}{#1}% \path (#2)--++(-\cmdGR@vertex@unit,-\cmdGR@vertex@unit) coordinate (#3); \Vertex[#1,Node]{#3} \endgroup% } %<---------------------------------------------------------------------------> % Vertices %<---------------------------------------------------------------------------> \newcommand*{\Vertices}[1][]{\Vertices@NoStar[#1]}% \def\Vertices@NoStar[#1]#2#3{% \setkeys[GR]{vertex}{#1}% \begingroup% \setcounter{tkz@gr@p}{0} \@for\liste:=#3\do{% \stepcounter{tkz@gr@p}% \global\expandafter\let\csname label@\alph{tkz@gr@p}\endcsname\liste} \ifthenelse{\equal{#2}{line}}{% \setcounter{tkz@gr@p}{0} \foreach \fin in {#3}{% \ifthenelse{\value{tkz@gr@p}=0}{% \global\let\deb\fin \Vertex[#1]{\fin} \stepcounter{tkz@gr@p} }{% \cmdGR@vertex@dir[#1,x={},y={},a={},d={},Node=false](\deb){\fin} \global\let\deb\fin } }% }{ \ifthenelse{\equal{#2}{square}}{% \begin{scope}[rotate=45] \Vertex[#1,Lpos=-135]{\label@a} \EA[#1,Lpos=-45,x={},y={},Node=false](\label@a){\label@b} \NO[#1,Lpos=45, x={},y={},Node=false](\label@b){\label@c} \WE[#1,Lpos=135,x={},y={},Node=false](\label@c){\label@d} \end{scope} }{% \ifthenelse{\equal{#2}{tr1}}{% \Vertex[#1]{\label@a} \EA[#1,x={},y={},Node=false](\label@a){\label@b} \NO[#1,x={},y={},Node=false](\label@b){\label@c}}{% \ifthenelse{\equal{#2}{tr2}}{% \Vertex[#1]{\label@a} \NO[#1,x={},y={},Node=false](\label@a){\label@b} \EA[#1,x={},y={},Node=false](\label@b){\label@c}}{% \ifthenelse{\equal{#2}{tr3}}{% \Vertex[#1]{\label@a} \NO[#1,x={},y={},Node=false](\label@a){\label@b} \WE[#1,x={},y={},Node=false](\label@b){\label@c}}{% \ifthenelse{\equal{#2}{tr4}}{% \Vertex[#1]{\label@a} \WE[#1,x={},y={},Node=false](\label@a){\label@b} \NO[#1,x={},y={},Node=false](\label@b){\label@c}}{% \ifthenelse{\equal{#2}{circle}}{% \pgfmathdivide{360}{\value{tkz@gr@p}}% \global\let\gr@angle\pgfmathresult% \setcounter{tkz@gr@p}{0} \foreach \lab in {#3}{% \pgfmathmultiply{\gr@angle}{\thetkz@gr@p}% \let\gr@newangle\pgfmathresult% \pgfmathadd{\cmdGR@vertex@Lpos}{\gr@newangle} \let\gr@posangle\pgfmathresult% \Vertex[#1, a = \gr@newangle, d = \cmdGR@vertex@unit, Lpos = \gr@posangle]{\lab} \stepcounter{tkz@gr@p}% }% }{}% }}}}}}% \endgroup% } %<---------------------------------------------------------------------------> % Edge style %<---------------------------------------------------------------------------> \tikzset{LabelStyle/.style={}}% add 03/04/2009 \tikzset{EdgeStyle/.style={}} %<---------------------------------------------------------------------------> % Init SetUpEdge %<---------------------------------------------------------------------------> \define@cmdkey [GR] {SUE} {color}{} \define@cmdkey [GR] {SUE} {label}{} \define@cmdkey [GR] {SUE} {labelstyle}{} \define@cmdkey [GR] {SUE} {labeltext}{} \define@cmdkey [GR] {SUE} {labelcolor}{} \define@cmdkey [GR] {SUE} {style}{} \define@cmdkey [GR] {SUE} {lw}{} \presetkeys [GR] {SUE} {color = \EdgeColor, lw = \EdgeLineWidth, label = {}, labeltext = \LabelTextColor, labelcolor = \LabelFillColor, labelstyle = {}, style = {}}{} %<---------------------------------------------------------------------------> % SetUpEdge %<---------------------------------------------------------------------------> \newcommand*{\SetUpEdge}[1][]{\@SetUpEdge[#1]}% \def\@SetUpEdge[#1]{% \setkeys [GR] {SUE} {#1}% \presetkeys [GR] {edge} {color = \cmdGR@SUE@color, lw = \cmdGR@SUE@lw, label = \cmdGR@SUE@label, labeltext = \cmdGR@SUE@labeltext, labelcolor = \cmdGR@SUE@labelcolor, labelstyle = \cmdGR@SUE@labelstyle, style = \cmdGR@SUE@style}{} \tikzset{LabelStyle/.style={}} \tikzset{EdgeStyle/.style={}}} \newcommand*{\DisableEdgeStyle}{\tikzset{EdgeStyle/.style={}}} %<---------------------------------------------------------------------------> % Init Edge %<---------------------------------------------------------------------------> \define@cmdkey [GR] {edge} {color}{} \define@cmdkey [GR] {edge} {lw}{} \define@cmdkey [GR] {edge} {double}{} \define@cmdkey [GR] {edge} {incolor}{} \define@cmdkey [GR] {edge} {dd}{} \define@cmdkey [GR] {edge} {style}{} \define@cmdkey [GR] {edge} {label}{} \define@cmdkey [GR] {edge} {labeltext}{} \define@cmdkey [GR] {edge} {labelcolor}{} \define@cmdkey [GR] {edge} {labelstyle}{} \define@boolkey[GR] {edge} {local}[true]{} \presetkeys [GR] {edge} {style = {pos=.5}, lw = \EdgeLineWidth, label = {}, labeltext = \LabelTextColor, labelcolor = \LabelFillColor, labelstyle = {}, local = false, double = {}, dd = \EdgeDoubleDistance, incolor = \EdgeFillColor, color = \EdgeColor}{} %<---------------------------------------------------------------------------> % Edge %<---------------------------------------------------------------------------> \newcommand*{\Edge}[1][]{\@edge[#1]}% \def\@edge[#1](#2)(#3){% \setkeys[GR]{edge}{#1}% \begingroup% \ifthenelse{\equal{\cmdGR@edge@double}{}}{% \tikzset{LocalEdgeStyle/.style={color = \cmdGR@edge@color, line width = \cmdGR@edge@lw}}}{% \tikzset{LocalEdgeStyle/.style={line width = \cmdGR@edge@dd, color = \cmdGR@edge@double, double distance = \cmdGR@edge@lw, double = \cmdGR@edge@color}}}% \ifGR@edge@local% \tikzset{EdgeStyle/.style={}}% \fi \ifthenelse{\equal{\cmdGR@edge@label}{}}{% \protected@edef\@tempa{% \noexpand \draw[LocalEdgeStyle,\cmdGR@edge@style,EdgeStyle]}% \@tempa (#2) to (#3)}{% \protected@edef\@tempa{% \noexpand \draw[LocalEdgeStyle,\cmdGR@edge@style,EdgeStyle] (#2) to% node[fill = \cmdGR@edge@labelcolor, text = \cmdGR@edge@labeltext, \cmdGR@edge@labelstyle,LabelStyle]}\@tempa {\cmdGR@edge@label} (#3)}% ; \endgroup% }% %<---------------------------------------------------------------------------> % Edges %<---------------------------------------------------------------------------> \newcommand*{\Edges}[1][]{\@edges[#1]}% \def\@edges[#1](#2){% \setkeys[GR]{edge}{#1}% \begingroup% \setcounter{tkz@gr@p}{0} \foreach \fin in {#2}{% \ifthenelse{\value{tkz@gr@p}=0}{% \global\let\deb\fin \stepcounter{tkz@gr@p}}{% \Edge[#1](\deb)(\fin) \global\let\deb\fin }% } \endgroup% }% %<---------------------------------------------------------------------------> % Init loop %<---------------------------------------------------------------------------> \define@choicekey*[GR]{loop}{dir}[\val\nr]{WE,EA,NO,SO,NOWE,NOEA,SOWE,SOEA}{% \ifcase\nr\relax \tikzset{LoopStyle/.style = {in=225, out=135, distance=\cmdGR@loop@dist}}% \or \tikzset{LoopStyle/.style = {in= 45, out=-45, distance=\cmdGR@loop@dist}}% \or \tikzset{LoopStyle/.style = {in=135, out= 45, distance=\cmdGR@loop@dist}}% \or \tikzset{LoopStyle/.style = {in=-45, out=-135, distance=\cmdGR@loop@dist}}% \or \tikzset{LoopStyle/.style = {in=180, out=90, distance=\cmdGR@loop@dist}}% \or \tikzset{LoopStyle/.style = {in=90, out=0, distance=\cmdGR@loop@dist}}% \or \tikzset{LoopStyle/.style = {in=-90, out=-180, distance=\cmdGR@loop@dist}}% \or \tikzset{LoopStyle/.style = {in=0, out=-90, distance=\cmdGR@loop@dist}}% \fi% } \define@cmdkey [GR] {loop} {color}{} \define@cmdkey [GR] {loop} {label}{} \define@cmdkey [GR] {loop} {labelstyle}{} \define@cmdkey [GR] {loop} {style}{} \define@cmdkey [GR] {loop} {dist}{} \presetkeys [GR] {loop} {style = {pre,thick},%` label = {},% labelstyle = {},% color = \tkz@suc@txt,% dist = 4cm,% dir = WE}{} %<---------------------------------------------------------------------------> % loop %<---------------------------------------------------------------------------> \newcommand*{\grLoop}[1][]{\tkzGR@loop[#1]}% \def\tkzGR@loop[#1](#2){% \setkeys[GR]{loop}{#1}% \protected@edef\@tempa{% \noexpand \draw[\cmdGR@loop@color] (#2)% edge [EdgeStyle,LoopStyle,\cmdGR@loop@style]% node [LabelStyle,\cmdGR@loop@labelstyle]% {\cmdGR@loop@label} (#2)}\@tempa;% }% %<---------------------------------------------------------------------------> % Init Graphes probabilistes %<---------------------------------------------------------------------------> \define@cmdkey [GR] {grpb} {unit}{} \define@cmdkey [GR] {grpb} {LposA}{} \define@cmdkey [GR] {grpb} {LposB}{} \define@cmdkey [GR] {grpb} {Ldist}{} \define@cmdkey [GR] {grpb} {LoopDist}{} \presetkeys [GR] {grpb} {LposA = 180,% LposB = 0,% Ldist = 0cm,% LoopDist = 4cm, unit = 4}{} %<---------------------------------------------------------------------------> % Graphes probabilistes %<---------------------------------------------------------------------------> \newcommand*{\grProb}[7][]{% \setkeys[GR]{grpb}{#1}% \tikzset{LabelStyle/.append style ={pos=.5}} \Vertex[Lpos=\cmdGR@grpb@LposA,Ldist=\cmdGR@grpb@Ldist,L=#2]{grA} \EA[unit=\cmdGR@grpb@unit,Lpos=\cmdGR@grpb@LposB, Ldist=\cmdGR@grpb@Ldist,L=#3](grA){grB} \Edge[style={post,bend left=60},label={$#4$},labelstyle={above}](grA)(grB) \Edge[style={post,bend left=60},label={$#5$},labelstyle={below}](grB)(grA) \grLoop[dist=\cmdGR@grpb@LoopDist,dir=WE,label={$#6$},labelstyle={left}](grA) \grLoop[dist=\cmdGR@grpb@LoopDist,dir=EA,label={$#7$},labelstyle={right}](grB) }% \newcommand*{\grProbThree}[7][]{% \setkeys[GR]{grpb}{#1}% \begin{scope}[] \tikzset{LabelStyle/.append style ={pos=.5}} \Vertices[empty,unit=\cmdGR@grpb@unit]{circle}{grA,grB,grC} \Vertex[Node,Lpos=\cmdGR@grpb@LposA,Ldist=\cmdGR@grpb@Ldist,L=#2]{grA} \Vertex[Node,Lpos=\cmdGR@grpb@LposA,Ldist=\cmdGR@grpb@Ldist,L=#3]{grB} \Vertex[Node,Lpos=\cmdGR@grpb@LposA,Ldist=\cmdGR@grpb@Ldist,L=#4]{grC} \foreach \x/\y/\z in {#5} {% \grLoop[dist=\cmdGR@grpb@LoopDist,dir=EA,label={$\x$}](grA) \Edge[style={post,bend right=20},label={$\y$}](grA)(grB) \Edge[style={post,bend right=20},label={$\z$}](grA)(grC)} \foreach \x/\y/\z in {#6} {% \grLoop[dist=\cmdGR@grpb@LoopDist,dir=NO,label={$\x$}](grB) \Edge[style={post,bend right=20},label={$\y$}](grB)(grA) \Edge[style={post,bend right=20},label={$\z$}](grB)(grC)} \foreach \x/\y/\z in {#7} {% \grLoop[dist=\cmdGR@grpb@LoopDist,dir=SO,label={$\x$}](grC) \Edge[style={post,bend right=20},label={$\y$}](grC)(grA) \Edge[style={post,bend right=20},label={$\z$}](grC)(grB)} \end{scope} } %<---------------------------------------------------------------------------> % End Graphes probabilistes %<---------------------------------------------------------------------------> \let\Loop\grLoop \newcommand{\SetVertexLabeledSmall}{% \SetVertexLabel% \tikzset{VertexStyle/.style = {draw, shape = circle, inner sep = 1pt, minimum size = 10pt}} \tikzset{EdgeStyle/.style = {double = \tkz@suc@txt, double distance = 1pt, color = \tkz@suc@bkc, line width = 0.7pt}} } \newcommand{\SetVertexNotLabeledSmall}{% \tikzset{EdgeStyle/.style = {double = \tkz@suc@txt, double distance = 1pt, color = \tkz@suc@bkc, line width = 0.7pt}} \SetVertexNoLabel \SetVertexSimple[MinSize=6pt,FillColor=gray] \renewcommand*{\VertexLineWidth}{0pt} }% \newcommand{\SetVertexForPresentation}[3]{% \GraphInit[vstyle=Shade] \SetVertexNoLabel \renewcommand*{\VertexBigMinSize}{12pt}% \renewcommand*{\EdgeDoubleDistance}{2pt}% \renewcommand*{\EdgeLineWidth}{0.7pt}% \SetGraphShadeColor{#1}{#2}{#3} }% \newcommand{\setxyzvec}[1][20]{% \pgfmathsetmacro{\xone}{cos(180+#1)}% \pgfmathsetmacro{\yone}{sin(180+#1)}% \pgfmathsetmacro{\xtwo}{cos(360-#1)}% \pgfmathsetmacro{\ytwo}{sin(360-#1)}% \pgfsetxvec{\pgfpoint{\xone cm}{\yone cm}}% \pgfsetyvec{\pgfpoint{\xtwo cm}{\ytwo cm}}% \pgfsetzvec{\pgfpoint{0cm}{1cm}}% } \endinput