Graph drawings in TikZ.

April 17, 2010

Petersen Graph

Filed under: Graphs — fbc @ 21:52
Tags: , , , ,

On the occasion of the 303 anniversary of the birth of  Leonhard Euler, father of graph theory, we start publishing this week in this blog. We now show a drawing of the Petersen graph.

The Petersen Graph

Picture of the Petersen graph

The drawing in pdf format.

To generate the vertex and edge shadows in this diagram we have used the shadows library from TikZ. We suggest to include the following line in the preamble of the document.

\usetikzlibrary{shadows}

We now show the TikZ code we used to generate this drawing.

\begin{tikzpicture}[
vertex_style/.style={circle,shading=ball,ball color=red,draw=red!80!white,drop shadow={opacity=0.4}},
edge_style/.style={ultra thick, black,drop shadow={opacity=0.4}}]

\useasboundingbox (-5.05,-4.4) rectangle (5.1,5.25);

\begin{scope}[rotate=90]
 \foreach \x/\y in {0/1,72/2,144/3,216/4,288/5}{
 \node[vertex_style] (\y) at (canvas polar cs: radius=2.5cm,angle=\x){};
 }
 \foreach \x/\y in {0/6,72/7,144/8,216/9,288/10}{
 \node[vertex_style] (\y) at (canvas polar cs: radius=5cm,angle=\x){};
 }
\end{scope}

\foreach \x/\y in {1/6,2/7,3/8,4/9,5/10}{
 \draw[edge_style] (\x) -- (\y);
}

\foreach \x/\y in {1/3,2/4,3/5,4/1,5/2}{
 \draw[edge_style] (\x) -- (\y);
}

\foreach \x/\y in {6/7,7/8,8/9,9/10,10/6}{
 \draw[edge_style] (\x) -- (\y);
}
\end{tikzpicture}

Until next week!

Create a free website or blog at WordPress.com.