From 00435300a2dfff579421628dba7fcc6a234a2236 Mon Sep 17 00:00:00 2001 From: Stefan Pinnow Date: Sat, 30 May 2020 13:09:04 +0200 Subject: [PATCH 01/14] - adapted formatting in `pgf/text-en/pgfmanual-en-tikz-matrices.tex` - changed order of mentioned libraries so they fit the order of references in the next sentence in `pgf/text-en/pgfmanual-en-tikz-shapes.tex` --- .../text-en/pgfmanual-en-tikz-matrices.tex | 28 +++++++++---------- .../pgf/text-en/pgfmanual-en-tikz-shapes.tex | 4 +-- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/doc/generic/pgf/text-en/pgfmanual-en-tikz-matrices.tex b/doc/generic/pgf/text-en/pgfmanual-en-tikz-matrices.tex index 817043469..6b4943e47 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-tikz-matrices.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-tikz-matrices.tex @@ -413,7 +413,7 @@ \subsubsection{Cell Styles and Options} columns, or cells. If more than one of these styles is defined, they are executed in the below order (the |every cell| style is executed before all of the below). - % +% \begin{stylekey}{/tikz/column \meta{number}} This style is used for every cell in column \meta{number}. \end{stylekey} @@ -501,9 +501,9 @@ \subsubsection{Cell Styles and Options} \end{stylekey} \begin{stylekey}{/tikz/matrix/inner style order} - The order in which these styles are applied to the matrix cells is specified - by this key. By default it is - % + The order in which these styles are applied to the matrix cells is + specified by this key. By default it is + % \begin{codeexample}[code only] \tikzset{ matrix/inner style order={ @@ -512,16 +512,16 @@ \subsubsection{Cell Styles and Options} even odd column, row, even odd row, - this cell + this cell, } } \end{codeexample} - % - You can use this to install your own styles here, but only \emph{names} of - styles are permitted here. The style specification has to be placed - outside of |matrix/inner style order| and unless it is installed inside - |/tikz/matrix/inner style/|, it has to be fully qualified. - % + % + You can use this to install your own styles here, but only \emph{names} of + styles are permitted here. The style specification has to be placed + outside of |matrix/inner style order| and unless it is installed inside + |/tikz/matrix/inner style/|, it has to be fully qualified. + % \begin{codeexample}[code only] \tikzset{ my style/.code={% @@ -536,11 +536,11 @@ \subsubsection{Cell Styles and Options} column, row, this cell, - /tikz/my style - } + /tikz/my style, + }, } \end{codeexample} - % + % \end{stylekey} In many matrices all cell pictures have nearly the same code. For example, diff --git a/doc/generic/pgf/text-en/pgfmanual-en-tikz-shapes.tex b/doc/generic/pgf/text-en/pgfmanual-en-tikz-shapes.tex index 5d2e4a7a0..e0767928e 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-tikz-shapes.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-tikz-shapes.tex @@ -1708,11 +1708,11 @@ \subsubsection{Advanced Placement Options} \end{key} -\subsubsection{Advanced Arrangements of Nodes} +\subsubsection{Advanced Arrangements of Nodes} The simple |above| and |right| options may not always suffice for arranging a large number of nodes. For such situations \tikzname\ offers libraries that -make positioning easier: The |graphdrawing| library and the |matrix| library. +make positioning easier: The |matrix| library and the |graphdrawing| library. These libraries for positioning nodes are described in two separate Sections~\ref{section-matrices} and~\ref{section-intro-gd}. From cd43c1e3a18e7e0c712f8764b86d64f0ed7626d4 Mon Sep 17 00:00:00 2001 From: Stefan Pinnow Date: Sat, 30 May 2020 13:43:06 +0200 Subject: [PATCH 02/14] - adapted formatting in `pgfmanual-en-library-bbox.tex` and fixed a typo --- .../pgf/text-en/pgfmanual-en-library-bbox.tex | 218 +++++++++--------- 1 file changed, 112 insertions(+), 106 deletions(-) diff --git a/doc/generic/pgf/text-en/pgfmanual-en-library-bbox.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-bbox.tex index c0c1ef9ec..32de19592 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-bbox.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-bbox.tex @@ -7,158 +7,164 @@ % % See the file doc/generic/pgf/licenses/LICENSE for more details. -\section{Bounding Boxes for B\'ezier Curves} - +\section{Bounding Boxes for Bézier Curves} \begin{pgflibrary}{bbox} This library provides methods to determine tight bounding boxes for - B\'ezier curves. This library loads and uses the - |fpu| library. + Bézier curves. This library loads and uses the |fpu| library. \end{pgflibrary} -\subsection{Bounding box without the library} -\tikzname\ determines the bounding box of (cubic) Bezier curves by establishing the -smallest rectangle that contains the end point and the two control points of the -curve. +\subsection{Bounding box without the library} +\tikzname{} determines the bounding box of (cubic) Bézier curves by +establishing the smallest rectangle that contains the end point and the two +control points of the curve. +% \begin{codeexample}[width=5cm] -\begin{tikzpicture}[% - bullet/.style={circle,fill, - inner sep=1pt}] - \draw (0,0) .. controls (-1,1) - and (1,2) .. (2,0); - \draw (current bounding box.south west) - rectangle - (current bounding box.north east); - \draw[red,dashed] - (0,0) -- (-1,1) - node[bullet,label=above:{$(x_a,y_a)$}]{} - (2,0) -- (1,2) - node[bullet,label=above:{$(x_b,y_b)$}]{}; - \path (0,0) - node[bullet,label=below:{$(x_0,y_0)$}]{} - (2,0) - node[bullet,label=below:{$(x_1,y_1)$}]{}; +\begin{tikzpicture}[ + bullet/.style={circle,fill,inner sep=1pt}, +] + \draw (0,0) .. controls (-1,1) and (1,2) .. (2,0); + \draw (current bounding box.south west) + rectangle (current bounding box.north east); + \draw[red,dashed] + (0,0) -- (-1,1) node[bullet,label=above:{$(x_a,y_a)$}]{} + (2,0) -- ( 1,2) node[bullet,label=above:{$(x_b,y_b)$}]{}; + \path + (0,0) node[bullet,label=below:{$(x_0,y_0)$}]{} + (2,0) node[bullet,label=below:{$(x_1,y_1)$}]{}; \end{tikzpicture} \end{codeexample} As one can see from this illustration, this may lead to drastic overestimates of the bounding box. + \subsection{Computing the bounding box} Establishing the precise bounding box has been discussed in various places, the following discussion uses in part the results from -\url{https://pomax.github.io/bezierinfo/}. What is a cubic Bezier curve? A -cubic Bezier curve running from $(x_0,y_0)$ to $(x_1,y_1)$ with control points -$(x_a,y_a)$ and $(x_b,y_b)$ can be parametrized by -\begin{equation} - \gamma(t)~=~ - \begin{pmatrix} x(t)\\ y(t) \end{pmatrix}~=~ - \begin{pmatrix}t^3 x_{1}+3 t^2 (1-t) x_{b}+(1-t)^3 - x_{0}+3 t (1-t)^2 x_{a}\\ - t^3 y_{1}+3 - t^2 (1-t) y_{b}+(1-t)^3 y_{0}+3 t (1-t)^2 - y_{a}\end{pmatrix}\;,\label{eq:gammaBezier} -\end{equation} -where $t$ runs from 0 to 1 (and $\gamma(0)=(x_0,y_0)$ and -$\gamma(1)=(x_1,y_1)$). Surely, the bounding box has to contain -$(x_0,y_0)$ and $(x_1,y_1)$. If the functions $x(t)$ and $y(t)$ have extrema in -the interval $[0,1]$, then the bounding box will in general be larger than that. -In order to determine the extrema of the curve, all -we need to find the extrema of the functions $x(t)$ and $y(t)$ for $0\le t\le -1$. That is, we need to find the solutions of the quadratic equations -\begin{equation} - \frac{\mathrm{d}x}{\mathrm{d}t}(t)~=~0\quad\text{and}\quad - \frac{\mathrm{d}y}{\mathrm{d}t}(t)~=~0\;. -\end{equation} +\url{https://pomax.github.io/bezierinfo/}. What is a cubic Bézier curve? A +cubic Bézier curve running from $(x_0,y_0)$ to $(x_1,y_1)$ with control points +$(x_a,y_a)$ and $(x_b,y_b)$ can be parameterized by +% + \begin{equation} + \label{eq:gammaBezier} + \gamma(t) = + \begin{pmatrix} + x(t) \\ y(t) + \end{pmatrix} + = + \begin{pmatrix} + t^3 x_{1} + 3 t^2 (1-t) x_{b} + (1-t)^3 x_{0} + 3 t (1-t)^2 x_{a} \\ + t^3 y_{1} + 3 t^2 (1-t) y_{b} + (1-t)^3 y_{0} + 3 t (1-t)^2 y_{a} + \end{pmatrix} + \;, + \end{equation} +% +where $t$ runs from 0 to 1 (and $\gamma(0) = (x_0,y_0)$ and $\gamma(1) = +(x_1,y_1)$). Surely, the bounding box has to contain $(x_0,y_0)$ and +$(x_1,y_1)$. If the functions $x(t)$ and $y(t)$ have extrema in the interval +$[0,1]$, then the bounding box will in general be larger than that. In order to +determine the extrema of the curve, all we need to find the extrema of the +functions $x(t)$ and $y(t)$ for $0 \le t \le 1$. That is, we need to find the +solutions of the quadratic equations +% + \begin{equation} + \frac{\mathrm{d}x}{\mathrm{d}t}(t) = 0 + \quad\text{and}\quad + \frac{\mathrm{d}y}{\mathrm{d}t}(t) = 0 \;. + \end{equation} +% % (*parametrization of x:*) -% myx = x0 (1 - t)^3 + 3 xa (1 - t)^2 t + 3 xb (1 - t) t^2 + x1 t^3 +% myx = x0 (1 - t)^3 + 3 xa (1 - t)^2 t + 3 xb (1 - t) t^2 + x1 t^3 % (*d1\ne0 condition for t1 and t2 to exist*) -% === (*case d1\ne0*) == +% === (*case d1\ne0*) == % d1 = x0 - x1 - 3 xa + 3 xb % (*square root, d2=0 \[Rule] only one solution,d2<0 \[Rule] no solution*) -% d2 = x0*x1 - x1*xa + xa*xa - x0*xb - xa xb + xb*xb +% d2 = x0*x1 - x1*xa + xa*xa - x0*xb - xa xb + xb*xb % (*first t*) % t1 = (x0 - 2*xa + xb - sqrt(d2))/(x0 - x1 - 3*xa + 3*xb) % = (x0 - 2*xa + xb - sqrt(d2))/d1 % (*second t*) % t2 = (x0 - 2*xa + xb + sqrt(d2))/(x0 - x1 - 3*xa + 3*xb) % = (x0 - 2*xa + xb + sqrt(d2))/d1 -% === (*case d1=0*) == +% === (*case d1=0*) == % (*2nd condition for extra condition: d3\ne0*) % d3 = x1 + xa - 2 xb % (*third t*) % t3 = (x1 + 2*xa - 3*xb)/(2*d3)% d3 = x1 + 3 xa - 3 xb - x0 +% Let's discuss $x$ first. If the discriminant -\begin{equation} - d~:=~x_0\,x_1 - x_1\,x_a + x_a\,x_a - x_0\,x_b - x_a x_b + x_b\,x_b -\end{equation} +% + \begin{equation} + d := x_0\,x_1 - x_1\,x_a + x_a\,x_a - x_0\,x_b - x_a x_b + x_b\,x_b + \end{equation} +% is greater than 0, there are two solutions -\begin{equation} - t_\pm~=~\frac{x_{0}-2x_{a}+x_{b}\pm\sqrt{d}}{% - x_{0}-x_{1}-3(x_{a}- x_{b})} \;. -\end{equation} -If the denominator $x_{0}-x_{1}-3(x_{a}- x_{b})$ vanishes, one may use the -l'Hospital rule to determine the solutions. -In this case, we need to make sure that the bounding box contains, say -$(x(t_-),y_0)$ and $(x(t_+),y_0)$. If $d\le0$, the bounding box does not need to -be increased in the $x$ direction. On the other hand, if there are solutions, -one needs include the points $\bigl(x(t_\pm),y_0\bigr)$ with $x(t)$ from -\eqref{eq:gammaBezier} in the bounding box. - -The analogous statements apply to $y(t)$. +% + \begin{equation} + t_\pm = \frac{x_{0} - 2x_{a} + x_{b} + \pm \sqrt{d}}{x_{0} - x_{1} - 3(x_{a}- x_{b})} \;. + \end{equation} +% +If the denominator $x_{0} - x_{1} - 3(x_{a} - x_{b})$ vanishes, one may use the +l'Hospital rule to determine the solutions. In this case, we need to make sure +that the bounding box contains, say $(x(t_-),y_0)$ and $(x(t_+),y_0)$. If $d +\le 0$, the bounding box does not need to be increased in the $x$ direction. On +the other hand, if there are solutions, one needs include the points +$\bigl(x(t_\pm),y_0\bigr)$ with $x(t)$ from equation~\eqref{eq:gammaBezier} in +the bounding box. + +The analogous statements apply to $y(t)$. + \subsection{Using the library} \begin{key}{/pgf/bezier bounding box=\meta{boolean} (default true)} Turn the tight bounding box algorithm on and off. The initial value is - |false|. + |false|. - \emph{Caveat:} As can be seen from the derivations, the necessary - computations involve the squaring of lengths and taking ratios of lengths, - which can easily lead to |dimension too large| errors. The library uses - |fpu| to account for that, but errors may still occur. + \emph{Caveat:} As can be seen from the derivations, the necessary + computations involve the squaring of lengths and taking ratios of lengths, + which can easily lead to |dimension too large| errors. The library uses + |fpu| to account for that, but errors may still occur. \end{key} - -\begin{codeexample}[width=5cm] -\begin{tikzpicture}[bezier bounding box,% - bullet/.style={circle,fill, - inner sep=1pt}] - \draw (0,0) .. controls (-1,1) - and (1,2) .. (2,0); - \draw (current bounding box.south west) - rectangle - (current bounding box.north east); - \draw[red,dashed] - (0,0) -- (-1,1) - node[bullet,label=above:{$(x_a,y_a)$}]{} - (2,0) -- (1,2) - node[bullet,label=above:{$(x_b,y_b)$}]{}; - \path (0,0) - node[bullet,label=below:{$(x_0,y_0)$}]{} - (2,0) - node[bullet,label=below:{$(x_1,y_1)$}]{}; +\begin{codeexample}[width=5cm,preamble={\usetikzlibrary{bbox}}] +\begin{tikzpicture}[ + bezier bounding box, + bullet/.style={circle,fill,inner sep=1pt}, +] + \draw (0,0) .. controls (-1,1) and (1,2) .. (2,0); + \draw (current bounding box.south west) + rectangle (current bounding box.north east); + \draw[red,dashed] + (0,0) -- (-1,1) node[bullet,label=above:{$(x_a,y_a)$}]{} + (2,0) -- ( 1,2) node[bullet,label=above:{$(x_b,y_b)$}]{}; + \path + (0,0) node[bullet,label=below:{$(x_0,y_0)$}]{} + (2,0) node[bullet,label=below:{$(x_1,y_1)$}]{}; \end{tikzpicture} \end{codeexample} -A few comments are in order. +A few comments are in order. +% \begin{enumerate} -\item For paths with arrow heads one may need to load the - \texttt{bending} library. This is because otherwise the quick arrow head - distorts the path, and this happens after the bounding box has been computed. - Even worse, arrow heads could get deformed. -\item If you shorten a path by some negative length, the bounding box will not - be accurate either. However, this has nothing to do with curves, it also - applies to straight lines. So this is not specific to the |bbox| library but - something that one may want to keep in mind. -\item Let us also note that the computations can lead to |dimension too large| errors. - These errors do not come directly from the computations done by the library, - which uses |fpu| for its computations, but from the aftermath. Many of these - problems can be avoided by using the |fpu| library also for computing - reciprocals. + \item For paths with arrow heads one may need to load the |bending| + library. This is because otherwise the quick arrow head distorts the + path, and this happens after the bounding box has been computed. Even + worse, arrow heads could get deformed. + \item If you shorten a path by some negative length, the bounding box will + not be accurate either. However, this has nothing to do with curves, it + also applies to straight lines. So this is not specific to the |bbox| + library but something that one may want to keep in mind. + \item Let us also note that the computations can lead to + |dimension too large| errors. These errors do not come directly from + the computations done by the library, which uses |fpu| for its + computations, but from the aftermath. Many of these problems can be + avoided by using the |fpu| library also for computing reciprocals. \end{enumerate} \endinput From a094a64d0d7efb3935a3bf54a3df99f884ed2059 Mon Sep 17 00:00:00 2001 From: Stefan Pinnow Date: Mon, 1 Jun 2020 10:01:13 +0200 Subject: [PATCH 03/14] added reference from `matrix` library to "basic" matrix section --- doc/generic/pgf/text-en/pgfmanual-en-library-matrices.tex | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/generic/pgf/text-en/pgfmanual-en-library-matrices.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-matrices.tex index 53284b980..e6750d5a2 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-matrices.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-matrices.tex @@ -12,7 +12,8 @@ \section{Matrix Library} \begin{tikzlibrary}{matrix} This library package defines additional styles and options for creating - matrices. + matrices. (The basic matrix styles and options can be found in + Section~\ref{section-matrices}.) \end{tikzlibrary} From b4e5e33ecd90fd24d63b1ee87738cd255178cbda Mon Sep 17 00:00:00 2001 From: Stefan Pinnow Date: Fri, 5 Jun 2020 07:36:43 +0200 Subject: [PATCH 04/14] "improved" colors given in the `codeexample` of pull request #871 --- doc/generic/pgf/text-en/pgfmanual-en-tikz-matrices.tex | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/doc/generic/pgf/text-en/pgfmanual-en-tikz-matrices.tex b/doc/generic/pgf/text-en/pgfmanual-en-tikz-matrices.tex index 2229b5e69..41c1c4d49 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-tikz-matrices.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-tikz-matrices.tex @@ -485,7 +485,7 @@ \subsubsection{Cell Styles and Options} \begin{codeexample}[preamble={\usetikzlibrary{matrix,shapes.misc}}] \begin{tikzpicture} [mycol/.style={column #1/.append style={ - every even row/.style={nodes={fill=gray!10}}} + every even row/.style={nodes={fill=gray!20}}} }] \matrix [matrix of nodes, nodes in empty cells, @@ -494,11 +494,11 @@ \subsubsection{Cell Styles and Options} mycol/.list={1,...,5}, % add mycol style to all cols column 1/.style={ row 1 column 1/.style={nodes={fill=none, draw=none}}, - nodes={fill=yellow, chamfered rectangle, inner sep=0, + nodes={fill=yellow!75!black, chamfered rectangle, inner sep=0, chamfered rectangle corners={north west, south east}}, }, row 1/.style={nodes={text depth=0.2ex, text width=2cm, text=white}}, - column 2/.append style={row 1/.append style={nodes={fill=green}}}, + column 2/.append style={row 1/.append style={nodes={fill=green!75!black}}}, column 3/.append style={every even row/.style={nodes={fill=red!10}}, row 1 column 3/.append style={nodes={fill=red}} }, @@ -521,7 +521,6 @@ \subsubsection{Cell Styles and Options} \end{tikzpicture} \end{codeexample} - The order in which these styles are applied is configurable. You can also install your own styles. The following styles (in fact, internally they are |/.code| keys) wrap the styles introduced in the previous paragraph passing the From 4173bf68671d85efe1f423c5ed33342a2d29c425 Mon Sep 17 00:00:00 2001 From: Stefan Pinnow Date: Fri, 12 Jun 2020 15:26:54 +0200 Subject: [PATCH 05/14] added codeexample to `bbox` library manual as suggested in pull request #872 --- .../pgf/text-en/pgfmanual-en-library-bbox.tex | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/doc/generic/pgf/text-en/pgfmanual-en-library-bbox.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-bbox.tex index 32de19592..32775db55 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-bbox.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-bbox.tex @@ -128,7 +128,7 @@ \subsection{Using the library} \emph{Caveat:} As can be seen from the derivations, the necessary computations involve the squaring of lengths and taking ratios of lengths, - which can easily lead to |dimension too large| errors. The library uses + which can easily lead to |Dimension too large| errors. The library uses |fpu| to account for that, but errors may still occur. \end{key} @@ -161,10 +161,29 @@ \subsection{Using the library} also applies to straight lines. So this is not specific to the |bbox| library but something that one may want to keep in mind. \item Let us also note that the computations can lead to - |dimension too large| errors. These errors do not come directly from + |Dimension too large| errors. These errors do not come directly from the computations done by the library, which uses |fpu| for its computations, but from the aftermath. Many of these problems can be - avoided by using the |fpu| library also for computing reciprocals. + avoided by using the |fpu| library also for computing reciprocals as in + e.g. + % +\begin{codeexample}[preamble={\usetikzlibrary{bbox}}] +\begin{tikzpicture} + \pgfmathsetmacro{\rnda}{360*rnd} + \pgfmathsetmacro{\rndb}{360*rnd} + \pgfmathsetmacro{\rndc}{360*rnd} + \pgfmathsetmacro{\rndd}{3*rnd} + \pgfmathsetmacro{\rnde}{3*rnd} + \pgfmathsetmacro{\rndf}{3*rnd} + \begin{scope}[/pgf/fpu/install only={reciprocal},bezier bounding box=true] + \draw (0,0) .. controls (\rnda:\rndd) and (\rndb:\rnde) .. (\rndc:\rndf); + \end{scope} +\end{tikzpicture} +\end{codeexample} + % + Please note that this is done in a local scope. This is because + currently there is no reverse operation to uninstall these definitions + at the moment. \end{enumerate} \endinput From 286e2acea3646b99857ea77beef2bacc9881c303 Mon Sep 17 00:00:00 2001 From: Stefan Pinnow Date: Fri, 12 Jun 2020 15:28:34 +0200 Subject: [PATCH 06/14] removed braces as suggested in pull request #872 --- doc/generic/pgf/text-en/pgfmanual-en-library-matrices.tex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/generic/pgf/text-en/pgfmanual-en-library-matrices.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-matrices.tex index e6750d5a2..816464c0e 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-matrices.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-matrices.tex @@ -12,8 +12,8 @@ \section{Matrix Library} \begin{tikzlibrary}{matrix} This library package defines additional styles and options for creating - matrices. (The basic matrix styles and options can be found in - Section~\ref{section-matrices}.) + matrices. The basic matrix styles and options can be found in + Section~\ref{section-matrices}. \end{tikzlibrary} From 17b1c58531b80f16d6d372a3405313fd0fc56eb8 Mon Sep 17 00:00:00 2001 From: Stefan Pinnow Date: Fri, 12 Jun 2020 15:29:34 +0200 Subject: [PATCH 07/14] added `codeexample` plus some text to the `decorations` library manual as suggested in pull request #872 --- .../pgfmanual-en-library-decorations.tex | 22 +++++++++++++ .../pgf/text-en/pgfmanual-en-library-fpu.tex | 33 +++++++++++-------- 2 files changed, 41 insertions(+), 14 deletions(-) diff --git a/doc/generic/pgf/text-en/pgfmanual-en-library-decorations.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-decorations.tex index 1dea8b28a..929e645bf 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-decorations.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-decorations.tex @@ -106,6 +106,28 @@ \subsection{Overview and Common Options} \end{key} +\subsection{Handling ``Dimension too large error''s} + +In case you should run into a ``Dimension too large error'' when using the +|decorations| libraries, there is a pretty high chance that you can resolve +this by using the |fpu| library in combination with +|/pgf/fpu/install only={reciprocal}|. Please note that this key should only be +applied locally to avoid other errors (see also at the definition of this key +on page~\pageref{fpu-install-only}). +% +\begin{codeexample}[preamble={\usetikzlibrary{decorations.markings,fpu}}] +\begin{tikzpicture} + \begin{scope}[/pgf/fpu/install only={reciprocal}] + \draw[postaction=decorate,decoration={ + markings,mark=at position 0.52 with { + \draw circle[radius=2pt]; + }}, + ] plot[smooth,variable=\x,domain=-1:1] (\x*\x*\x,\x*\x); + \end{scope} +\end{tikzpicture} +\end{codeexample} + + \subsection{Path Morphing Decorations} \begin{pgflibrary}{decorations.pathmorphing} diff --git a/doc/generic/pgf/text-en/pgfmanual-en-library-fpu.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-fpu.tex index 186c83960..70ef7bf65 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-fpu.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-fpu.tex @@ -148,25 +148,30 @@ \subsection{Usage} \end{command} \begin{key}{/pgf/fpu/install only=\marg{list of names}} + \label{fpu-install-only} Unfortunately, the FPU is currently incompatible with drawing operations. However, it can still be useful to replace single definitions with FPU - counterparts to avoid errors of the kind |Dimension too large| which tend to - happen when transformation matrices are inverted. + counterparts to avoid errors of the kind |Dimension too large| which tend + to happen when transformation matrices are inverted. - This key allows to specify a list of definitions to be pulled into the current - scope. \emph{Note that there is no reverse operation to uninstall these - definitions at the moment}, so it is advisable to do this in a group. - Conveniently, \tikzname\ paths form an implicit group, so you can use this key - on a path as well. + This key allows to specify a list of definitions to be pulled into the + current scope. \emph{Note that there is no reverse operation to uninstall + these definitions at the moment}, so it is advisable to do this in a group. + Conveniently, \tikzname{} paths form an implicit group, so you can use this + key on a path as well. You have to be aware of the limitations that the FPU imposes. It will not - magically give TeX better precision, but it will avoid overflow or underflow - situation for large or small operands by rescaling them. In the following - example, in the first case the FPU variant performs much better than the - normal variant, however, in the second case where a rescaling would not in - fact be needed the rescaling introduces a small round-off error. - % -\begin{codeexample}[preamble={\usepgflibrary{fpu}},pre={\pgfkeys{/pgf/fpu=false}}] + magically give \TeX{} better precision, but it will avoid overflow or + underflow situation for large or small operands by rescaling them. In the + following example, in the first case the FPU variant performs much better + than the normal variant, however, in the second case where a rescaling + would not in fact be needed the rescaling introduces a small round-off + error. + % +\begin{codeexample}[ + preamble={\usepgflibrary{fpu}}, + pre={\pgfkeys{/pgf/fpu=false}}, +] \begingroup \pgfkeys{/pgf/fpu/install only={divide}} \pgfmathparse{12.34/0.001234}\pgfmathresult (good) From b555dd553a8174eb4b1b3451137e36e167cb5036 Mon Sep 17 00:00:00 2001 From: Mo-Gul Date: Sat, 13 Jun 2020 07:39:18 +0200 Subject: [PATCH 08/14] Update doc/generic/pgf/text-en/pgfmanual-en-library-decorations.tex Co-authored-by: Henri Menke --- doc/generic/pgf/text-en/pgfmanual-en-library-decorations.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/generic/pgf/text-en/pgfmanual-en-library-decorations.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-decorations.tex index 929e645bf..c0e6536fd 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-decorations.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-decorations.tex @@ -106,7 +106,7 @@ \subsection{Overview and Common Options} \end{key} -\subsection{Handling ``Dimension too large error''s} +\subsection{Handling ``Dimension too large error''} In case you should run into a ``Dimension too large error'' when using the |decorations| libraries, there is a pretty high chance that you can resolve From 26fcd9e6751ac375fb0542fb0309469e54b981ca Mon Sep 17 00:00:00 2001 From: Mo-Gul Date: Sat, 13 Jun 2020 07:42:34 +0200 Subject: [PATCH 09/14] Update doc/generic/pgf/text-en/pgfmanual-en-library-fpu.tex Co-authored-by: Henri Menke --- doc/generic/pgf/text-en/pgfmanual-en-library-fpu.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/generic/pgf/text-en/pgfmanual-en-library-fpu.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-fpu.tex index 70ef7bf65..04989eef4 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-fpu.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-fpu.tex @@ -162,7 +162,7 @@ \subsection{Usage} You have to be aware of the limitations that the FPU imposes. It will not magically give \TeX{} better precision, but it will avoid overflow or - underflow situation for large or small operands by rescaling them. In the + underflow situations for large or small operands by rescaling them. In the following example, in the first case the FPU variant performs much better than the normal variant, however, in the second case where a rescaling would not in fact be needed the rescaling introduces a small round-off From 34b895547e520095152a87dd40a2a5493351c3da Mon Sep 17 00:00:00 2001 From: Stefan Pinnow Date: Mon, 15 Jun 2020 13:14:56 +0200 Subject: [PATCH 10/14] followed @joulev's suggestion --- doc/generic/pgf/text-en/pgfmanual-en-library-decorations.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/generic/pgf/text-en/pgfmanual-en-library-decorations.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-decorations.tex index c0e6536fd..2f6fd0161 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-decorations.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-decorations.tex @@ -106,7 +106,7 @@ \subsection{Overview and Common Options} \end{key} -\subsection{Handling ``Dimension too large error''} +\subsection{Handling ``Dimension too large'' errors} In case you should run into a ``Dimension too large error'' when using the |decorations| libraries, there is a pretty high chance that you can resolve From 9fb67a790fb7eb6d74a06c26d96b32a6806ba07e Mon Sep 17 00:00:00 2001 From: Stefan Pinnow Date: Thu, 18 Jun 2020 17:39:12 +0200 Subject: [PATCH 11/14] added hints which libraries need to be loaded as well to make the example in `pgfmanual-en-tikz-graphs.tex` work closes issue #755) --- doc/generic/pgf/text-en/pgfmanual-en-tikz-graphs.tex | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/generic/pgf/text-en/pgfmanual-en-tikz-graphs.tex b/doc/generic/pgf/text-en/pgfmanual-en-tikz-graphs.tex index f2237a372..0667dfe0d 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-tikz-graphs.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-tikz-graphs.tex @@ -243,8 +243,9 @@ \subsubsection{Concept: Chain Groups} As can be seen, the placement is not particularly nice by default, use the algorithms from the graph drawing libraries to get a better layout. For -instance, adding |tree layout| to the above code results in the following -somewhat more pleasing rendering: +instance, adding |tree layout| to the above code (and +|\usetikzlibrary{graphdrawing}| as well as |\usegdlibrary{trees}| to the +preamble) results in the following somewhat more pleasing rendering: % \ifluatex \medskip From 8e77219cdbdf7418883c05df2de44f2fb0cbef31 Mon Sep 17 00:00:00 2001 From: Stefan Pinnow Date: Thu, 18 Jun 2020 20:43:06 +0200 Subject: [PATCH 12/14] corrected codeexample preamble entries --- doc/generic/pgf/text-en/pgfmanual-en-library-patterns.tex | 8 ++++---- .../pgf/graphdrawing/lua/pgf/gd/force/ControlSprings.lua | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/generic/pgf/text-en/pgfmanual-en-library-patterns.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-patterns.tex index ecf666c40..542aff4f1 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-patterns.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-patterns.tex @@ -257,7 +257,7 @@ \subsection{User-Defined Patterns} The following settings can be used to reproduce the other |... lines| patterns. % -\begin{codeexample}[preamble={\usetikzlibrary{patterns.meta}}] +\begin{codeexample}[preamble={\usetikzlibrary{patterns,patterns.meta}}] \begin{tikzpicture} \draw[pattern={horizontal lines},pattern color=orange] (0,0) rectangle +(1,1); @@ -315,7 +315,7 @@ \subsection{User-Defined Patterns} The following settings can be used to reproduce the |grid| and |crosshatch| patterns. % -\begin{codeexample}[preamble={\usetikzlibrary{patterns.meta}}] +\begin{codeexample}[preamble={\usetikzlibrary{patterns,patterns.meta}}] \begin{tikzpicture} \draw[pattern={grid},pattern color=orange] (0,0) rectangle +(1,1); @@ -363,7 +363,7 @@ \subsection{User-Defined Patterns} The following settings can be used to reproduce the |dots| and |crosshatch dots| patterns. % -\begin{codeexample}[preamble={\usetikzlibrary{patterns.meta}}] +\begin{codeexample}[preamble={\usetikzlibrary{patterns,patterns.meta}}] \begin{tikzpicture} \draw[pattern={dots},pattern color=orange] (0,0) rectangle +(1,1); @@ -413,7 +413,7 @@ \subsection{User-Defined Patterns} Number of pointy ends of the stars. \end{key} % -\begin{codeexample}[preamble={\usetikzlibrary{patterns.meta}}] +\begin{codeexample}[preamble={\usetikzlibrary{patterns,patterns.meta}}] \begin{tikzpicture} \draw[pattern={fivepointed stars},pattern color=orange] (0,0) rectangle +(1,1); diff --git a/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlSprings.lua b/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlSprings.lua index 71005d852..9b0c1071e 100644 --- a/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlSprings.lua +++ b/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlSprings.lua @@ -26,14 +26,14 @@ local declare = require("pgf.gd.interface.InterfaceToAlgorithms").declare -- The following examples shows how a simple graph can be scaled by -- changing the |node distance|: -- % --- \begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} +-- \begin{codeexample}[preamble={\usetikzlibrary{graphs.standard,graphdrawing} -- \usegdlibrary{force}}] -- \tikz \graph [spring layout, node distance=7mm] { subgraph C_n[n=3] }; -- \tikz \graph [spring layout] { subgraph C_n[n=3] }; -- \tikz \graph [spring layout, node distance=15mm]{ subgraph C_n[n=3] }; -- \end{codeexample} -- % --- \begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} +-- \begin{codeexample}[preamble={\usetikzlibrary{graphs.standard,graphdrawing} -- \usegdlibrary{force}}] -- \tikz \graph [spring electrical layout, node distance=0.7cm] { subgraph C_n[n=3] }; -- \tikz \graph [spring electrical layout] { subgraph C_n[n=3] }; From 239c7cb48eb136641b066016a2826aaca9e9f72a Mon Sep 17 00:00:00 2001 From: Stefan Pinnow Date: Thu, 18 Jun 2020 17:39:12 +0200 Subject: [PATCH 13/14] added hints which libraries need to be loaded as well to make the example in `pgfmanual-en-tikz-graphs.tex` work closes issue #755) --- doc/generic/pgf/text-en/pgfmanual-en-tikz-graphs.tex | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/generic/pgf/text-en/pgfmanual-en-tikz-graphs.tex b/doc/generic/pgf/text-en/pgfmanual-en-tikz-graphs.tex index f2237a372..0667dfe0d 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-tikz-graphs.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-tikz-graphs.tex @@ -243,8 +243,9 @@ \subsubsection{Concept: Chain Groups} As can be seen, the placement is not particularly nice by default, use the algorithms from the graph drawing libraries to get a better layout. For -instance, adding |tree layout| to the above code results in the following -somewhat more pleasing rendering: +instance, adding |tree layout| to the above code (and +|\usetikzlibrary{graphdrawing}| as well as |\usegdlibrary{trees}| to the +preamble) results in the following somewhat more pleasing rendering: % \ifluatex \medskip From 1e13bdfaf06b27a054abb0df165d7bcde5fe6cde Mon Sep 17 00:00:00 2001 From: Stefan Pinnow Date: Fri, 19 Jun 2020 07:11:12 +0200 Subject: [PATCH 14/14] add options to Lua (code) examples --- .../version-for-luatex/en/pgfmanual-test.tex | 7 +- .../lua/pgf/gd/control/ComponentAlign.lua | 99 +++++--- .../lua/pgf/gd/control/ComponentDirection.lua | 39 ++- .../lua/pgf/gd/control/ComponentOrder.lua | 47 ++-- .../lua/pgf/gd/control/Components.lua | 37 ++- .../lua/pgf/gd/control/Distances.lua | 213 +++++++++++------ .../lua/pgf/gd/control/FineTune.lua | 100 +++++--- .../lua/pgf/gd/control/NodeAnchors.lua | 28 ++- .../lua/pgf/gd/control/Orientation.lua | 226 ++++++++++++------ .../lua/pgf/gd/control/library.lua | 86 +++++-- .../lua/pgf/gd/force/ControlCoarsening.lua | 92 ++++--- .../lua/pgf/gd/force/ControlElectric.lua | 7 +- .../lua/pgf/gd/force/ControlIteration.lua | 91 ++++--- .../lua/pgf/gd/layered/Sugiyama.lua | 152 +++++++----- .../lua/pgf/gd/pedigrees/Koerner2015.lua | 23 +- .../phylogenetics/AuthorDefinedPhylogeny.lua | 26 +- .../BalancedMinimumEvolution.lua | 36 +-- .../lua/pgf/gd/phylogenetics/Maeusle2012.lua | 145 ++++++----- .../pgf/gd/phylogenetics/PhylogeneticTree.lua | 32 ++- .../gd/phylogenetics/SokalMichener1958.lua | 34 ++- .../lua/pgf/gd/planar/PlanarLayout.lua | 18 +- .../lua/pgf/gd/planar/parameters.lua | 2 +- .../lua/pgf/gd/routing/NecklaceRouting.lua | 20 +- .../lua/pgf/gd/trees/ChildSpec.lua | 65 +++-- .../pgf/gd/trees/SpanningTreeComputation.lua | 62 +++-- 25 files changed, 1109 insertions(+), 578 deletions(-) diff --git a/doc/generic/pgf/version-for-luatex/en/pgfmanual-test.tex b/doc/generic/pgf/version-for-luatex/en/pgfmanual-test.tex index 98b08b3f7..87757b6f9 100644 --- a/doc/generic/pgf/version-for-luatex/en/pgfmanual-test.tex +++ b/doc/generic/pgf/version-for-luatex/en/pgfmanual-test.tex @@ -10,13 +10,16 @@ \documentclass[a4paper]{ltxdoc} % pgf version is defined in \pgfversion in file -% generic/pgf/utilities/pgfrcs.code.tex +% generic/pgf/utilities/pgfrcs.code.tex \input{../pgfmanual-luatex.cfg} \input{../../text-en/pgfmanual-en-main-preamble.tex} \begin{document} -\include{pgfmanual-en-library-patterns} +%\include{pgfmanual-en-library-patterns} + +\include{pgfmanual-en-gd-phylogenetics} +%\includeluadocumentationof{pgf.gd.pedigrees.library} \end{document} diff --git a/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/ComponentAlign.lua b/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/ComponentAlign.lua index 72a82be97..1073e2b58 100644 --- a/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/ComponentAlign.lua +++ b/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/ComponentAlign.lua @@ -59,10 +59,18 @@ declare { than one node of a component, the node encountered first in the component is used. "]], - examples = [[" - \tikz \graph [binary tree layout, nodes={draw}] - { a, b -- c[align here], d -- e[second, align here] -- f }; - "]] + examples = {{ + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{trees} + }, + "]], + code = [[" + \tikz \graph [binary tree layout, nodes={draw}] + { a, b -- c[align here], d -- e[second, align here] -- f }; + "]], + }} } --- @@ -200,11 +208,19 @@ declare { suggest, the components will be placed left-to-right and they are aligned such that their top nodes are in a line. "]], - examples = [[" - \tikz \graph [tree layout, nodes={draw, align=center}, - components go right top aligned] - { a, "high\\node" -- b}; - "]] + examples = {{ + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{trees} + }, + "]], + code = [[" + \tikz \graph [tree layout, nodes={draw, align=center}, + components go right top aligned] + { a, "high\\node" -- b}; + "]] + }} } --- @@ -222,11 +238,19 @@ declare { This means that the components will be aligned with their bounding boxed being top-aligned. "]], - examples = [[" - \tikz \graph [tree layout, nodes={draw, align=center}, - components go right absolute top aligned] - { a, "high\\node" -- b}; - "]] + examples = {{ + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{trees} + }, + "]], + code = [[" + \tikz \graph [tree layout, nodes={draw, align=center}, + components go right absolute top aligned] + { a, "high\\node" -- b}; + "]] + }} } --- @@ -295,11 +319,19 @@ declare { summary = "See the other |components go ...| keys.", - examples = [[" - \tikz \graph [tree layout, nodes={draw, align=center}, - components go left top aligned] - { a, "high\\node" -- b}; - "]] + examples = {{ + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{trees} + }, + "]], + code = [[" + \tikz \graph [tree layout, nodes={draw, align=center}, + components go left top aligned] + { a, "high\\node" -- b}; + "]] + }} } --- @@ -381,15 +413,26 @@ declare { }, summary = "See the other |components go ...| keys.", - examples = {[[" - \tikz \graph [tree layout, nodes={draw, align=center}, - components go down left aligned] - { a, hello -- {world,s} }; - "]],[[" - \tikz \graph [tree layout, nodes={draw, align=center}, - components go up absolute left aligned] - { a, hello -- {world,s}}; - "]] + examples = { + { + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{trees} + }, + "]], + code = [[" + \tikz \graph [tree layout, nodes={draw, align=center}, + components go down left aligned] + { a, hello -- {world,s} }; + "]] + },{ + code = [[" + \tikz \graph [tree layout, nodes={draw, align=center}, + components go up absolute left aligned] + { a, hello -- {world,s}}; + "]] + } } } diff --git a/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/ComponentDirection.lua b/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/ComponentDirection.lua index f941ff226..f014e48a1 100644 --- a/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/ComponentDirection.lua +++ b/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/ComponentDirection.lua @@ -38,19 +38,32 @@ declare { by this option in any way. You can use the |grow| option or |orient| options to orient individual components. "]], - examples = {[[" - \tikz \graph [tree layout, nodes={inner sep=1pt,draw,circle}, - component direction=left] - { a, b, c -- d -- e, f -- g }; - "]],[[" - \tikz \graph [tree layout, nodes={inner sep=1pt,draw,circle}, - component direction=10] - { a, b, c -- d -- e, f -- g }; - "]],[[" - \tikz \graph [tree layout, nodes={inner sep=1pt,draw,circle}, - component direction=up] - { a, b, c [grow=right] -- d -- e, f[grow=45] -- g }; - "]] + examples = { + { + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{trees} + }, + "]], + code = [[" + \tikz \graph [tree layout, nodes={inner sep=1pt,draw,circle}, + component direction=left] + { a, b, c -- d -- e, f -- g }; + "]] + },{ + code = [[" + \tikz \graph [tree layout, nodes={inner sep=1pt,draw,circle}, + component direction=10] + { a, b, c -- d -- e, f -- g }; + "]] + },{ + code = [[" + \tikz \graph [tree layout, nodes={inner sep=1pt,draw,circle}, + component direction=up] + { a, b, c [grow=right] -- d -- e, f[grow=45] -- g }; + "]] + } } } diff --git a/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/ComponentOrder.lua b/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/ComponentOrder.lua index 78537b614..0f51caf47 100644 --- a/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/ComponentOrder.lua +++ b/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/ComponentOrder.lua @@ -58,15 +58,26 @@ declare { As above, but in decreasing order. \end{itemize} "]], - examples = {[[" - \tikz \graph [tree layout, nodes={inner sep=1pt,draw,circle}, - component order=by first specified node] - { a, b, c, f -- g, c -- d -- e }; - "]],[[" - \tikz \graph [tree layout, nodes={inner sep=1pt,draw,circle}, - component order=increasing node number] - { a, b, c -- d -- e, f -- g }; - "]] + examples = { + { + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{trees} + }, + "]], + code = [[" + \tikz \graph [tree layout, nodes={inner sep=1pt,draw,circle}, + component order=by first specified node] + { a, b, c, f -- g, c -- d -- e }; + "]] + },{ + code = [[" + \tikz \graph [tree layout, nodes={inner sep=1pt,draw,circle}, + component order=increasing node number] + { a, b, c -- d -- e, f -- g }; + "]] + } } } @@ -94,11 +105,19 @@ declare { summary = [[" A shorthand for |component order=decreasing node number|. "]], - examples = [[" - \tikz \graph [tree layout, nodes={inner sep=1pt,draw,circle}, - large components first] - { a, b, c -- d -- e, f -- g }; - "]] + examples = {{ + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{trees} + }, + "]], + code = [[" + \tikz \graph [tree layout, nodes={inner sep=1pt,draw,circle}, + large components first] + { a, b, c -- d -- e, f -- g }; + "]] + }} } diff --git a/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/Components.lua b/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/Components.lua index c5019a56e..c512d8d28 100644 --- a/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/Components.lua +++ b/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/Components.lua @@ -107,19 +107,30 @@ declare { support laying out unconnected graphs, this option has no effect; rather it works as if this option were always set. "]], - examples = {[[" - \tikz \graph [simple necklace layout] - { - a -- b -- c -- d -- a, - 1 -- 2 -- 3 -- 1 - }; - "]],[[", - \tikz \graph [simple necklace layout, componentwise] - { - a -- b -- c -- d -- a, - 1 -- 2 -- 3 -- 1 - }; - "]] + examples = { + { + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{circular} + }, + "]], + code = [[" + \tikz \graph [simple necklace layout] + { + a -- b -- c -- d -- a, + 1 -- 2 -- 3 -- 1 + }; + "]] + },{ + code = [[", + \tikz \graph [simple necklace layout, componentwise] + { + a -- b -- c -- d -- a, + 1 -- 2 -- 3 -- 1 + }; + "]] + } } } diff --git a/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/Distances.lua b/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/Distances.lua index 6dc5a1301..2441e2d43 100644 --- a/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/Distances.lua +++ b/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/Distances.lua @@ -62,18 +62,26 @@ declare { desired distance, for instance in case the nodes are too big. In this case, the \meta{length} is just considered as a lower bound. "]], - examples = [[" - \begin{tikzpicture} - \graph [simple necklace layout, node distance=1cm, node sep=0pt, - nodes={draw,circle,as=.}] - { - 1 -- 2 [minimum size=2cm] -- 3 -- - 4 -- 5 -- 6 -- 7 --[orient=up] 8 - }; - \draw [red,|-|] (1.center) -- ++(0:1cm); - \draw [red,|-|] (5.center) -- ++(180:1cm); - \end{tikzpicture} - "]] + examples = {{ + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{circular} + }, + "]], + code = [[" + \begin{tikzpicture} + \graph [simple necklace layout, node distance=1cm, node sep=0pt, + nodes={draw,circle,as=.}] + { + 1 -- 2 [minimum size=2cm] -- 3 -- + 4 -- 5 -- 6 -- 7 --[orient=up] 8 + }; + \draw [red,|-|] (1.center) -- ++(0:1cm); + \draw [red,|-|] (5.center) -- ++(180:1cm); + \end{tikzpicture} + "]] + }} } @@ -94,14 +102,25 @@ declare { front''. This make sense only for some algorithms, like for a simple necklace layout. "]], - examples = {[[" - \tikz \graph [simple necklace layout, node distance=0cm, nodes={circle,draw}] - { 1--2--3--4--5--1 }; - "]],[[" - \tikz \graph [simple necklace layout, node distance=0cm, node sep=0mm, - nodes={circle,draw}] - { 1--2--3[node pre sep=5mm]--4--5[node pre sep=1mm]--1 }; - "]] + examples = { + { + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{circular} + }, + "]], + code = [[" + \tikz \graph [simple necklace layout, node distance=0cm, nodes={circle,draw}] + { 1--2--3--4--5--1 }; + "]] + },{ + code = [[" + \tikz \graph [simple necklace layout, node distance=0cm, node sep=0mm, + nodes={circle,draw}] + { 1--2--3[node pre sep=5mm]--4--5[node pre sep=1mm]--1 }; + "]] + } } } @@ -150,15 +169,23 @@ declare { instance in case the nodes are too big. In this case, the \meta{length} is just considered as a lower bound. "]], - examples = [[" - \begin{tikzpicture}[inner sep=2pt] - \draw [help lines] (0,0) grid (3.5,2); - \graph [layered layout, level distance=1cm, level sep=0] - { 1 [x=1,y=2] -- 2 -- 3 -- 1 }; - \graph [layered layout, level distance=5mm, level sep=0] - { 1 [x=3,y=2] -- 2 -- 3 -- 1, 3 -- {4,5} -- 6 -- 3 }; - \end{tikzpicture} - "]] + examples = {{ + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{layered} + }, + "]], + code = [[" + \begin{tikzpicture}[inner sep=2pt] + \draw [help lines] (0,0) grid (3.5,2); + \graph [layered layout, level distance=1cm, level sep=0] + { 1 [x=1,y=2] -- 2 -- 3 -- 1 }; + \graph [layered layout, level distance=5mm, level sep=0] + { 1 [x=3,y=2] -- 2 -- 3 -- 1, 3 -- {4,5} -- 6 -- 3 }; + \end{tikzpicture} + "]] + }} } --- @@ -188,15 +215,23 @@ declare { behave like the ``padding'' keys rather than the ``margin'' key of cascading style sheets. "]], - examples = [[" - \begin{tikzpicture}[inner sep=2pt, level sep=0pt, sibling distance=0pt] - \draw [help lines] (0,0) grid (3.5,2); - \graph [layered layout, level distance=0cm, nodes=draw] - { 1 [x=1,y=2] -- {2,3[level pre sep=1mm],4[level pre sep=5mm]} -- 5 }; - \graph [layered layout, level distance=0cm, nodes=draw] - { 1 [x=3,y=2] -- {2,3,4} -- 5[level pre sep=5mm] }; - \end{tikzpicture} - "]] + examples = {{ + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{layered} + }, + "]], + code = [[" + \begin{tikzpicture}[inner sep=2pt, level sep=0pt, sibling distance=0pt] + \draw [help lines] (0,0) grid (3.5,2); + \graph [layered layout, level distance=0cm, nodes=draw] + { 1 [x=1,y=2] -- {2,3[level pre sep=1mm],4[level pre sep=5mm]} -- 5 }; + \graph [layered layout, level distance=0cm, nodes=draw] + { 1 [x=3,y=2] -- {2,3,4} -- 5[level pre sep=5mm] }; + \end{tikzpicture} + "]] + }} } --- @@ -278,18 +313,31 @@ declare { For some layouts, like a simple necklace layout, the \meta{length} is measured as the distance on the circle. "]], - examples = {[[" - \tikz \graph [tree layout, sibling distance=1cm, nodes={circle,draw}] - { 1--{2,3,4,5} }; - "]],[[" - \tikz \graph [tree layout, sibling distance=0cm, sibling sep=0pt, - nodes={circle,draw}] - { 1--{2,3,4,5} }; - "]],[[" - \tikz \graph [tree layout, sibling distance=0cm, sibling sep=0pt, - nodes={circle,draw}] - { 1--{2,3[sibling distance=1cm],4,5} }; - "]] + examples = { + { + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{trees} + }, + "]], + code = [[" + \tikz \graph [tree layout, sibling distance=1cm, nodes={circle,draw}] + { 1--{2,3,4,5} }; + "]] + },{ + code = [[" + \tikz \graph [tree layout, sibling distance=0cm, sibling sep=0pt, + nodes={circle,draw}] + { 1--{2,3,4,5} }; + "]] + },{ + code = [[" + \tikz \graph [tree layout, sibling distance=0cm, sibling sep=0pt, + nodes={circle,draw}] + { 1--{2,3[sibling distance=1cm],4,5} }; + "]] + } } } @@ -304,11 +352,19 @@ declare { summary = [[" Works like |level pre sep|, only for siblings. "]], - examples = [[" - \tikz \graph [tree layout, sibling distance=0cm, nodes={circle,draw}, - sibling sep=0pt] - { 1--{2,3[sibling pre sep=1cm],4,5} }; - "]] + examples = {{ + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{trees} + }, + "]], + code = [[" + \tikz \graph [tree layout, sibling distance=0cm, nodes={circle,draw}, + sibling sep=0pt] + { 1--{2,3[sibling pre sep=1cm],4,5} }; + "]] + }} } --- @@ -412,25 +468,36 @@ declare { connected components will have when they are placed next to each other. "]], - examples = {[[" - \tikz \graph [binary tree layout, sibling distance=4mm, level distance=8mm, - components go right top aligned, - component sep=1pt, nodes=draw] + examples = { { - 1 -> 2 -> {3->4[second]->5,6,7}; - a -> b[second] -> c[second] -> d -> e; - x -> y[second] -> z -> u[second] -> v; - }; - "]],[[" - \tikz \graph [binary tree layout, sibling distance=4mm, level distance=8mm, - components go right top aligned, - component sep=1em, nodes=draw] - { - 1 -> 2 -> {3->4[second]->5,6,7}; - a -> b[second] -> c[second] -> d -> e; - x -> y[second] -> z -> u[second] -> v; - }; - "]] + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{trees} + }, + "]], + code = [[" + \tikz \graph [binary tree layout, sibling distance=4mm, level distance=8mm, + components go right top aligned, + component sep=1pt, nodes=draw] + { + 1 -> 2 -> {3->4[second]->5,6,7}; + a -> b[second] -> c[second] -> d -> e; + x -> y[second] -> z -> u[second] -> v; + }; + "]] + },{ + code = [[" + \tikz \graph [binary tree layout, sibling distance=4mm, level distance=8mm, + components go right top aligned, + component sep=1em, nodes=draw] + { + 1 -> 2 -> {3->4[second]->5,6,7}; + a -> b[second] -> c[second] -> d -> e; + x -> y[second] -> z -> u[second] -> v; + }; + "]] + } } } diff --git a/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/FineTune.lua b/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/FineTune.lua index 87d67b5b5..ced54e48c 100644 --- a/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/FineTune.lua +++ b/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/FineTune.lua @@ -37,12 +37,20 @@ declare { after the algorithm has computed something. "]], - examples = [[" - \tikz \graph [edges=rounded corners, nodes=draw, - layered layout, sibling distance=0] { - a -- {b, c, d[nudge=(up:2mm)]} -- e -- a; - }; - "]] + examples = {{ + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{layered} + }, + "]], + code = [[" + \tikz \graph [edges=rounded corners, nodes=draw, + layered layout, sibling distance=0] { + a -- {b, c, d[nudge=(up:2mm)]} -- e -- a; + }; + "]] + }} } @@ -57,12 +65,20 @@ declare { }, summary = "A shorthand for nudging a node upwards.", - examples = [[" - \tikz \graph [edges=rounded corners, nodes=draw, - layered layout, sibling distance=0] { - a -- {b, c, d[nudge up=2mm]} -- e -- a; - }; - "]] + examples = {{ + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{layered} + }, + "]], + code = [[" + \tikz \graph [edges=rounded corners, nodes=draw, + layered layout, sibling distance=0] { + a -- {b, c, d[nudge up=2mm]} -- e -- a; + }; + "]] + }} } @@ -90,12 +106,20 @@ declare { }, summary = "Like |nudge up|, but left.", - examples = [[" - \tikz \graph [edges=rounded corners, nodes=draw, - layered layout, sibling distance=0] { - a -- {b, c, d[nudge left=2mm]} -- e -- a; - }; - "]] + examples = {{ + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{layered} + }, + "]], + code = [[" + \tikz \graph [edges=rounded corners, nodes=draw, + layered layout, sibling distance=0] { + a -- {b, c, d[nudge left=2mm]} -- e -- a; + }; + "]] + }} } --- @@ -125,12 +149,20 @@ declare { afterwards, the node is placed there, regardless of what the algorithm has computed (all other nodes are unaffected). "]], - examples = [[" - \tikz \graph [edges=rounded corners, nodes=draw, - layered layout, sibling distance=0] { - a -- {b,c,d[regardless at={(1,0)}]} -- e -- a; - }; - "]] + examples = {{ + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{layered} + }, + "]], + code = [[" + \tikz \graph [edges=rounded corners, nodes=draw, + layered layout, sibling distance=0] { + a -- {b,c,d[regardless at={(1,0)}]} -- e -- a; + }; + "]] + }} } @@ -154,11 +186,19 @@ declare { regardless. The name of the key is intended to remind one of a node being ``nailed'' to the canvas. "]], - examples = [[" - \tikz \graph [edges=rounded corners, nodes=draw, - layered layout, sibling distance=0] { - a -- {b,c,d[nail at={(1,0)}]} -- e[nail at={(1.5,-1)}] -- a; - }; - "]] + examples = {{ + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{layered} + }, + "]], + code = [[" + \tikz \graph [edges=rounded corners, nodes=draw, + layered layout, sibling distance=0] { + a -- {b,c,d[nail at={(1,0)}]} -- e[nail at={(1.5,-1)}] -- a; + }; + "]] + }} } diff --git a/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/NodeAnchors.lua b/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/NodeAnchors.lua index 80aa7ef42..e264e3953 100644 --- a/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/NodeAnchors.lua +++ b/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/NodeAnchors.lua @@ -161,15 +161,23 @@ declare { could draw a sort of ``inside edge''. "]], - examples = { [[" - \tikz \graph [no layout, nodes={draw, minimum size=20pt}] { - a [x=0, y=0] -- b [x=15pt, y=10pt] -- c[x=40pt] - }; - "]],[[" - \tikz \graph [no layout, nodes={draw, minimum size=20pt}, - allow inside edges=false] { - a [x=0, y=0] -- b [x=15pt, y=10pt] -- c[x=40pt] - }; - "]] + examples = { + { + options = [[" + preamble={\usetikzlibrary{graphs,graphdrawing}}, + "]], + code = [[" + \tikz \graph [no layout, nodes={draw, minimum size=20pt}] { + a [x=0, y=0] -- b [x=15pt, y=10pt] -- c[x=40pt] + }; + "]] + },{ + code = [[" + \tikz \graph [no layout, nodes={draw, minimum size=20pt}, + allow inside edges=false] { + a [x=0, y=0] -- b [x=15pt, y=10pt] -- c[x=40pt] + }; + "]] + } } } \ No newline at end of file diff --git a/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/Orientation.lua b/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/Orientation.lua index 1890fa4f3..2ca38037a 100644 --- a/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/Orientation.lua +++ b/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/Orientation.lua @@ -69,19 +69,30 @@ declare { and so forth as \meta{direction} and also |up|, |down|, |left|, and |right|. Also, you can specify |-| for ``right'' and \verb!|! for ``down''. "]], - examples = {[[" - \tikz \graph [spring layout] + examples = { { - a -- { b, c, d, e -- {f, g, h} }; - h -- [orient=30] a; - }; - "]],[[" - \tikz \graph [spring layout] - { - a -- { b, c, d[> orient=right], e -- {f, g, h} }; - h -- a; - }; - "]] + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{force} + }, + "]], + code = [[" + \tikz \graph [spring layout] + { + a -- { b, c, d, e -- {f, g, h} }; + h -- [orient=30] a; + }; + "]] + },{ + code = [[" + \tikz \graph [spring layout] + { + a -- { b, c, d[> orient=right], e -- {f, g, h} }; + h -- a; + }; + "]] + } } } @@ -97,13 +108,21 @@ declare { Same as |orient|, only the rest of the graph should be flipped relative to the connection line. "]], - examples = [[" - \tikz \graph [spring layout] - { - a -- { b, c, d[> orient'=right], e -- {f, g, h} }; - h -- a; - }; - "]] + examples = {{ + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{force} + }, + "]], + code = [[" + \tikz \graph [spring layout] + { + a -- { b, c, d[> orient'=right], e -- {f, g, h} }; + h -- a; + }; + "]] + }} } --- @@ -116,17 +135,28 @@ declare { Specifies the tail vertex for the orientation of a graph. See |orient| for details. "]], - examples = {[[" - \tikz \graph [spring layout] { - a [orient=|, orient tail=f] -- { b, c, d, e -- {f, g, h} }; - { h, g } -- a; - }; - "]],[[" - \tikz \graph [spring layout] { - a [orient=down, orient tail=h] -- { b, c, d, e -- {f, g, h} }; - { h, g } -- a; - }; - "]] + examples = { + { + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{force} + }, + "]], + code = [[" + \tikz \graph [spring layout] { + a [orient=|, orient tail=f] -- { b, c, d, e -- {f, g, h} }; + { h, g } -- a; + }; + "]] + },{ + code = [[" + \tikz \graph [spring layout] { + a [orient=down, orient tail=h] -- { b, c, d, e -- {f, g, h} }; + { h, g } -- a; + }; + "]] + } } } @@ -144,17 +174,28 @@ declare { Specifies the head vertex for the orientation of a graph. See |orient| for details. "]], - examples = {[[" - \tikz \graph [spring layout] + examples = { { - a [orient=|, orient head=f] -- { b, c, d, e -- {f, g, h} }; - { h, g } -- a; - }; - "]],[[" - \tikz \graph [spring layout] { a -- b -- c -- a }; - \tikz \graph [spring layout, orient=10, - orient tail=a, orient head=b] { a -- b -- c -- a }; - "]] + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{force} + }, + "]], + code = [[" + \tikz \graph [spring layout] + { + a [orient=|, orient head=f] -- { b, c, d, e -- {f, g, h} }; + { h, g } -- a; + }; + "]] + },{ + code = [[" + \tikz \graph [spring layout] { a -- b -- c -- a }; + \tikz \graph [spring layout, orient=10, + orient tail=a, orient head=b] { a -- b -- c -- a }; + "]] + } } } @@ -169,10 +210,18 @@ declare { |orient=0|. The tail will be everything before the part ``| to |'' and the head will be everything following it. "]], - examples = [[" - \tikz \graph [spring layout] { a -- b -- c -- a }; - \tikz \graph [spring layout, horizontal=a to b] { a -- b -- c -- a }; - "]] + examples = {{ + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{force} + }, + "]], + code = [[" + \tikz \graph [spring layout] { a -- b -- c -- a }; + \tikz \graph [spring layout, horizontal=a to b] { a -- b -- c -- a }; + "]] + }} } @@ -204,10 +253,18 @@ declare { summary = [[" A shorthand for specifying |orient tail|, |orient head| and |orient=-90|. "]], - examples = [[" - \tikz \graph [spring layout] { a -- b -- c -- a }; - \tikz \graph [spring layout, vertical=a to b] { a -- b -- c -- a }; - "]] + examples = {{ + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{force} + }, + "]], + code = [[" + \tikz \graph [spring layout] { a -- b -- c -- a }; + \tikz \graph [spring layout, vertical=a to b] { a -- b -- c -- a }; + "]] + }} } @@ -257,26 +314,39 @@ declare { When you give the |grow=right| key to the graph as a whole, it will be applied to all nodes. This happens to be exactly what you want: "]], - examples = {[[" - \tikz \graph [layered layout, sibling distance=5mm] - { - a [grow=right] -- { b, c, d, e -- {f, g, h} }; - { h, g } -- a; - }; - "]],[[" - \tikz \graph [layered layout, grow=right, sibling distance=5mm] + examples = { { - a -- { b, c, d, e -- {f, g, h} }; - { h, g } -- a; - }; - "]],[[" - \tikz - \graph [layered layout, grow=-80] - { - {a,b,c} --[complete bipartite] {e,d,f} - --[complete bipartite] {g,h,i}; - }; - "]] + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{layered} + }, + "]], + code = [[" + \tikz \graph [layered layout, sibling distance=5mm] + { + a [grow=right] -- { b, c, d, e -- {f, g, h} }; + { h, g } -- a; + }; + "]] + },{ + code = [[" + \tikz \graph [layered layout, grow=right, sibling distance=5mm] + { + a -- { b, c, d, e -- {f, g, h} }; + { h, g } -- a; + }; + "]] + },{ + code = [[" + \tikz + \graph [layered layout, grow=-80] + { + {a,b,c} --[complete bipartite] {e,d,f} + --[complete bipartite] {g,h,i}; + }; + "]] + } } } @@ -288,13 +358,21 @@ declare { type = "direction", summary = "Same as |grow|, only with the children in clockwise order.", - examples = [[" - \tikz \graph [layered layout, sibling distance=5mm] - { - a [grow'=right] -- { b, c, d, e -- {f, g, h} }; - { h, g } -- a; - }; - "]] + examples = {{ + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{layered} + }, + "]], + code = [[" + \tikz \graph [layered layout, sibling distance=5mm] + { + a [grow'=right] -- { b, c, d, e -- {f, g, h} }; + { h, g } -- a; + }; + "]] + }} } diff --git a/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/library.lua b/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/library.lua index df7ce68dd..8d59c016e 100644 --- a/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/library.lua +++ b/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/library.lua @@ -53,11 +53,19 @@ declare { This behavior can be changed using this option. When the key is invoked, nodes are placed \emph{behind} the edges. "]], - examples = [[" - \tikz \graph [simple necklace layout, nodes={draw,fill=white}, - nodes behind edges] - { subgraph K_n [n=7], 1 [regardless at={(0,-1)}] }; - "]] + examples = {{ + options = [[" + preamble={ + \usetikzlibrary{graphs.standard,graphdrawing} + \usegdlibrary{circular,examples} + }, + "]], + code = [[" + \tikz \graph [simple necklace layout, nodes={draw,fill=white}, + nodes behind edges] + { subgraph K_n [n=7], 1 [regardless at={(0,-1)}] }; + "]] + }} } @@ -72,11 +80,19 @@ declare { summary = [[" This is the default placement of edges: Behind the nodes. "]], - examples = [[" - \tikz \graph [simple necklace layout, nodes={draw,fill=white}, - edges behind nodes] - { subgraph K_n [n=7], 1 [regardless at={(0,-1)}] }; - "]] + examples = {{ + options = [[" + preamble={ + \usetikzlibrary{graphs.standard,graphdrawing} + \usegdlibrary{circular,examples} + }, + "]], + code = [[" + \tikz \graph [simple necklace layout, nodes={draw,fill=white}, + edges behind nodes] + { subgraph K_n [n=7], 1 [regardless at={(0,-1)}] }; + "]] + }} } --- @@ -117,15 +133,26 @@ declare { For instance, in a |layered layout|, an edge with a large |weight| will be as short as possible. "]], - examples = {[[" - \tikz \graph [layered layout] { - a -- {b,c,d} -- e -- a; - }; - "]],[[" - \tikz \graph [layered layout] { - a -- {b,c,d} -- e --[weight=3] a; - }; - "]] + examples = { + { + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{layered} + }, + "]], + code = [[" + \tikz \graph [layered layout] { + a -- {b,c,d} -- e -- a; + }; + "]] + },{ + code = [[" + \tikz \graph [layered layout] { + a -- {b,c,d} -- e --[weight=3] a; + }; + "]] + } } } @@ -141,13 +168,20 @@ declare { Sets the ``length'' of an edge. Algorithms may take this value into account when drawing a graph. "]], - examples = {[[" - \tikz \graph [phylogenetic tree layout] { - a --[length=2] b --[length=1] {c,d}; - a --[length=3] e - }; - "]], - } + examples = {{ + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{phylogenetics,trees} + }, + "]], + code = [[" + \tikz \graph [phylogenetic tree layout] { + a --[length=2] b --[length=1] {c,d}; + a --[length=3] e + }; + "]], + }} } diff --git a/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlCoarsening.lua b/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlCoarsening.lua index d69d5fc6c..182ba0e93 100644 --- a/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlCoarsening.lua +++ b/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlCoarsening.lua @@ -57,20 +57,28 @@ declare { expected to be higher than graphics where this feature is not applied. The following example demonstrates how coarsening can improve the - quality of graph drawings generated with Walshaw's algorihtm + quality of graph drawings generated with Walshaw's algorithm |spring electrical layout'|. "]], - examples = [[" - \tikz \graph [spring electrical layout', coarsen=false, vertical=3 to 4] - { - { [clique] 1, 2 } -- 3 -- 4 -- { 5, 6, 7 } - }; - - \tikz \graph [spring electrical layout', coarsen, vertical=3 to 4] - { - { [clique] 1, 2 } -- 3 -- 4 -- { 5, 6, 7 } - }; - "]] + examples = {{ + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{force} + }, + "]], + code = [[" + \tikz \graph [spring electrical layout', coarsen=false, vertical=3 to 4] + { + { [clique] 1, 2 } -- 3 -- 4 -- { 5, 6, 7 } + }; + + \tikz \graph [spring electrical layout', coarsen, vertical=3 to 4] + { + { [clique] 1, 2 } -- 3 -- 4 -- { 5, 6, 7 } + }; + "]] + }} } --- @@ -95,15 +103,23 @@ declare { in the two graphs, the nodes are placed at exactly two and four coordinates in the final drawing. "]], - examples = [[" - \tikz \graph [spring layout, iterations=0, - minimum coarsening size=2] - { subgraph C_n [n=8] }; - - \tikz \graph [spring layout, iterations=0, - minimum coarsening size=4] - { subgraph C_n [n=8] }; - "]] + examples = {{ + options = [[" + preamble={ + \usetikzlibrary{graphs.standard,graphdrawing} + \usegdlibrary{force} + }, + "]], + code = [[" + \tikz \graph [spring layout, iterations=0, + minimum coarsening size=2] + { subgraph C_n [n=8] }; + + \tikz \graph [spring layout, iterations=0, + minimum coarsening size=4] + { subgraph C_n [n=8] }; + "]] + }} } --- @@ -131,18 +147,26 @@ declare { multilevel approach may not produce drawings as good as with a lower |downsize ratio|. "]], - examples = [[" - % 1. ratio too high, coarsening stops early, benefits are lost - \tikz \graph [spring electrical layout', - downsize ratio=1.0, - node distance=7mm, vertical=3 to 4] - { { [clique] 1, 2 } -- 3 -- 4 -- { 5, 6, 7 } }; - - % 2. ratio set to default, coarsening benefits are visible - \tikz \graph [spring electrical layout', - downsize ratio=0.2, - node distance=7mm, vertical=3 to 4] - { { [clique] 1, 2 } -- 3 -- 4 -- { 5, 6, 7 } }; - "]] + examples = {{ + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{force} + }, + "]], + code = [[" + % 1. ratio too high, coarsening stops early, benefits are lost + \tikz \graph [spring electrical layout', + downsize ratio=1.0, + node distance=7mm, vertical=3 to 4] + { { [clique] 1, 2 } -- 3 -- 4 -- { 5, 6, 7 } }; + + % 2. ratio set to default, coarsening benefits are visible + \tikz \graph [spring electrical layout', + downsize ratio=0.2, + node distance=7mm, vertical=3 to 4] + { { [clique] 1, 2 } -- 3 -- 4 -- { 5, 6, 7 } }; + "]] + }} } diff --git a/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlElectric.lua b/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlElectric.lua index c9f129c28..6564b5f6a 100644 --- a/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlElectric.lua +++ b/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlElectric.lua @@ -41,7 +41,12 @@ declare { "]], examples = { { - options = [["preamble={\usetikzlibrary{graphs,graphdrawing} \usegdlibrary{force}}"]], + options = [[" + preamble={ + \usetikzlibrary{graphs.standard,graphdrawing} + \usegdlibrary{force} + }, + "]], code = [[" \tikz \graph [spring electrical layout, horizontal=0 to 1] { 0 [electric charge=1] -- subgraph C_n [n=10] }; diff --git a/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlIteration.lua b/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlIteration.lua index b8d96630c..a35ac62ee 100644 --- a/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlIteration.lua +++ b/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlIteration.lua @@ -47,17 +47,32 @@ declare { The examples shows two drawings generated using two different |iteration| limits. "]], - examples = {[[" - \tikz \graph [spring layout, iterations=10] { subgraph K_n [n=4] }; - "]],[[" - \tikz \graph [spring layout, iterations=500] { subgraph K_n [n=4] }; - "]],[[" - \tikz \graph [spring electrical layout, iterations=10] - { subgraph K_n [n=4] }; - "]],[[" - \tikz \graph [spring electrical layout, iterations=500] - { subgraph K_n [n=4] }; - "]] + examples = { + { + options = [[" + preamble={ + \usetikzlibrary{graphs.standard,graphdrawing} + \usegdlibrary{force} + }, + "]], + code = [[" + \tikz \graph [spring layout, iterations=10] { subgraph K_n [n=4] }; + "]] + },{ + code = [[" + \tikz \graph [spring layout, iterations=500] { subgraph K_n [n=4] }; + "]] + },{ + code = [[" + \tikz \graph [spring electrical layout, iterations=10] + { subgraph K_n [n=4] }; + "]] + },{ + code = [[" + \tikz \graph [spring electrical layout, iterations=500] + { subgraph K_n [n=4] }; + "]] + } } } @@ -97,13 +112,24 @@ declare { Hu2006 spring electrical, and Walshaw2000 spring electrical use a cooling factor of |0.95|. "]], - examples = {[[" - \tikz \graph [spring layout, cooling factor=0.1] - { a -> b -> c -> a }; - "]],[[" - \tikz \graph [spring layout, cooling factor=0.5] - { a -> b -> c -> a }; - "]] + examples = { + { + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{force} + }, + "]], + code = [[" + \tikz \graph [spring layout, cooling factor=0.1] + { a -> b -> c -> a }; + "]] + },{ + code = [[" + \tikz \graph [spring layout, cooling factor=0.5] + { a -> b -> c -> a }; + "]] + } } } @@ -120,17 +146,24 @@ declare { below $k \cdot \meta{tolerance}$. This tolerance factor can be changed with the convergence tolerance option: "]], - examples = {[[" - \tikz \graph [spring layout, convergence tolerance=0.001] - { { [clique] 1, 2 } -- 3 -- 4 -- { 5, 6, 7 } }; - "]],[[" - \tikz \graph [spring layout, convergence tolerance=1.0] - { { [clique] 1, 2 } -- 3 -- 4 -- { 5, 6, 7 } }; - "]] + examples = { + { + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{force} + }, + "]], + code = [[" + \tikz \graph [spring layout, convergence tolerance=0.001] + { { [clique] 1, 2 } -- 3 -- 4 -- { 5, 6, 7 } }; + "]] + },{ + code = [[" + \tikz \graph [spring layout, convergence tolerance=1.0] + { { [clique] 1, 2 } -- 3 -- 4 -- { 5, 6, 7 } }; + "]] + } } } - - - - diff --git a/tex/generic/pgf/graphdrawing/lua/pgf/gd/layered/Sugiyama.lua b/tex/generic/pgf/graphdrawing/lua/pgf/gd/layered/Sugiyama.lua index c91818dc3..3f26e27a1 100644 --- a/tex/generic/pgf/graphdrawing/lua/pgf/gd/layered/Sugiyama.lua +++ b/tex/generic/pgf/graphdrawing/lua/pgf/gd/layered/Sugiyama.lua @@ -71,27 +71,38 @@ declare { routing. This will look visually quite pleasing if you add the |rounded corners| option: "]], - examples = {[[" - \tikz \graph [layered layout, sibling distance=7mm] + examples = { { - a -> { - b, - c -> { d, e, f } - } -> - h -> - a - }; - "]],[[" - \tikz [rounded corners] \graph [layered layout, sibling distance=7mm] - { - a -> { - b, - c -> { d, e, f } - } -> - h -> - a - }; - "]] + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{layered} + }, + "]], + code = [[" + \tikz \graph [layered layout, sibling distance=7mm] + { + a -> { + b, + c -> { d, e, f } + } -> + h -> + a + }; + "]] + },{ + code = [[" + \tikz [rounded corners] \graph [layered layout, sibling distance=7mm] + { + a -> { + b, + c -> { d, e, f } + } -> + h -> + a + }; + "]] + } } } @@ -108,11 +119,19 @@ declare { causes an edge to become shorter, a larger |minimum layers| value causes an edge to be longer. "]], - examples = [[" - \tikz \graph [layered layout] { - a -- {b [> minimum layers=3], c, d} -- e -- a; - }; - "]] + examples = {{ + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{layered} + }, + "]], + code = [[" + \tikz \graph [layered layout] { + a -- {b [> minimum layers=3], c, d} -- e -- a; + }; + "]] + }} } @@ -127,42 +146,53 @@ declare { a on the same layer of a layered layout (this option is also known as |same rank|). You use it like this: "]], - examples = {[[" - \tikz \graph [layered layout] { - a -- b -- c -- d -- e; - - { [same layer] a, b }; - { [same layer] d, e }; - }; - "]],[[" - \tikz [rounded corners] \graph [layered layout] { - 1972 -> 1976 -> 1978 -> 1980 -> 1982 -> 1984 -> 1986 -> 1988 -> 1990 -> future; - - { [same layer] 1972, Thompson }; - { [same layer] 1976, Mashey, Bourne }, - { [same layer] 1978, Formshell, csh }, - { [same layer] 1980, esh, vsh }, - { [same layer] 1982, ksh, "System-V" }, - { [same layer] 1984, v9sh, tcsh }, - { [same layer] 1986, "ksh-i" }, - { [same layer] 1988, KornShell ,Perl, rc }, - { [same layer] 1990, tcl, Bash }, - { [same layer] "future", POSIX, "ksh-POSIX" }, - - Thompson -> { Mashey, Bourne, csh -> tcsh}, - Bourne -> { ksh, esh, vsh, "System-V", v9sh -> rc, Bash}, - { "ksh-i", KornShell } -> Bash, - { esh, vsh, Formshell, csh } -> ksh, - { KornShell, "System-V" } -> POSIX, - ksh -> "ksh-i" -> KornShell -> "ksh-POSIX", - Bourne -> Formshell, - - { [edge={draw=none}] - Bash -> tcl, - KornShell -> Perl - } - }; - "]] + examples = { + { + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{layered} + }, + "]], + code = [[" + \tikz \graph [layered layout] { + a -- b -- c -- d -- e; + + { [same layer] a, b }; + { [same layer] d, e }; + }; + "]] + },{ + code = [[" + \tikz [rounded corners] \graph [layered layout] { + 1972 -> 1976 -> 1978 -> 1980 -> 1982 -> 1984 -> 1986 -> 1988 -> 1990 -> future; + + { [same layer] 1972, Thompson }; + { [same layer] 1976, Mashey, Bourne }, + { [same layer] 1978, Formshell, csh }, + { [same layer] 1980, esh, vsh }, + { [same layer] 1982, ksh, "System-V" }, + { [same layer] 1984, v9sh, tcsh }, + { [same layer] 1986, "ksh-i" }, + { [same layer] 1988, KornShell ,Perl, rc }, + { [same layer] 1990, tcl, Bash }, + { [same layer] "future", POSIX, "ksh-POSIX" }, + + Thompson -> { Mashey, Bourne, csh -> tcsh}, + Bourne -> { ksh, esh, vsh, "System-V", v9sh -> rc, Bash}, + { "ksh-i", KornShell } -> Bash, + { esh, vsh, Formshell, csh } -> ksh, + { KornShell, "System-V" } -> POSIX, + ksh -> "ksh-i" -> KornShell -> "ksh-POSIX", + Bourne -> Formshell, + + { [edge={draw=none}] + Bash -> tcl, + KornShell -> Perl + } + }; + "]] + } } } diff --git a/tex/generic/pgf/graphdrawing/lua/pgf/gd/pedigrees/Koerner2015.lua b/tex/generic/pgf/graphdrawing/lua/pgf/gd/pedigrees/Koerner2015.lua index 32927530a..493405039 100644 --- a/tex/generic/pgf/graphdrawing/lua/pgf/gd/pedigrees/Koerner2015.lua +++ b/tex/generic/pgf/graphdrawing/lua/pgf/gd/pedigrees/Koerner2015.lua @@ -73,16 +73,19 @@ declare { documentation = [[" ... "]], - examples = [[" - \tikz \graph [simple pedigree layout, default edge operator=complete bipartite] - { - Eve -- [mate] Felix; - { Eve, Felix } -> [child] { George, Hank }; - - Alice -- [mate] Bob; - { Alice, Bob } -> [child] { Charly, Dave, Eve }; - }; - "]] + examples = {{ + options = [["preamble={\usetikzlibrary{graphs,graphdrawing}"]], + code = [[" + \tikz \graph [simple pedigree layout, default edge operator=complete bipartite] + { + Eve -- [mate] Felix; + { Eve, Felix } -> [child] { George, Hank }; + + Alice -- [mate] Bob; + { Alice, Bob } -> [child] { Charly, Dave, Eve }; + }; + "]] + }} } diff --git a/tex/generic/pgf/graphdrawing/lua/pgf/gd/phylogenetics/AuthorDefinedPhylogeny.lua b/tex/generic/pgf/graphdrawing/lua/pgf/gd/phylogenetics/AuthorDefinedPhylogeny.lua index 04e1ca49f..379296687 100644 --- a/tex/generic/pgf/graphdrawing/lua/pgf/gd/phylogenetics/AuthorDefinedPhylogeny.lua +++ b/tex/generic/pgf/graphdrawing/lua/pgf/gd/phylogenetics/AuthorDefinedPhylogeny.lua @@ -43,16 +43,24 @@ declare { The evolutionary length of the edges must be specified through the use of the |length| key for each edge. "]], - examples = [[" - \tikz \graph [phylogenetic tree layout] { - a -- { - b [>length=2] --[length=1] { c, d }, - e [>length=3] - } - }; - "]] + examples = {{ + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{phylogenetics,trees} + }, + "]], + code = [[" + \tikz \graph [phylogenetic tree layout] { + a -- { + b [>length=2] --[length=1] { c, d }, + e [>length=3] + } + }; + "]] + }} } - + function AuthorDefinedPhylogeny:run() diff --git a/tex/generic/pgf/graphdrawing/lua/pgf/gd/phylogenetics/BalancedMinimumEvolution.lua b/tex/generic/pgf/graphdrawing/lua/pgf/gd/phylogenetics/BalancedMinimumEvolution.lua index ef40f0ee6..2a73ecde6 100644 --- a/tex/generic/pgf/graphdrawing/lua/pgf/gd/phylogenetics/BalancedMinimumEvolution.lua +++ b/tex/generic/pgf/graphdrawing/lua/pgf/gd/phylogenetics/BalancedMinimumEvolution.lua @@ -47,20 +47,28 @@ declare { nodes. After every insertion the distance matrix has to be updated. "]], - examples = [[" - \tikz \graph [phylogenetic tree layout, - balanced minimum evolution, - grow'=right, sibling distance=0pt, - distance matrix={ - 0 4 9 9 9 9 9 - 4 0 9 9 9 9 9 - 9 9 0 2 7 7 7 - 9 9 2 0 7 7 7 - 9 9 7 7 0 3 5 - 9 9 7 7 3 0 5 - 9 9 7 7 5 5 0}] - { a, b, c, d, e, f, g }; - "]] + examples = {{ + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{phylogenetics} + }, + "]], + code = [[" + \tikz \graph [phylogenetic tree layout, + balanced minimum evolution, + grow'=right, sibling distance=0pt, + distance matrix={ + 0 4 9 9 9 9 9 + 4 0 9 9 9 9 9 + 9 9 0 2 7 7 7 + 9 9 2 0 7 7 7 + 9 9 7 7 0 3 5 + 9 9 7 7 3 0 5 + 9 9 7 7 5 5 0}] + { a, b, c, d, e, f, g }; + "]] + }} } diff --git a/tex/generic/pgf/graphdrawing/lua/pgf/gd/phylogenetics/Maeusle2012.lua b/tex/generic/pgf/graphdrawing/lua/pgf/gd/phylogenetics/Maeusle2012.lua index a9acc4886..712e26e55 100644 --- a/tex/generic/pgf/graphdrawing/lua/pgf/gd/phylogenetics/Maeusle2012.lua +++ b/tex/generic/pgf/graphdrawing/lua/pgf/gd/phylogenetics/Maeusle2012.lua @@ -52,20 +52,28 @@ declare { documentation = [[" ... "]], - examples = [[" - \tikz \graph [phylogenetic tree layout, - rooted rectangular phylogram, - balanced minimum evolution, - distance matrix={ - 0 4 9 9 9 9 9 - 4 0 9 9 9 9 9 - 9 9 0 2 7 7 7 - 9 9 2 0 7 7 7 - 9 9 7 7 0 3 5 - 9 9 7 7 3 0 5 - 9 9 7 7 5 5 0}] - { a, b, c, d, e, f, g }; - "]] + examples = {{ + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{phylogenetics} + }, + "]], + code = [[" + \tikz \graph [phylogenetic tree layout, + rooted rectangular phylogram, + balanced minimum evolution, + distance matrix={ + 0 4 9 9 9 9 9 + 4 0 9 9 9 9 9 + 9 9 0 2 7 7 7 + 9 9 2 0 7 7 7 + 9 9 7 7 0 3 5 + 9 9 7 7 3 0 5 + 9 9 7 7 5 5 0}] + { a, b, c, d, e, f, g }; + "]] + }} } --- @@ -94,20 +102,29 @@ declare { documentation = [[" ... "]], - examples = [[" - \tikz \graph [phylogenetic tree layout, - rooted straight phylogram, - balanced minimum evolution, grow=right, - distance matrix={ - 0 4 9 9 9 9 9 - 4 0 9 9 9 9 9 - 9 9 0 2 7 7 7 - 9 9 2 0 7 7 7 - 9 9 7 7 0 3 5 - 9 9 7 7 3 0 5 - 9 9 7 7 5 5 0}] - { a, b, c, d, e, f, g }; - "]]} + examples = {{ + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{phylogenetics} + }, + "]], + code = [[" + \tikz \graph [phylogenetic tree layout, + rooted straight phylogram, + balanced minimum evolution, grow=right, + distance matrix={ + 0 4 9 9 9 9 9 + 4 0 9 9 9 9 9 + 9 9 0 2 7 7 7 + 9 9 2 0 7 7 7 + 9 9 7 7 0 3 5 + 9 9 7 7 3 0 5 + 9 9 7 7 5 5 0}] + { a, b, c, d, e, f, g }; + "]] + }} +} --- declare { @@ -134,20 +151,28 @@ declare { documentation = [[" ... "]], - examples = [[" - \tikz \graph [phylogenetic tree layout, - unrooted rectangular phylogram, - balanced minimum evolution, grow=right, - distance matrix={ - 0 4 9 9 9 9 9 - 4 0 9 9 9 9 9 - 9 9 0 2 7 7 7 - 9 9 2 0 7 7 7 - 9 9 7 7 0 3 5 - 9 9 7 7 3 0 5 - 9 9 7 7 5 5 0}] - { a, b, c, d, e, f, g }; - "]] + examples = {{ + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{phylogenetics} + }, + "]], + code = [[" + \tikz \graph [phylogenetic tree layout, + unrooted rectangular phylogram, + balanced minimum evolution, grow=right, + distance matrix={ + 0 4 9 9 9 9 9 + 4 0 9 9 9 9 9 + 9 9 0 2 7 7 7 + 9 9 2 0 7 7 7 + 9 9 7 7 0 3 5 + 9 9 7 7 3 0 5 + 9 9 7 7 5 5 0}] + { a, b, c, d, e, f, g }; + "]] + }} } --- @@ -168,20 +193,28 @@ declare { documentation = [[" ... "]], - examples = [[" - \tikz \graph [phylogenetic tree layout, - unrooted straight phylogram, - balanced minimum evolution, grow=right, - distance matrix={ - 0 4 9 9 9 9 9 - 4 0 9 9 9 9 9 - 9 9 0 2 7 7 7 - 9 9 2 0 7 7 7 - 9 9 7 7 0 3 5 - 9 9 7 7 3 0 5 - 9 9 7 7 5 5 0}] - { a, b, c, d, e, f, g }; - "]] + examples = {{ + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{phylogenetics} + }, + "]], + code = [[" + \tikz \graph [phylogenetic tree layout, + unrooted straight phylogram, + balanced minimum evolution, grow=right, + distance matrix={ + 0 4 9 9 9 9 9 + 4 0 9 9 9 9 9 + 9 9 0 2 7 7 7 + 9 9 2 0 7 7 7 + 9 9 7 7 0 3 5 + 9 9 7 7 3 0 5 + 9 9 7 7 5 5 0}] + { a, b, c, d, e, f, g }; + "]] + }} } diff --git a/tex/generic/pgf/graphdrawing/lua/pgf/gd/phylogenetics/PhylogeneticTree.lua b/tex/generic/pgf/graphdrawing/lua/pgf/gd/phylogenetics/PhylogeneticTree.lua index 242ccf183..f79902dc3 100644 --- a/tex/generic/pgf/graphdrawing/lua/pgf/gd/phylogenetics/PhylogeneticTree.lua +++ b/tex/generic/pgf/graphdrawing/lua/pgf/gd/phylogenetics/PhylogeneticTree.lua @@ -40,18 +40,26 @@ declare { documentation = [[" ... "]], - examples = [[" - \tikz \graph [phylogenetic tree layout, upgma, - distance matrix={ - 0 4 9 9 9 9 9 - 4 0 9 9 9 9 9 - 9 9 0 2 7 7 7 - 9 9 2 0 7 7 7 - 9 9 7 7 0 3 5 - 9 9 7 7 3 0 5 - 9 9 7 7 5 5 0}] - { a, b, c, d, e, f, g }; - "]] + examples = {{ + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{phylogenetics} + }, + "]], + code = [[" + \tikz \graph [phylogenetic tree layout, upgma, + distance matrix={ + 0 4 9 9 9 9 9 + 4 0 9 9 9 9 9 + 9 9 0 2 7 7 7 + 9 9 2 0 7 7 7 + 9 9 7 7 0 3 5 + 9 9 7 7 3 0 5 + 9 9 7 7 5 5 0}] + { a, b, c, d, e, f, g }; + "]] + }} } diff --git a/tex/generic/pgf/graphdrawing/lua/pgf/gd/phylogenetics/SokalMichener1958.lua b/tex/generic/pgf/graphdrawing/lua/pgf/gd/phylogenetics/SokalMichener1958.lua index 6a665b673..7485bcead 100644 --- a/tex/generic/pgf/graphdrawing/lua/pgf/gd/phylogenetics/SokalMichener1958.lua +++ b/tex/generic/pgf/graphdrawing/lua/pgf/gd/phylogenetics/SokalMichener1958.lua @@ -45,19 +45,27 @@ declare { This algorithm uses a distance matrix, ideally an ultrametric one, to compute the graph. "]], - examples = [[" - \tikz \graph [phylogenetic tree layout, sibling distance=0pt, sibling sep=2pt, - unweighted pair group method using arithmetic averages, - distance matrix={ - 0 4 9 9 9 9 9 - 4 0 9 9 9 9 9 - 9 9 0 2 7 7 7 - 9 9 2 0 7 7 7 - 9 9 7 7 0 3 5 - 9 9 7 7 3 0 5 - 9 9 7 7 5 5 0}] - { a, b, c, d, e, f, g }; - "]] + examples = {{ + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{phylogenetics} + }, + "]], + code = [[" + \tikz \graph [phylogenetic tree layout, sibling distance=0pt, sibling sep=2pt, + unweighted pair group method using arithmetic averages, + distance matrix={ + 0 4 9 9 9 9 9 + 4 0 9 9 9 9 9 + 9 9 0 2 7 7 7 + 9 9 2 0 7 7 7 + 9 9 7 7 0 3 5 + 9 9 7 7 3 0 5 + 9 9 7 7 5 5 0}] + { a, b, c, d, e, f, g }; + "]] + }} } diff --git a/tex/generic/pgf/graphdrawing/lua/pgf/gd/planar/PlanarLayout.lua b/tex/generic/pgf/graphdrawing/lua/pgf/gd/planar/PlanarLayout.lua index 9e5b8d72e..c31bacb89 100644 --- a/tex/generic/pgf/graphdrawing/lua/pgf/gd/planar/PlanarLayout.lua +++ b/tex/generic/pgf/graphdrawing/lua/pgf/gd/planar/PlanarLayout.lua @@ -31,16 +31,22 @@ InterfaceToAlgorithms.declare { documentation = [[" The planar layout is a pipeline of algorithms to produce a crossings-free drawing of a planar graph. - First a combinatorical embedding of the graph is created using + First a combinatorial embedding of the graph is created using the Algorithm from Boyer and Myrvold. - The combinatorical Embedding is then being improved by + The combinatorial Embedding is then being improved by by the Sort and Flip algorithm and triangulated afterwards. To determine the actual node positions the shift method by de Fraysseix, Pach and Pollack is used. Finally the force based Planar Drawing Postprocessing improves the drawing. "]], - examples = { - [[" + examples = {{ + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{trees} + }, + "]], + code = [[" \tikz \graph [nodes={draw, circle}] { a -- { b -- { @@ -59,9 +65,9 @@ InterfaceToAlgorithms.declare { f --[no span edge] g, c --[no span edge] d, e --[no span edge] c - } + }; "]] - } + }} } function PlanarLayout:run() diff --git a/tex/generic/pgf/graphdrawing/lua/pgf/gd/planar/parameters.lua b/tex/generic/pgf/graphdrawing/lua/pgf/gd/planar/parameters.lua index 603f2ee7c..bbfc44f98 100644 --- a/tex/generic/pgf/graphdrawing/lua/pgf/gd/planar/parameters.lua +++ b/tex/generic/pgf/graphdrawing/lua/pgf/gd/planar/parameters.lua @@ -19,7 +19,7 @@ declare { summary = [[" Whether or not to use the Sort and Flip Algorithm - to improve the combinatorical embedding. + to improve the combinatorial embedding. "]] } diff --git a/tex/generic/pgf/graphdrawing/lua/pgf/gd/routing/NecklaceRouting.lua b/tex/generic/pgf/graphdrawing/lua/pgf/gd/routing/NecklaceRouting.lua index defcf9f8c..e468d1ebb 100644 --- a/tex/generic/pgf/graphdrawing/lua/pgf/gd/routing/NecklaceRouting.lua +++ b/tex/generic/pgf/graphdrawing/lua/pgf/gd/routing/NecklaceRouting.lua @@ -50,13 +50,21 @@ declare { to 7 in the example. "]], - examples = [[" - \tikz \graph [simple necklace layout, node distance=1.5cm, - necklace routing, - nodes={draw,circle}, edges={>={Stealth[round,sep,bend]}}] - { 1 -> 2 [minimum size=30pt] <- 3 <-> 4 -- - 5 -- 6 -- [bend left] 7 -- 1 -- 4 }; + examples = {{ + options = [[" + preamble={ + \usetikzlibrary{arrows.meta,bending,graphs,graphdrawing} + \usegdlibrary{circular,routing} + }, + "]], + code = [[" + \tikz \graph [simple necklace layout, node distance=1.5cm, + necklace routing, + nodes={draw,circle}, edges={>={Stealth[round,sep,bend]}}] + { 1 -> 2 [minimum size=30pt] <- 3 <-> 4 -- + 5 -- 6 -- [bend left] 7 -- 1 -- 4 }; "]] + }} } diff --git a/tex/generic/pgf/graphdrawing/lua/pgf/gd/trees/ChildSpec.lua b/tex/generic/pgf/graphdrawing/lua/pgf/gd/trees/ChildSpec.lua index 815f90d26..ca898bde8 100644 --- a/tex/generic/pgf/graphdrawing/lua/pgf/gd/trees/ChildSpec.lua +++ b/tex/generic/pgf/graphdrawing/lua/pgf/gd/trees/ChildSpec.lua @@ -101,10 +101,18 @@ declare { every node with a single child, this child will be the first child and the second child will be missing. "]], - examples = [[" - \tikz \graph [binary tree layout,level distance=5mm] - { a -> { b->c->d, e->f->g } }; - "]] + examples = {{ + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{trees} + }, + "]], + code = [[" + \tikz \graph [binary tree layout,level distance=5mm] + { a -> { b->c->d, e->f->g } }; + "]] + }} } --- @@ -151,22 +159,39 @@ declare { the |right| and |left| keys are already in use for anchoring. Naturally, you can locally redefine them, if you want. "]], - examples = {[[" - \tikz \graph [binary tree layout, level distance=5mm] - { a -> b[second] }; - "]],[[" - \tikz \graph [binary tree layout, level distance=5mm] - { a -> { b[second], c} }; - "]],[[" - \tikz \graph [binary tree layout, level distance=5mm] - { a -> { b, c[first]} }; - "]],[[" - \tikz \graph [binary tree layout, level distance=5mm] - { a -> { b[second], c[second]} }; - "]],[[" - \tikz \graph [binary tree layout, level distance=5mm] - { a -> { b[third], c[first], d} }; - "]] + examples = { + { + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{trees} + }, + "]], + code = [[" + \tikz \graph [binary tree layout, level distance=5mm] + { a -> b[second] }; + "]] + },{ + code = [[" + \tikz \graph [binary tree layout, level distance=5mm] + { a -> { b[second], c} }; + "]] + },{ + code = [[" + \tikz \graph [binary tree layout, level distance=5mm] + { a -> { b, c[first]} }; + "]] + },{ + code = [[" + \tikz \graph [binary tree layout, level distance=5mm] + { a -> { b[second], c[second]} }; + "]] + },{ + code = [[" + \tikz \graph [binary tree layout, level distance=5mm] + { a -> { b[third], c[first], d} }; + "]] + } } } diff --git a/tex/generic/pgf/graphdrawing/lua/pgf/gd/trees/SpanningTreeComputation.lua b/tex/generic/pgf/graphdrawing/lua/pgf/gd/trees/SpanningTreeComputation.lua index dacf63486..7f7f4f7f5 100644 --- a/tex/generic/pgf/graphdrawing/lua/pgf/gd/trees/SpanningTreeComputation.lua +++ b/tex/generic/pgf/graphdrawing/lua/pgf/gd/trees/SpanningTreeComputation.lua @@ -237,20 +237,28 @@ declare { preferred in the computation of the spanning tree, but use |no span edge| to cause the algorithm to ignore these edges. "]], - examples = [[" - \tikz \graph [tree layout, nodes={draw}, sibling distance=0pt, - every group/.style={ - default edge kind=->, no span edge, - path=source}] - { - 5 -> { - "1,3" -> {0,2,4}, - 11 -> { - "7,9" -> { 6, 8, 10 } + examples = {{ + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{trees} + }, + "]], + code = [[" + \tikz \graph [tree layout, nodes={draw}, sibling distance=0pt, + every group/.style={ + default edge kind=->, no span edge, + path=source}] + { + 5 -> { + "1,3" -> {0,2,4}, + 11 -> { + "7,9" -> { 6, 8, 10 } + } } - } - }; - "]] + }; + "]] + }} } @@ -406,16 +414,24 @@ declare { This strategy is nice with trees specified with both forward and backward edges. "]], - examples = [[" - \tikz \graph [tree layout, nodes={draw}, sibling distance=0pt, - span using directed] - { - 3 <- 5[root] -> 8, - 1 <- 3 -> 4, - 7 <- 8 -> 9, - 1 -- 4 -- 7 -- 9 - }; - "]] + examples = {{ + options = [[" + preamble={ + \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{trees} + }, + "]], + code = [[" + \tikz \graph [tree layout, nodes={draw}, sibling distance=0pt, + span using directed] + { + 3 <- 5[root] -> 8, + 1 <- 3 -> 4, + 7 <- 8 -> 9, + 1 -- 4 -- 7 -- 9 + }; + "]] + }} } ---