 GraphTheory/Latex - Maple Help

GraphTheory

 Latex
 generate LaTeX code for a graph Calling Sequence Latex(G, file, width, height, color, vertexsize, s, v, p) Parameters

 G - Graph; a graph object. file - string or symbol; name of the file where the LaTeX code will be written. width - posint; LaTeX picture environment width parameter. height - posint; LaTeX picture environment height parameter. color - (optional) truefalse; generate a color graph. The default is false. vertexsize - (optional) integer; specify the vertex size. The default value is -1. s - (optional) equation of the form style = none or bipartite or circle or default or planar or spring or spring[constant] or tree or user. v - (optional) equation of the form vertexlabels = true or false. The default is true. p - (optional) equation of the form pictureonly = true or false. The default is false. Description

 • The Latex command generates LaTeX source code in the given file for displaying the graph G using the picture environment. For example, the command Latex(G, filename, 300, 300, true) will generate the following output

\documentclass{amsart}

\usepackage{xcolor}

\begin{document}

\begin{picture}(300,300)

...

\end{picture}

\end{document}

 The values 300 and 300 for the width and height mean the graph will fill about 2/3 of the page. The final placement of the graph on the page should be adjusted in LaTeX using the offset option of the picture environment. For example, to move the graph left by 50 points and up by 30 points change the picture command to \begin{picture}(300,300)(50,30) .
 • By default, the LaTeX source code is generated including the LaTeX preamble, \begin{document} and \end{document}, and can be run through LaTeX for previewing purposes. If optional keyword pictureonly = true is used, the output will only contain the code between \begin{picture} and \end{picture}, which can then be included in any LaTeX document.
 • The file parameter specifies where the LaTeX output is written. If special filename terminal (symbol) is specified, the LaTeX code is displayed on the current output stream, i.e., the Maple terminal. If an empty string is specified, the LaTeX code is returned as a Maple string. Otherwise, the output will be written in a file. If file does not end with .tex then this file extension is added automatically. If file does not begin with /, then the file is written in the current directory. The current directory in Maple is set by the currentdir command.
 • By default, the graph's vertices, edges and vertex labels are drawn in black. If true is given for color, then a color graph is generated. The vertex colors (default yellow) and edge colors (default blue) in the graph G are used. Use the HighlightVertex and HighlightEdges commands to change the vertex and edge colors.
 • The size of the vertices is determined by the size of the picture and the number of vertices. Larger vertices are used if height + width is large and if there are fewer vertices. Use the vertexsize parameter to provide a specific size for the vertices.
 • If the parameter style is given, this is used to determine the vertex positions which were previously set by the DrawGraph command using the style option.  To set user-defined vertex positions, use the SetVertexPositions command and then use style = user.  The default is style = none.
 • Vertices are labeled by default. Use vertexlabels = false to not show the vertex labels. Examples

 > $\mathrm{with}\left(\mathrm{GraphTheory}\right):$

Create a cycle on 3 vertices (a triangle).

 > $G≔\mathrm{Graph}\left(\mathrm{Trail}\left(1,2,3,1\right)\right)$
 ${G}{≔}{\mathrm{Graph 1: an undirected graph with 3 vertices and 3 edge\left(s\right)}}$ (1)

Generate LaTeX code and display it on the terminal.

 > $\mathrm{Latex}\left(G,\mathrm{terminal},100,100\right)$
 \documentclass{amsart} \begin{document} \begin{picture}(100,100) \qbezier(50.00,87.60)(68.80,50.00)(87.60,12.40) \qbezier(50.00,87.60)(31.20,50.00)(12.40,12.40) \qbezier(87.60,12.40)(50.00,12.40)(12.40,12.40) \put(50.000000,87.600000){\circle*{6}} \put(50.000,97.200){\makebox(0,0){1}} \put(87.600000,12.400000){\circle*{6}} \put(95.766,7.353){\makebox(0,0){2}} \put(12.400000,12.400000){\circle*{6}} \put(4.234,7.353){\makebox(0,0){3}} \end{picture} \end{document}

Generate picture-only LaTeX code for a color graph G with vertex size 20 and no vertex labels. Output a Maple string.

 > $\mathrm{Latex}\left(G,"",100,100,\mathrm{true},20,':-\mathrm{pictureonly}'=\mathrm{true},':-\mathrm{vertexlabels}'=\mathrm{false}\right)$
 ${"\begin\left\{picture\right\}\left(100,100\right) \color\left[rgb\right]\left\{0.000,0.000,0.000\right\}\qbezier\left(50.00,82.00\right)\left(66.00,50.00\right)\left(82.00,18.00\right) \color\left[rgb\right]\left\{0.000,0.000,0.000\right\}\qbezier\left(50.00,82.00\right)\left(34.00,50.00\right)\left(18.00,18.00\right) \color\left[rgb\right]\left\{0.000,0.000,0.000\right\}\qbezier\left(82.00,18.00\right)\left(50.00,18.00\right)\left(18.00,18.00\right) \put\left(50.00,82.00\right)\left\{\color\left[rgb\right]\left\{0.902,0.902,0.902\right\} \circle*\left\{20\right\}\right\} \put\left(50.00,82.00\right)\left\{\color\left[rgb\right]\left\{0.0,0.0,0.0\right\} \circle\left\{20\right\}\right\} \put\left(82.00,18.00\right)\left\{\color\left[rgb\right]\left\{0.902,0.902,0.902\right\} \circle*\left\{20\right\}\right\} \put\left(82.00,18.00\right)\left\{\color\left[rgb\right]\left\{0.0,0.0,0.0\right\} \circle\left\{20\right\}\right\} \put\left(18.00,18.00\right)\left\{\color\left[rgb\right]\left\{0.902,0.902,0.902\right\} \circle*\left\{20\right\}\right\} \put\left(18.00,18.00\right)\left\{\color\left[rgb\right]\left\{0.0,0.0,0.0\right\} \circle\left\{20\right\}\right\} \end\left\{picture\right\}"}$ (2)

Create a directed graph with an articulation vertex highlighted in red.

 > $T≔\mathrm{Graph}\left(\mathrm{directed},\mathrm{Trail}\left(1,2,3,1,4,5,1\right)\right)$
 ${T}{≔}{\mathrm{Graph 2: a directed graph with 5 vertices and 6 arc\left(s\right)}}$ (3)
 > $\mathrm{HighlightVertex}\left(T,1,\mathrm{red}\right)$

Compute vertex positions using the spring option.

 > $\mathrm{DrawGraph}\left(T,':-\mathrm{style}'='\mathrm{spring}'\right)$ Generate LaTeX code and output to a file loops.tex.

 > $\mathrm{currentdir}\left(\mathrm{homedir}\right)$
 > $\mathrm{Latex}\left(T,"loops.tex",150,150,\mathrm{true},':-\mathrm{style}'='\mathrm{spring}'\right)$ Compatibility

 • The GraphTheory[Latex] command was introduced in Maple 18.