texlive[47148] Master/texmf-dist: adigraph (27mar18)
commits+karl at tug.org
commits+karl at tug.org
Tue Mar 27 23:24:17 CEST 2018
Revision: 47148
http://tug.org/svn/texlive?view=revision&revision=47148
Author: karl
Date: 2018-03-27 23:24:17 +0200 (Tue, 27 Mar 2018)
Log Message:
-----------
adigraph (27mar18)
Modified Paths:
--------------
trunk/Master/texmf-dist/doc/latex/adigraph/README.md
trunk/Master/texmf-dist/doc/latex/adigraph/adigraph_documentation.pdf
trunk/Master/texmf-dist/doc/latex/adigraph/adigraph_documentation.tex
trunk/Master/texmf-dist/doc/latex/adigraph/adigraph_working_test.pdf
trunk/Master/texmf-dist/doc/latex/adigraph/adigraph_working_test.tex
trunk/Master/texmf-dist/tex/latex/adigraph/adigraph.sty
Added Paths:
-----------
trunk/Master/texmf-dist/doc/latex/adigraph/adigraph-large.png
Modified: trunk/Master/texmf-dist/doc/latex/adigraph/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/adigraph/README.md 2018-03-27 21:24:05 UTC (rev 47147)
+++ trunk/Master/texmf-dist/doc/latex/adigraph/README.md 2018-03-27 21:24:17 UTC (rev 47148)
@@ -29,9 +29,7 @@
Suppose you want to create a graph as the following, with an augmenting path highlighted and a couple of cuts:
-<p align="center">
- <img src="https://github.com/LucaCappelletti94/adigraph/blob/master/img_examples/example_3.jpg?raw=true" width="600px">
-</p>
+![Basic example](https://github.com/LucaCappelletti94/adigraph/blob/master/img_examples/example_3.jpg?raw=true)
We start by defining a new graph, called *myAdigraph*:
@@ -63,9 +61,8 @@
\myAdigraph{}
```
-<p align="center">
- <img src="https://github.com/LucaCappelletti94/adigraph/blob/master/img_examples/example_0.jpg?raw=true" width="600px">
-</p>
+![First adigraph](https://github.com/LucaCappelletti94/adigraph/blob/master/img_examples/example_0.jpg?raw=true)
+
Then we can add the augmenting path as follows:
```latex
@@ -74,9 +71,7 @@
}
```
-<p align="center">
- <img src="https://github.com/LucaCappelletti94/adigraph/blob/master/img_examples/example_1.jpg?raw=true" width="600px">
-</p>
+![Augmenting adigraph](https://github.com/LucaCappelletti94/adigraph/blob/master/img_examples/example_1.jpg?raw=true)
And the cuts (remember that the paths from previous steps are memorized by the library) are added as follows:
@@ -89,9 +84,7 @@
The result with the cuts is the following:
-<p align="center">
- <img src="https://github.com/LucaCappelletti94/adigraph/blob/master/img_examples/example_2.jpg?raw=true" width="600px">
-</p>
+![Cuts adigraph](https://github.com/LucaCappelletti94/adigraph/blob/master/img_examples/example_2.jpg?raw=true)
You can add both cuts and paths at the same time to keep the latest path highlighted:
@@ -104,9 +97,7 @@
}
```
-<p align="center">
- <img src="https://github.com/LucaCappelletti94/adigraph/blob/master/img_examples/example_3.jpg?raw=true" width="600px">
-</p>
+![Cuts adigraph](https://github.com/LucaCappelletti94/adigraph/blob/master/img_examples/example_3.jpg?raw=true)
Have a nice day!
Added: trunk/Master/texmf-dist/doc/latex/adigraph/adigraph-large.png
===================================================================
(Binary files differ)
Index: trunk/Master/texmf-dist/doc/latex/adigraph/adigraph-large.png
===================================================================
--- trunk/Master/texmf-dist/doc/latex/adigraph/adigraph-large.png 2018-03-27 21:24:05 UTC (rev 47147)
+++ trunk/Master/texmf-dist/doc/latex/adigraph/adigraph-large.png 2018-03-27 21:24:17 UTC (rev 47148)
Property changes on: trunk/Master/texmf-dist/doc/latex/adigraph/adigraph-large.png
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Modified: trunk/Master/texmf-dist/doc/latex/adigraph/adigraph_documentation.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/doc/latex/adigraph/adigraph_documentation.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/adigraph/adigraph_documentation.tex 2018-03-27 21:24:05 UTC (rev 47147)
+++ trunk/Master/texmf-dist/doc/latex/adigraph/adigraph_documentation.tex 2018-03-27 21:24:17 UTC (rev 47148)
@@ -637,7 +637,64 @@
\subsection{Combining Kleene operations}
Sadly, operations such as \textit{<*,+>} or \textit{<+,+>} are not currently supported and not for lack of trying. I'll try implementing them again in the future when I'll have more time.
-\section{Augmenting paths}
+\section{Paths}
+A path is specified by the following syntax: \textit{<comma separated list of nodes>}.
+
+\NewAdigraph{myPathsTestAdigraph}{
+ s:0,0;
+ 1:2,2;
+ 3:2,-2;
+ 2:6,2;
+ 4:6,-2;
+ t:8,0;
+}{
+ s,1:25;
+ s,3:25;
+ 3,4:25;
+ 1,2:35;
+ 2,t:20;
+ 4,t:30;
+ 3,1:10;
+ 4,2:10;
+ 2,3:15::near start;
+ 4,1:5::near start;
+}
+
+\begin{figure}
+ \begin{subfigure}{0.49\textwidth}
+ \begin{minted}{latex}
+\NewAdigraph{myAdigraph}{
+ s:0,0;
+ 1:2,2;
+ 3:2,-2;
+ 2:6,2;
+ 4:6,-2;
+ t:8,0;
+}{
+ s,1:25;
+ s,3:25;
+ 3,4:25;
+ 1,2:35;
+ 2,t:20;
+ 4,t:30;
+ 3,1:10;
+ 4,2:10;
+ 2,3:15::near start;
+ 4,1:5::near start;
+}
+\myAdigraph{
+ s,3,4,2,t;
+}
+\end{minted}
+ \end{subfigure}
+ \begin{subfigure}{0.49\textwidth}
+ \myPathsTestAdigraph{
+ s,3,4,2,t;
+ }
+ \end{subfigure}
+\end{figure}
+
+\subsection{Augmenting paths}
An augmenting path is specified by the following syntax: \textit{<comma separated list of nodes:units>}. It is \textbf{very important} to note that incremental paths called upon the same object are memorized by default.
\NewAdigraph{myAdigraph}{
@@ -771,8 +828,123 @@
\end{subfigure}
\end{figure}
+\subsection{Custom colored augmenting Paths}
+A path is specified by the following syntax: \textit{<comma separated list of nodes>:<units>:<forward path color, backward path color>}.
+
+\NewAdigraph{myCustomAugmentingPathAdigraph}{
+ s:0,0;
+ 1:2,2;
+ 3:2,-2;
+ 2:6,2;
+ 4:6,-2;
+ t:8,0;
+}{
+ s,1:25;
+ s,3:25;
+ 3,4:25;
+ 1,2:35;
+ 2,t:20;
+ 4,t:30;
+ 3,1:10;
+ 4,2:10;
+ 2,3:15::near start;
+ 4,1:5::near start;
+}
+
+\begin{figure}
+ \begin{subfigure}{0.49\textwidth}
+ \begin{minted}{latex}
+\NewAdigraph{myAdigraph}{
+ s:0,0;
+ 1:2,2;
+ 3:2,-2;
+ 2:6,2;
+ 4:6,-2;
+ t:8,0;
+}{
+ s,1:25;
+ s,3:25;
+ 3,4:25;
+ 1,2:35;
+ 2,t:20;
+ 4,t:30;
+ 3,1:10;
+ 4,2:10;
+ 2,3:15::near start;
+ 4,1:5::near start;
+}
+\myAdigraph{
+ s,3,4,2,t:5:green,blue;
+}
+\end{minted}
+ \end{subfigure}
+ \begin{subfigure}{0.49\textwidth}
+ \myCustomAugmentingPathAdigraph{
+ s,3,4,2,t:5:green,blue;
+ }
+ \end{subfigure}
+\end{figure}
+
+\subsection{Custom colored Paths}
+A path is specified by the following syntax: \textit{<comma separated list of nodes>::<forward path color, backward path color>}. \textbf{Note the double colons!}.
+
+\NewAdigraph{myCustomPathAdigraph}{
+ s:0,0;
+ 1:2,2;
+ 3:2,-2;
+ 2:6,2;
+ 4:6,-2;
+ t:8,0;
+}{
+ s,1:25;
+ s,3:25;
+ 3,4:25;
+ 1,2:35;
+ 2,t:20;
+ 4,t:30;
+ 3,1:10;
+ 4,2:10;
+ 2,3:15::near start;
+ 4,1:5::near start;
+}
+
+\begin{figure}
+ \begin{subfigure}{0.49\textwidth}
+ \begin{minted}{latex}
+\NewAdigraph{myAdigraph}{
+ s:0,0;
+ 1:2,2;
+ 3:2,-2;
+ 2:6,2;
+ 4:6,-2;
+ t:8,0;
+}{
+ s,1:25;
+ s,3:25;
+ 3,4:25;
+ 1,2:35;
+ 2,t:20;
+ 4,t:30;
+ 3,1:10;
+ 4,2:10;
+ 2,3:15::near start;
+ 4,1:5::near start;
+}
+\myAdigraph{
+ s,3,4,2,t::green;
+ s,1,2::red;
+}
+\end{minted}
+ \end{subfigure}
+ \begin{subfigure}{0.49\textwidth}
+ \myCustomPathAdigraph{
+ s,1,2::red;
+ s,3,4,2,t::green;
+ }
+ \end{subfigure}
+\end{figure}
+
\section{Cuts}
-
The following is to add cuts to show minimum cuts for example, the syntax is: \textit{<first node, second node;>}
\begin{figure}
@@ -793,7 +965,7 @@
\end{figure}
\subsection{Colored cuts}
-If you'd like to color the cuts you just have to add the color as follows: \textit{<first node, second node, color;>}
+If you'd like to color the cuts you just have to add the color as follows: \textit{<first node, second node, color;>}. \textbf{Note that if you want to only add a cut and not an augmenting path and a cut, you still need to add the empty curly braces \{\}.}
\begin{figure}
\begin{subfigure}{0.49\textwidth}
@@ -801,6 +973,7 @@
\myAdigraph{}{
3,4,red;
2,t,blue;
+ 2,4,green;
}
\end{minted}
\end{subfigure}
Modified: trunk/Master/texmf-dist/doc/latex/adigraph/adigraph_working_test.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/doc/latex/adigraph/adigraph_working_test.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/adigraph/adigraph_working_test.tex 2018-03-27 21:24:05 UTC (rev 47147)
+++ trunk/Master/texmf-dist/doc/latex/adigraph/adigraph_working_test.tex 2018-03-27 21:24:17 UTC (rev 47148)
@@ -100,6 +100,51 @@
3,4,blue;
}
\end{figure}
+
+ \NewAdigraph{myForthAdigraph}{
+ 1:4;
+ 2:4;
+ 3:4;
+ 4:4;
+ 5:4;
+ 6:4;
+ 7:4;
+ 8:4;
+ }{
+ 1,2:5;
+ 2,3:5;
+ 3,4:5;
+ 4,5:5;
+ 5,6:5;
+ }
+
+ \begin{figure}
+ \myForthAdigraph{
+ 1,2,3:0;
+ }
+ \end{figure}
+
+ \NewAdigraph{myFifthAdigraph}{
+ 1:4;
+ 2:4;
+ 3:4;
+ 4:4;
+ 5:4;
+ 6:4;
+ 7:4;
+ 8:4;
+ }{
+ 1,*,red;
+ *,4,blue;
+ 2,3;
+ 3,4;
+ }
+
+ \begin{figure}
+ \myFifthAdigraph{
+ 2,3,4::purple;
+ }
+ \end{figure}
\end{center}
\end{document}
\ No newline at end of file
Modified: trunk/Master/texmf-dist/tex/latex/adigraph/adigraph.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/adigraph/adigraph.sty 2018-03-27 21:24:05 UTC (rev 47147)
+++ trunk/Master/texmf-dist/tex/latex/adigraph/adigraph.sty 2018-03-27 21:24:17 UTC (rev 47148)
@@ -7,11 +7,11 @@
%
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
%
-\def\AdigraphVersionNumber{v1.4.1}
+\def\AdigraphVersionNumber{v1.5.1}
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{adigraph}
-[2018/03/11 \AdigraphVersionNumber LaTeX package for creating augmenting directed graphs]
+[2018/03/27 \AdigraphVersionNumber LaTeX package for creating augmenting directed graphs]
\RequirePackage{etoolbox}
\RequirePackage{fp}
@@ -54,46 +54,6 @@
\ifbool{adigraphEdge#1v#2Drawn}{%
% This edge was already drawn
}{%
- \letcs{\firstX}{adigraphNode#1X}
- \letcs{\firstY}{adigraphNode#1Y}
- \letcs{\secondX}{adigraphNode#2X}
- \letcs{\secondY}{adigraphNode#2Y}
-
- \providebool{equalX}
- \FPifeq{\firstX}{\secondX}
- \booltrue{equalX}
- \else
- \boolfalse{equalX}
- \fi
-
- \providebool{ltX}
- \FPiflt{\firstX}{\secondX}
- \booltrue{ltX}
- \else
- \boolfalse{ltX}
- \fi
-
- \providebool{ltY}
- \FPiflt{\firstY}{\secondY}
- \booltrue{ltY}
- \else
- \boolfalse{ltY}
- \fi
-
- \ifbool{ltX}{%
- \def\AdigraphLabelPosition{above}
- }{%
- \ifbool{equalX}{%
- \ifbool{ltY}{%
- \def\AdigraphLabelPosition{left}
- }{%
- \def\AdigraphLabelPosition{right}
- }
- }{%
- \def\AdigraphLabelPosition{below}
- }
- }
-
\booltrue{adigraphEdge#1v#2Drawn}
\letcs{\edgeLabelPosition}{adigraphEdge#1v#2LabelPosition}
\letcs{\edgeWeight}{adigraphEdge#1v#2Weight}
@@ -128,7 +88,11 @@
\ifbool{secondWeight}{%
% The twin edge won't be drawn
% This edge will be a straight line
- \draw[edge,\edgeColor] (#1) to node[\edgeLabelPosition, \AdigraphLabelPosition] {\edgeLabel}(#2);
+ \ifbool{adigraphEdge#1v#2HasEmptyLabel}{
+ \draw[edge,\edgeColor] (#1) to (#2);
+ }{
+ \draw[edge,\edgeColor] (#1) to node[\edgeLabelPosition, fill=white] {\edgeLabel}(#2);
+ }
}{%
\IfEq{#1}{#2}{
% This is a self loop
@@ -175,10 +139,18 @@
}
\pgfmathsetmacro{\leftAngle}{\centralAngle-35}
\pgfmathsetmacro{\rightAngle}{\centralAngle+35}
- \draw[edge,\edgeColor] (#1) to [out=\leftAngle,in=\rightAngle,looseness=8] node[\edgeLabelPosition, \AdigraphLabelPosition] {\edgeLabel}(#1);
+ \ifbool{adigraphEdge#1v#2HasEmptyLabel}{
+ \draw[edge,\edgeColor] (#1) to [out=\leftAngle,in=\rightAngle,looseness=8](#1);
+ }{
+ \draw[edge,\edgeColor] (#1) to [out=\leftAngle,in=\rightAngle,looseness=8] node[\edgeLabelPosition, fill=white] {\edgeLabel}(#1);
+ }
}{
% Both edges have to be drawn, they will be curly
- \draw[edge,\edgeColor] (#1) to [bend right=20] node[\edgeLabelPosition, \AdigraphLabelPosition] {\edgeLabel}(#2);
+ \ifbool{adigraphEdge#1v#2HasEmptyLabel}{
+ \draw[edge,\edgeColor] (#1) to [bend right=20] (#2);
+ }{
+ \draw[edge,\edgeColor] (#1) to [bend right=20] node[\edgeLabelPosition, fill=white] {\edgeLabel}(#2);
+ }
}
}%
}%
@@ -268,6 +240,7 @@
\listxadd{\AdigraphEdgeList}{\AdigraphFirstNode,\AdigraphSecondNode}
\newbool{adigraphEdge\AdigraphEdgeName HasLabel}
+ \newbool{adigraphEdge\AdigraphEdgeName HasEmptyLabel}
\newbool{adigraphEdge\AdigraphEdgeName Drawn}
\ifblank{#3}{%
\boolfalse{adigraphEdge\AdigraphEdgeName HasLabel}
@@ -276,6 +249,7 @@
}%
\ifblank{#2}{%
\booltrue{adigraphEdge\AdigraphEdgeName HasLabel}
+ \booltrue{adigraphEdge\AdigraphEdgeName HasEmptyLabel}
\csdef{adigraphEdge\AdigraphEdgeName Weight}{1}%
}{%
\csdef{adigraphEdge\AdigraphEdgeName Weight}{#2}%
@@ -334,11 +308,13 @@
}
}
-\NewDocumentCommand{\AdigraphPathBuilder}{m m m}{%
+\NewDocumentCommand{\AdigraphPathBuilder}{m m m m m}{%
%
% #1 -> first node
% #2 -> second node
% #3 -> units
+ % #4 -> forward color
+ % #5 -> backward color
%
\ifcsdef{adigraphEdge#1v#2Weight}{%
\letcs{\AdigraphWeightA}{adigraphEdge#1v#2Weight}
@@ -345,6 +321,7 @@
}{%
\def\AdigraphWeightA{0}
\newbool{adigraphEdge#1v#2HasLabel}
+ \newbool{adigraphEdge#1v#2HasEmptyLabel}
\ifcsdef{adigraphEdge#2v#1LabelPosition}{%
\csdef{adigraphEdge#1v#2LabelPosition}{\csuse{adigraphEdge#2v#1LabelPosition}}
}{%
@@ -352,7 +329,6 @@
}
\csdef{adigraphEdge#1v#2LabelPosition}{midway}
\newbool{adigraphEdge#1v#2Drawn}
- \csdef{adigraphEdge#1v#2Color}{black}%
\listgadd{\AdigraphEdgeList}{#1,#2}
}
\ifcsdef{adigraphEdge#2v#1Weight}{%
@@ -360,6 +336,7 @@
}{%
\def\AdigraphWeightB{0}
\newbool{adigraphEdge#2v#1HasLabel}
+ \newbool{adigraphEdge#2v#1HasEmptyLabel}
\ifcsdef{adigraphEdge#1v#2LabelPosition}{%
\csdef{adigraphEdge#2v#1LabelPosition}{\csuse{adigraphEdge#1v#2LabelPosition}}
}{%
@@ -366,16 +343,12 @@
\csdef{adigraphEdge#2v#1LabelPosition}{midway}
}
\newbool{adigraphEdge#2v#1Drawn}
- \csdef{adigraphEdge#2v#1Color}{black}%
\listgadd{\AdigraphEdgeList}{#2,#1}
}
- \ifnum\value{AdigraphCurrentPathNumber}=\value{AdigraphNumberOfPaths}
- \csdef{adigraphEdge#1v#2Color}{blue}%
- \csdef{adigraphEdge#2v#1Color}{red}%
- \else
- % Leaves the default colors
- \fi
+ \cslet{adigraphEdge#1v#2Color}{#4}%
+ \cslet{adigraphEdge#2v#1Color}{#5}%
+
\expandafter\AdigraphSimpleSum\expandafter{\AdigraphWeightA}{-#3}{\resultA}
\expandafter\AdigraphSimpleSum\expandafter{\AdigraphWeightB}{#3}{\resultB}
\cslet{adigraphEdge#1v#2Weight}{\resultA}%
@@ -382,11 +355,37 @@
\cslet{adigraphEdge#2v#1Weight}{\resultB}%
}
-\NewDocumentCommand{\AdigraphBuildPath}{> { \SplitList{,} } m m}{%
+\NewDocumentCommand{\AdigraphElaboratePathColors}{G{} G{black}}{}
+
+\NewDocumentCommand{\AdigraphBuildPath}{> { \SplitList{,} } m G{} > { \SplitArgument{ 1 } {,} } G{}}{%
%
% #1 -> List of nodes
% #2 -> Units to send over path
+ % #3 -> Colors list
%
+ \ifblank{#2}{%
+ \FPset{\units}{0}
+ }{
+ \FPset{\units}{#2}
+ }
+
+ \RenewDocumentCommand{\AdigraphElaboratePathColors}{G{} G{black}}{%
+ \ifblank{##1}{
+ \ifnum\value{AdigraphNumberOfPaths}=\value{AdigraphCurrentPathNumber}
+ \def\AdigraphForwardPathColor{red}
+ \def\AdigraphBackwardPathColor{blue}
+ \else
+ \def\AdigraphForwardPathColor{black}
+ \def\AdigraphBackwardPathColor{black}
+ \fi
+ }{
+ \def\AdigraphForwardPathColor{##1}
+ \def\AdigraphBackwardPathColor{##2}
+ }
+ }
+
+ \AdigraphElaboratePathColors#3
+
\RenewDocumentCommand{\AdigraphElaboratePath}{m}{%
\IfInteger{##1}{%
\def\AdigraphCurrentNode{\AdigraphRom{##1}}%
@@ -394,7 +393,7 @@
\def\AdigraphCurrentNode{##1}%
}%
\ifdef{\AdigraphLastParsedNode}{%
- \expandafter\expandafter\expandafter\AdigraphPathBuilder\expandafter\expandafter\expandafter{\expandafter\AdigraphLastParsedNode\expandafter}\expandafter{\AdigraphCurrentNode}{#2}
+ \expandafter\expandafter\expandafter\AdigraphPathBuilder\expandafter\expandafter\expandafter{\expandafter\AdigraphLastParsedNode\expandafter}\expandafter{\AdigraphCurrentNode}{\units}{\AdigraphForwardPathColor}{\AdigraphBackwardPathColor}
}{%
% This is the first iteration
}
@@ -532,7 +531,7 @@
\ProcessList{#1}{\AdigraphFirstEdgeRenormalizer}
}
-\NewDocumentCommand{\AdigraphProcessPaths}{> { \SplitArgument{ 1 } {:} } m}{%
+\NewDocumentCommand{\AdigraphProcessPaths}{> { \SplitArgument{ 2 } {:} } m}{%
\stepcounter{AdigraphCurrentPathNumber}
\AdigraphBuildPath#1
}
@@ -670,7 +669,7 @@
\listcsgadd{Adigraph#1AugmentingPaths}{##1}
}
\RenewDocumentCommand{\AdigraphProcessAugmentingPathsList}{> { \SplitList{;} } m}{%
- \AdigraphProcessAugmentingPaths##1
+ \ProcessList{##1}{\AdigraphProcessAugmentingPaths}
}
\expandafter\NewDocumentCommand\expandafter{\csname #1\endcsname}{m G{}}{%
%
More information about the tex-live-commits
mailing list