Skip to content

New versions of tkz-graph and tkz-berge

March 8, 2011

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. For the time being, I will only say that:

  • \grCycle (and \grEmptyCycle) has an optional argument rotation that, well, rotates the cycle by the given degrees, hence eliminating the need to use the scope environment.
  • The commands like \SetUpVertex and \SetVertexNormal accept also several optional arguments, so that one can avoid setting styles with \tikzset.
  • All of the commands that draw Edges (except \EdgeDoubleMod, that has already nine arguments) can accept optional arguments, changing the look and/or style of the edge.

For example, the line graph of the Petersen graph can be drawn now as:

  {\tikzset{EdgeStyle/.append style = {blue,line width=3pt}}
  {\tikzset{EdgeStyle/.append style = {green,line width=2pt}}

Line graph of the Petersen graph


Doing more with vertices

January 21, 2011

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, to apply extra labels.

Options for vertices

  \tikzset{EdgeStyle/.append style = {line width=2pt}}
  \draw[line width=3pt] (a0) .. controls (-1,1) and (1,1) .. (a0);
  \draw[thick,color=blue] (a1) .. controls (0,0) and (2,2) .. (a1);
  \draw (a2) .. controls (0,2) and (8,2) .. (a2);
  \shadedraw[top color=brown,opacity=0.8] (a3) circle (0.7cm);
  \draw[thick,decorate,decoration=snake] (a4) -- (a5);
  \draw (a2) node[below]{\textsf{a label}};
  \draw (a3) node[above right=5pt]{$v_{0}$};
  \node (mytext) at (9,1.5) [shape=rectangle,align=center,draw] {a good\\ vertex};
  \draw[->,line width=1pt] (mytext)  -- (a4);

The macro \EdgeDoubleMod

January 10, 2011

The macro \EdgeDoubleMod is convenient when drawing some complicated graphs. Consider the following picture of the line graph of the Petersen graph.

Line graph of the Petersen graph

produced by:

  \tikzset{VertexStyle/.append style=
    {inner sep=0pt,font=\footnotesize\sffamily}}
  {\tikzset{EdgeStyle/.append style = {blue,line width=3pt}}
  {\tikzset{EdgeStyle/.append style = {green,line width=2pt}}

We construct the graph using tree cycles: a circulant, an “empty” cycle and a usual cycle. The code \EdgeIdentity{a}{b}{5} just joins, for each i from 0 to 4 (that is, five times) the vertex labeled a_i to the vertex labeled b_i.

Finally \EdgeDoubleMod{b}{5}{0}{1}{a}{5}{2}{1}{5} joins, for each i between 0 and 4 (that is the 5 in the last argument), the vertex labeled b_{0+1\cdot i} to the vertex labeled a_{2+1\cdot i}. In both cases, the sub-index is calculated mod 5 (because of the second and the sixth argument).

Three complete graphs

September 29, 2010

three complete graphs, aligned

Also with captions.

  \begin{scope}[yshift=-\theshift cm]
  \draw (0,-2.5) node [fill=magenta!30!white,below]{$K_{4}$};
  \begin{scope}[xshift=6cm,yshift=-\theshift cm,rotate=90]
  \draw (6,-2.5) node [fill=magenta!30!white,below]{$K_{5}$};
  \draw (12,-2.5) node [fill=magenta!30!white,below]{$K_{6}$};

Three graphs

September 11, 2010
tags: ,

three graphs, aligned

Note that we have to adjust the radius of the third graph so that it aligns with the other two.

  \begin{scope}[xshift=10cm,yshift=\theshift cm,rotate=90]

The macro \EdgeInGraphMod

July 28, 2010

This macro is useful for circulants. Observe:


which produces:

This means that the edges ai – ai+3 are added to the graph, starting when i=0 and whenever i+3<8. The “3” here is the third argument of the macro, and the “8” is the second. The “a” is the identifier of the vertices joined by the added edges.

Hence the circulant is obtained by:


that is:

The flower snark J5

March 8, 2010

A flower snark ({J_{5}}).