# Revision history [back]

Unfortunately, p.show computes the graph internally and just outputs the figure output. Put, we can do it from scratch:

sage: p = Permutation([3,1,2])
sage: edges = list(enumerate(p,start=1))
sage: d = DiGraph(edges, format='list_of_edges', loops=True)
sage: d
Looped digraph on 3 vertices
sage: latex(d) # prints the latexoutput in the default tikz
sage: view(d) # opens the pdf in a viewer


There is another way to use graphviz + dot2tex, but I always forget how to do it. Personnaly, I like to use the TikzPicture class from my package which uses graphviz the place the nodes + dot2tex to constructs the tikzpicture:

sage: from slabbe import TikzPicture
sage: tikz = TikzPicture.from_graph(d)
sage: print(tikz)
\documentclass[tikz]{standalone}
\standaloneconfig{border=4mm}
\usepackage{amsmath}
\begin{document}
\begin{tikzpicture}[>=latex,line join=bevel,]
%%
\node (node_0) at (23.0bp,104.5bp) [draw,draw=none] {$1$};
\node (node_2) at (6.0bp,55.5bp) [draw,draw=none] {$3$};
\node (node_1) at (23.0bp,6.5bp) [draw,draw=none] {$2$};
\draw [black,->] (node_0) ..controls (18.571bp,91.254bp) and (14.669bp,80.466bp)  .. (node_2);
\draw [black,->] (node_1) ..controls (23.0bp,27.341bp) and (23.0bp,65.653bp)  .. (node_0);
\draw [black,->] (node_2) ..controls (10.429bp,42.254bp) and (14.331bp,31.466bp)  .. (node_1);
%
\end{tikzpicture}
\end{document}
sage: tikz.pdf()                        # opens up a viewer
sage: tikz.pdf('filename.pdf')   # saves the pdf file


To install those optional packages, you do:

sage -i dot2tex
sage -pip install slabbe


At some point, I might move the TikzPicture code from my package to sage. Is this something you would like for instance?

Unfortunately, p.show computes the graph internally and just outputs the figure output. Put, we can do it from scratch:

sage: p = Permutation([3,1,2])
sage: edges = list(enumerate(p,start=1))
sage: d = DiGraph(edges, format='list_of_edges', loops=True)
sage: d
Looped digraph on 3 vertices
sage: latex(d) # prints the latexoutput in the default tikz
sage: view(d) # opens the pdf in a viewer


There is another way to use graphviz + dot2tex, but I always forget how to do it. Personnaly, I like to use the TikzPicture class from my package which uses sets up properly the options to use graphviz to the place the nodes + and dot2tex to constructs the tikzpicture:

sage: from slabbe import TikzPicture
sage: tikz = TikzPicture.from_graph(d)
sage: print(tikz)
\documentclass[tikz]{standalone}
\standaloneconfig{border=4mm}
\usepackage{amsmath}
\begin{document}
\begin{tikzpicture}[>=latex,line join=bevel,]
%%
\node (node_0) at (23.0bp,104.5bp) [draw,draw=none] {$1$};
\node (node_2) at (6.0bp,55.5bp) [draw,draw=none] {$3$};
\node (node_1) at (23.0bp,6.5bp) [draw,draw=none] {$2$};
\draw [black,->] (node_0) ..controls (18.571bp,91.254bp) and (14.669bp,80.466bp)  .. (node_2);
\draw [black,->] (node_1) ..controls (23.0bp,27.341bp) and (23.0bp,65.653bp)  .. (node_0);
\draw [black,->] (node_2) ..controls (10.429bp,42.254bp) and (14.331bp,31.466bp)  .. (node_1);
%
\end{tikzpicture}
\end{document}
sage: tikz.pdf()                        # opens up a viewer
sage: tikz.pdf('filename.pdf')   # saves the pdf file


To install those optional packages, you do:

sage -i dot2tex
sage -pip install slabbe


At some point, I might move the TikzPicture code from my package to sage. Is this something you would like for instance?

Unfortunately, p.show computes the graph internally and just outputs the figure output. Put, we can do it from scratch:

sage: p = Permutation([3,1,2])
sage: edges = list(enumerate(p,start=1))
sage: d = DiGraph(edges, format='list_of_edges', loops=True)
sage: d
Looped digraph on 3 vertices
sage: latex(d) # prints the latexoutput in the default tikz
sage: view(d) # opens the pdf in a viewer


There is another way to use graphviz + dot2tex, but I always forget how to do it. Personnaly, I like to use the TikzPicture class from my package which sets up properly the options to use graphviz to the place the nodes and + dot2tex to constructs the tikzpicture:

sage: from slabbe import TikzPicture
sage: tikz = TikzPicture.from_graph(d)
sage: print(tikz)
\documentclass[tikz]{standalone}
\standaloneconfig{border=4mm}
\usepackage{amsmath}
\begin{document}
\begin{tikzpicture}[>=latex,line join=bevel,]
%%
\node (node_0) at (23.0bp,104.5bp) [draw,draw=none] {$1$};
\node (node_2) at (6.0bp,55.5bp) [draw,draw=none] {$3$};
\node (node_1) at (23.0bp,6.5bp) [draw,draw=none] {$2$};
\draw [black,->] (node_0) ..controls (18.571bp,91.254bp) and (14.669bp,80.466bp)  .. (node_2);
\draw [black,->] (node_1) ..controls (23.0bp,27.341bp) and (23.0bp,65.653bp)  .. (node_0);
\draw [black,->] (node_2) ..controls (10.429bp,42.254bp) and (14.331bp,31.466bp)  .. (node_1);
%
\end{tikzpicture}
\end{document}
sage: tikz.pdf()                        # opens up a viewer
sage: tikz.pdf('filename.pdf')   # saves the pdf file


To install those optional packages, you do:

sage -i dot2tex
sage -pip install slabbe


At some point, I might move the TikzPicture code from my package to sage. Is this something you would like for instance?