TeX Community Aggregator

Category Graph Theory in LaTeX (Rafael)

A Cayley graph

The following is the Cayley graph , where is the additive group of the vector space (where is the field of three elements), and . \begin{tikzpicture} \tikzset{VertexStyle/.style={draw,rectangle}} \grEmptyCycle*[rotation=90,prefix=a,RA=2,Math]{{(1,2)},{(0,0)},{(2,1)}} \grEmptyCycle*[rotation=90,prefix=b,RA=4.5,Math]{(2,0),(1,0),(1,1),(0,1),(0,2),(2,2)} \EdgeInGraphLoop{b}{6} \SetUpEdge[style={bend right=10}] \EdgeDoubleMod{a}{3}{0}{1}{b}{6}{1}{2}{3} \EdgeDoubleMod{a}{3}{0}{1}{b}{6}{2}{2}{3} \SetUpEdge[style={bend left=10}] \EdgeDoubleMod{a}{3}{0}{1}{b}{6}{4}{2}{3} \EdgeDoubleMod{a}{3}{0}{1}{b}{6}{5}{2}{3} \end{tikzpicture} See… Continue Reading →

Introducing graphiso.sty

The purpose of the new package graphiso.sty is to use tkz-graph to produce an animation of a graph isomorphism in a beamer presentation, such as: You can find documentation and code at Github: rvf0068/graphiso.sty. See also: Original Source by Rafael

An icosahedron in fake 3d

\begin{tikzpicture} \begin{scope}[rotate=90] \grIcosahedral[form=1,RA=3,RB=1.5] \SetUpEdge[color=white,style={double=black,double distance=2pt}] \EdgeInGraphLoop{a}{6} \EdgeFromOneToSel{a}{b}{0}{1,5} \Edges(a2,b1,b3,b5,a4) \Edge(a3)(b3) \Edges(a1,b1,b5,a5) \Edges(a2,b3,a4) \end{scope} \end{tikzpicture} See also: Original Source by Rafael

Options for vertices

This post is an update for this post from my old blog, which did not work with the newer versions of tkz-berge. The changes are: instead of \tikzstyle{every node} = [node distance=1.5cm] one now has to use the macro: \SetGraphUnit{1.5},… Continue Reading →

Edges on a grid

For drawing some extra edges in a grid I used the following code: \begin{tikzpicture} \newcounter{xp} \newcounter{yp} \grGrid[prefix=a,RA=2,RB=2]{6}{6} \foreach \x in {0,2,4}{% \foreach \y in {1,3}{% \setcounter{xp}{\x} \setcounter{yp}{\y} \stepcounter{xp} \stepcounter{yp} \Edge(a\x;\y)(a\thexp;\theyp) } } \end{tikzpicture} For some reason the following code does… Continue Reading →

The flower snarks

I’m using the new rotation option for cycles to define a macro that draws a flower snark. The macro has as optional arguments the radius RA, RB, and RC of the three types of vertices, and a mandatory argument which… Continue Reading →

The Szekeres snark, more new features

\grEmptyCycle and \grCycle can also have options x and y, that set the coordinates of the center of the cycle, or r and d for polar coordinates (r is the radius and d the angle). Here we use these options… Continue Reading →

New versions of tkz-graph and tkz-berge

Finally, the much expected new versions (1.00 c) of tzk-graph and tkz-berge were released by Alain Matthes last week, and can be downloaded from Altermundus download zone. I expect to post several examples using the new capabilities of the packages…. Continue Reading →

Doing more with vertices

The vertices that tkz-berge draws are regular named TikZ nodes, and so they can be used if one wants unusual edges. Update: I added four more lines, to show that one can also use the node names provided by tkz-berge,… Continue Reading →

The macro \EdgeDoubleMod

The macro \EdgeDoubleMod is convenient when drawing some complicated graphs. Consider the following picture of the line graph of the Petersen graph. produced by: \begin{tikzpicture} \SetVertexNormal[MinSize=12pt] \tikzset{VertexStyle/.append style= {inner sep=0pt,font=\footnotesize\sffamily}} \begin{scope}[rotate=-90] \grCirculant[RA=0.6,prefix=a]{5}{2} \end{scope} \begin{scope}[rotate=-18] \grEmptyCycle[RA=1.5,prefix=b]{5}{2} \end{scope} \begin{scope}[rotate=18] \grCycle[RA=2.5,prefix=c]{5} \end{scope} \EdgeIdentity{a}{b}{5}… Continue Reading →

This blog moves

This blog will continue here, for reasons explained there. See also: Original Source by Rafael

A 3d graph

