GraphTheory/Latex - Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : GraphTheory/Latex

GraphTheory

  

Latex

  

generate LaTeX code for a graph

 

Calling Sequence

Parameters

Description

Examples

Compatibility

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

withGraphTheory:

Create a cycle on 3 vertices (a triangle).

GGraphTrail1,2,3,1

GGraph 1: an undirected unweighted graph with 3 vertices and 3 edge(s)

(1)

Generate LaTeX code and display it on the terminal.

LatexG,terminal,100,100

\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.

LatexG,,100,100,true,20,:-pictureonly=true,:-vertexlabels=false

\begin{picture}(100,100) \color[rgb]{0.000,0.000,0.000}\qbezier(50.00,82.00)(66.00,50.00)(82.00,18.00) \color[rgb]{0.000,0.000,0.000}\qbezier(50.00,82.00)(34.00,50.00)(18.00,18.00) \color[rgb]{0.000,0.000,0.000}\qbezier(82.00,18.00)(50.00,18.00)(18.00,18.00) \put(50.00,82.00){\color[rgb]{0.902,0.902,0.902} \circle*{20}} \put(50.00,82.00){\color[rgb]{0.0,0.0,0.0} \circle{20}} \put(82.00,18.00){\color[rgb]{0.902,0.902,0.902} \circle*{20}} \put(82.00,18.00){\color[rgb]{0.0,0.0,0.0} \circle{20}} \put(18.00,18.00){\color[rgb]{0.902,0.902,0.902} \circle*{20}} \put(18.00,18.00){\color[rgb]{0.0,0.0,0.0} \circle{20}} \end{picture}

(2)

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

TGraphdirected,Trail1,2,3,1,4,5,1

TGraph 2: a directed unweighted graph with 5 vertices and 6 arc(s)

(3)

HighlightVertexT,1,red

Compute vertex positions using the spring option.

DrawGraphT,:-style=spring

Generate LaTeX code and output to a file loops.tex.

currentdirhomedir

LatexT,loops.tex,150,150,true,:-style=spring

Compatibility

• 

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

• 

For more information on Maple 18 changes, see Updates in Maple 18.

See Also

DrawGraph

Export Worksheets to LaTeX

HighlightEdges

HighlightVertex

SetVertexPositions