diff options
Diffstat (limited to 'Master/texmf-dist/doc/latex/adigraph/adigraph_documentation.tex')
-rw-r--r-- | Master/texmf-dist/doc/latex/adigraph/adigraph_documentation.tex | 102 |
1 files changed, 95 insertions, 7 deletions
diff --git a/Master/texmf-dist/doc/latex/adigraph/adigraph_documentation.tex b/Master/texmf-dist/doc/latex/adigraph/adigraph_documentation.tex index 8818b12ff6b..d0c25207d73 100644 --- a/Master/texmf-dist/doc/latex/adigraph/adigraph_documentation.tex +++ b/Master/texmf-dist/doc/latex/adigraph/adigraph_documentation.tex @@ -136,7 +136,7 @@ You can renovate an older graph by calling \textbackslash RenewAdigraph \end{minted} \section{Adding nodes} -We set its nodes with the following syntax: \textit{<node name, color, border width: \(x\) coordinate, \(y\) coordinate: label>}. +We set its nodes with the following syntax: \textit{<node name[, textual color, border width]: \(x\) coordinate[, \(y\) coordinate][: label]>}. \begin{figure} \begin{subfigure}{0.49\textwidth} @@ -158,7 +158,7 @@ We set its nodes with the following syntax: \textit{<node name, color, border wi \end{figure} \subsection{Custom node colors} -To color a node you can use the following syntax: \textit{<node name, textual color: \(x\) coordinate, \(y\) coordinate>}. For example, to draw s in red and t in blue we would write: +To color a node you can use the following syntax: \textit{<node name[, textual color]: \(x\) coordinate[, \(y\) coordinate]>}. For example, to draw s in red and t in blue we would write: \begin{figure} \begin{subfigure}{0.49\textwidth} @@ -182,7 +182,7 @@ To color a node you can use the following syntax: \textit{<node name, textual co Tested available colors are: red, blue, black, green. You may extend the possible colors with LaTex libraries such as xcolor. \subsection{Custom node width} -To color a node you can use the following syntax: \textit{<node name, textual color, width: \(x\) coordinate, \(y\) coordinate>}. For example: +To color a node you can use the following syntax: \textit{<node name[, textual color[, border width]]: \(x\) coordinate[, \(y\) coordinate]>}. For example: \begin{figure} \begin{subfigure}{0.49\textwidth} @@ -204,7 +204,7 @@ To color a node you can use the following syntax: \textit{<node name, textual co \end{figure} \subsection{Custom node labels} -To add a custom label you can use the following syntax: either \textit{<node name: \(x\) coordinate, \(y\) coordinate: node label>} or \textit{<node name,textual color: \(x\) coordinate, \(y\) coordinate: node label>} will work: +To add a custom label you can use the following syntax: either \textit{<node name: \(x\) coordinate[, \(y\) coordinate][: node label]>} or \textit{<node name[, textual color]: \(x\) coordinate[, \(y\) coordinate][: node label]>} will work: \begin{figure} \begin{subfigure}{0.49\textwidth} @@ -294,7 +294,7 @@ When no coordinates are given or you just don't have time to think about where t \section{Adding edges} -We set its nodes with the following syntax: \textit{<node name: \(x\) coordinate, \(y\) coordinate, color, edge width: label>}. +We set its edges with the following syntax: \textit{<first node, second node,[color,[edge width]][:weight[:label:[label position]]]>}. \subsection{A simple edge} \begin{figure} @@ -1036,9 +1036,9 @@ If you'd like to color the cuts you just have to add the color as follows: \text \end{subfigure} \end{figure} -\section{Non oriented edges and custom edge stiles} +\section{Non oriented (undirected) edges and custom edge stiles} If you need non oriented edges or in general to ad a custom style to your edges you can proceed as follows: -\subsection{Non oriented} +\subsection{Non oriented (undirected)} \begin{figure} \begin{subfigure}{0.49\textwidth} \begin{minted}{latex} @@ -1138,6 +1138,94 @@ If you need non oriented edges or in general to ad a custom style to your edges \end{subfigure} \end{figure} +\chapter{PyAdigraph} +\href{https://github.com/LucaCappelletti94/pyadigraph}{Pyadigraph} turns your networkx into Adigraph latex package. It requires Adigraph (1.7.0+) to work. + +\section{Installation} +The package can be installed by simply running: +\begin{minted}{bash} +pip installed pyadigraph +\end{minted} +\clearpage +\section{Example} +\subsection{Python code} +For example by running the following python code: +\begin{minted}{python} +from pyadigraph import Adigraph +import networkx as nx + +A = Adigraph( + vertices_color_fallback="gray!90", + edges_color_fallback="gray!90", + sub_caption="My adigraph number {i} of {n}", + sub_label="adigraph_{i}_{n}", + row_size=1, + caption="A graph generated with python and latex.", + label="pyadigraph_example" +) + +A.add_graph( + nx.bipartite.random_graph(4, 4, 1), + vertices_color={ + 0: 'red!90', + 1: 'red!90', + 4: 'cyan!90', + 7: 'cyan!90' + }) + +A.save("test/result.tex", document=True) +\end{minted} +\clearpage +\subsection{Latex result} +You automatically obtain the following latex: + +\begin{minted}{latex} +\documentclass{report} +\usepackage{adigraph} +\usepackage{subcaption} + +\begin{document} +\begin{figure} + \begin{subfigure}{1.0\textwidth} + \NewAdigraph{myAdigraph}{ + 0,red!90,:-0.4386601404141742\textwidth,0.2091077552922947\textwidth:; + 1,red!90,:-0.15708496776680972\textwidth,0.09630690244229406\textwidth:; + 2,gray!90,:0.43887677279554366\textwidth,-0.2079924280020609\textwidth:; + 3,gray!90,:0.15678823839504888\textwidth,-0.09746320565948384\textwidth:; + 4,cyan!90,:-0.3736460590634439\textwidth,-0.327631363498189\textwidth:; + 5,gray!90,:0.3735687548614322\textwidth,0.3275275669374224\textwidth:; + 6,gray!90,:-0.042735184609099336\textwidth,-0.4998552275122768\textwidth:; + 7,cyan!90,:0.0428925858015027\textwidth,0.5\textwidth:; + }{ + 0,4,gray!90,::; + 0,5,gray!90,::; + 0,6,gray!90,::; + 0,7,gray!90,::; + 1,4,gray!90,::; + 1,5,gray!90,::; + 1,6,gray!90,::; + 1,7,gray!90,::; + 2,4,gray!90,::; + 2,5,gray!90,::; + 2,6,gray!90,::; + 2,7,gray!90,::; + 3,4,gray!90,::; + 3,5,gray!90,::; + 3,6,gray!90,::; + 3,7,gray!90,::; + }[] + \myAdigraph{} + \caption{My adigraph number 1 of 1}\label{adigraph_1_1} + \end{subfigure} + \caption{A graph generated with python and latex.}\label{pyadigraph_example} +\end{figure} +\end{document} +\end{minted} + +And once you compile that you receive a graph like the following: +\begin{figure} + \includegraphics[width=0.5\textwidth]{img_examples/pyadigraph.png} +\end{figure} \chapter{Warnings} \section{Reserved words} |