… after the example in the tikz gallery. \usetikzlibrary{calc,3d}\newcommand{\setxyz}[1]{% \pgfmathsetmacro{\xone}{cos(180+#1)}% \pgfmathsetmacro{\yone}{sin(180+#1)}% \pgfmathsetmacro{\xtwo}{cos(360-#1)}% \pgfmathsetmacro{\ytwo}{sin(360-#1)}%}\setxyz{17}\begin{tikzpicture}% [x = {(\xone cm,\yone cm)}, y = {(\xtwo cm,\ytwo cm)}, z = {(0cm,1cm)}] \GraphInit[vstyle=Shade] \SetVertexNoLabel \begin{scope}[canvas is xy plane at z=-5] \Vertex{x} \end{scope} \begin{scope}[canvas is xy plane… Continue Reading →

A circulant tournament

This is the circulant C_9(1,2,3,4)\begin{tikzpicture}\usepgflibrary{arrows}\GraphInit[vstyle=Art]\SetUpEdge[style={->,>=angle 45,bend right=10},color=red]\grCirculant[RA=3]{9}{1,-2,3,-4}\end{tikzpicture} See also: Original Source by Rafael

Several options for the \Vertex macro

UPDATE: This example no longer works with the latest versions of tkz-graph and tkz-berge. For an updated version see this post at my new blog. \begin{tikzpicture}\SetVertexNormal[LineColor=brown]\Vertex[x=0,y=2.5,style=orange,LabelOut=true,Lpos=90]{A}{\tikzstyle{every node} = [node distance=1.5cm] \Vertices[x=1.5,y=4,dir=\SO,LabelOut=true,Ldist=5pt]{B,C,D}}\Vertices[x=3,y=5,dir=\SO,style={shape=coordinate}]{E,F,G,H,I,J}\Vertices[x=4.5,y=5,dir=\SO,style={font=\bfseries}]{K,L,M,N,O,P}{\tikzstyle{every node} = [node distance=1.5cm] \Vertices[x=6,y=4,dir=\SO, style={line width=2pt, inner sep=0pt,… Continue Reading →

Several options for the \Edge macro

\begin{tikzpicture} \SetVertexNormal \Vertex[x=0,y=2.5]{A} {\tikzstyle{every node} = [node distance=1.5cm] \Vertices[x=1.5,y=4,dir=\SO]{B,C,D}} \Vertices[x=3,y=5,dir=\SO]{E,F,G,H,I,J} \Vertices[x=4.5,y=5,dir=\SO]{K,L,M,N,O,P} {\tikzstyle{every node} = [node distance=1.5cm] \Vertices[x=6,y=4,dir=\SO]{Q,R,S}} \Vertex[x=7.5,y=2.5]{T} \Edges[color=red](A,B,E,K,Q,T,S,P,J,D,A) \foreach \x/\y in {E/F,G/H,I/J,K/L,M/N,O/P} {\Edge[color=green](\x)(\y)} \Edge[style=->](I)(P) \Edge[style=dashed](A)(C) \Edge[style=dotted](C)(F) \Edge[label=CD](C)(D) \Edge[label=BC,labelcolor=yellow](B)(C) \Edge[label=QR,labelcolor=orange,labeltext=cyan](Q)(R) \Edge[label=RS,labelstyle=right](R)(S) \Edge[label=OS,labelstyle={below=1pt,inner sep=0pt}](O)(S) \Edge[label=LQ,labelstyle={above,font=\bfseries}](L)(Q) \Edge[label=FL,labelstyle={font=\tiny\bfseries}](F)(L) \Edge[label=GN,labelstyle={sloped,above}](G)(N) \Edge[style={bend right}](A)(T)\end{tikzpicture} See also:… Continue Reading →

Simulating KTikZ with Emacs

I stumbled upon a piece of software called KtikZ. The screenshot in that page, together with the fact that Doc-View mode is included in the new Emacs 23, inspired me to try that idea with tikz2pdf. With help from folks… Continue Reading →

Using tikz2pdf

When drawing graphs by trial and error, the script tikz2pdf by Hans Meine can be very useful. I have the following in ~/.tikz2pdf.tex: \documentclass{article} \usepackage{tikz}\usepackage{tkz-berge} \usepackage[graphics,tightpage,active]{preview}\PreviewEnvironment{tikzpicture}\newlength{\imagewidth}\newlength{\imagescale} \begin{document} \input{%s} \end{document} Then, I edit a file, say foo.tikz, with \begin{tikzpicture} \grHeawood[RA=1]\end{tikzpicture} and… Continue Reading →

New LaTeX package for graphs

Alain Matthes has produced a package (tkz-berge.sty) which should become THE way to draw graphs in LaTeX. It is built on top of Tikz, and so can be easily integrated with beamer presentations. The package can be dowloaded from here,… Continue Reading →

A mistake in Tutte’s 8-cage

Only after Kjell Magne Fauske posted in his gallery two (much improved) versions of two graphs found here, I realized there is a mistake in my picture of Tutte’s 8-cage. There are 5-cycles among the “inner” 10 vertices. Kjell has… Continue Reading →

The largest 3-regular graph of diameter 3

See this paper \documentclass{article}\usepackage{tikz}\pagestyle{empty} \begin{document}\begin{center} \begin{tikzpicture}[style=thick] \foreach \x in {18,90,…,306} { \draw (\x:4cm) circle (2pt) — (\x+72:4cm); \draw (\x:4cm) — (\x:3cm) circle (2pt); \draw (\x:3cm) — (\x+15:2cm) circle (2pt); \draw (\x:3cm) — (\x-15:2cm) circle (2pt); \draw (\x+15:2cm) — (\x+144-15:2cm); \draw… Continue Reading →

The largest 4-regular graph of diameter 2

See this paper. \documentclass{article}\usepackage{tikz}\pagestyle{empty} \begin{document}\begin{center} \begin{tikzpicture}[style=thick] \foreach \x in {0,30,…,330} { \draw (\x:2cm) circle (2pt) — (\x+30:2cm); } \foreach \x in {0,60,…,300} { \draw (\x:2cm) circle (2pt) — (\x+90:2cm); } \foreach \x in {0,30,…,150} { \draw (\x:2cm) circle (2pt) —… Continue Reading →

The McGee graph

\documentclass{article}\usepackage{tikz}\pagestyle{empty} \begin{document}\begin{center} \begin{tikzpicture}[style=thick] \foreach \x in {0,15,…,345} { \draw (\x:3cm) circle (2pt) — (\x+15:3cm); } \foreach \x in {0,45,…,135} { \draw (\x:3cm) circle (2pt) — (\x+180:3cm); } \foreach \x in {15,60,…,330} { \draw (\x:3cm) circle (2pt) — (\x+105:3cm); } \end{tikzpicture}\end{center}\end{document}… Continue Reading →

The Hoffman-Singleton graph

\documentclass{article} \pagestyle{empty}\usepackage{tikz} \begin{document} \begin{center} \begin{tikzpicture}[style=thick,scale=0.5] \def\pentagon{(18:1cm) circle (4pt) node[above right=-1.75pt]{\tiny $4$} — (90:1cm) circle (4pt) node[above]{\tiny $0$} — (162:1cm) circle (4pt) node[above left=-1.75pt]{\tiny $1$} — (234:1cm) circle (4pt) node[below]{\tiny $2$} — (306:1cm) circle (4pt) node[below]{\tiny $3$} — (18:1cm)} \def\pentagram{(18:1cm) circle… Continue Reading →

Tutte’s 8-cage

The unique smallest cubic graph of girth 8. Drawn from Algebraic Graph Theory by Godsil and Royle, p.72. \documentclass{article}\usepackage{tikz}\pagestyle{empty} \begin{document}\begin{tikzpicture}[style=thick] \foreach \x in {0,36,…,324} { \draw (\x:2cm) circle (2pt) — (\x+144:2cm); \draw (\x-10:3cm) circle (2pt) — (\x+5:4cm); \draw (\x-10:3cm) circle… Continue Reading →

A complete bipartite graph

\documentclass{article}\usepackage{tikz}\pagestyle{empty} \begin{document} \begin{center} \begin{tikzpicture}[style=thick] \foreach \x in {0,1,2} \foreach \y in {0,1,2} {\draw (\y,0) — (\x,1);} \foreach \x in {0,1,2}{ \draw (\x,0) circle (2pt); \draw (\x,1) circle (2pt);} \end{tikzpicture} \end{center}\end{document} See also: Original Source by Rafael

A cubic tree

If it could be completed to a cubic graph, it would give a cubic Moore graph of diameter 3. I wish I knew how to produce a similar tree, but growing from an edge instead of from a vertex.\documentclass{article} \usepackage{tikz}… Continue Reading →

Petersen graph

The smallest cubic graph of girth 5, drawn using TikZ. \documentclass{article}\usepackage{tikz}\pagestyle{empty} \begin{document} \begin{center} \begin{tikzpicture}[style=thick] \draw (18:2cm) — (90:2cm) — (162:2cm) — (234:2cm) — (306:2cm) — cycle; \draw (18:1cm) — (162:1cm) — (306:1cm) — (90:1cm) — (234:1cm) — cycle; \foreach \x… Continue Reading →

Heawood graph

The smallest cubic graph of girth 6, or 6-cage, drawn with PS Tricks. This was inspired from the example in The LaTeX Graphics Companion, page 121. \documentclass{article}\usepackage{pstricks,pst-node,multido,ifthen,calc}\pagestyle{empty} \begin{document}\begin{center}\begin{pspicture}(-1,-1.5)(1,1.5) \psset{unit=1.5cm} \newcounter{CtA} \newcounter{Temp} \newcounter{Tempi} \SpecialCoor \degrees[14] \multido{\ia=0+1}{14}{% \setcounter{CtA}{\ia}% \addtocounter{CtA}{1}% \multido{\ib=\value{CtA}+1}{1}{\psline{o-o}(1;\ia)(1;\ib)} }% \multido{\ia=0+2}{7}{%… Continue Reading →

Graphs with LaTeX

The purposes of this blog are to show pictures of graphs (where by a graph we mean the object studied in Graph Theory) produced by LaTeX, and more precisely by its packages Xy-pic, PS Tricks and TikZ, and to discuss… Continue Reading →

© 2025 TeX.social