Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am trying to illustrate a voltage graph construction of the Petersen graph. In practice, this means:

  • The outer cycle will be labelled clockwise (a,0),...,(a,4) with arcs oriented in that order;
  • The inner cycle will be labelled clockwise (b,0),...,(b,4) with arcs (b,0) -> (b,2), (b,1) -> (b,3), (b,2) -> (b,4) and (b,3) -> (b,0); and
  • Each (a,i) will be joined to the corresponding (b,i) (in that direction).

I can almost accomplish this using the grpetersen macro and the following code:

\begin{tikzpicture}[->,>=triangle 45,rotate=90,scale=1.2,style=thick]
  \newcommand{\aset}[2]{$\{#1,#2\}$}
  \tikzset{VertexStyle/.style={draw,rectangle}}
  \SetVertexNoLabel
  \SetVertexMath
  \SetUpVertex[MinSize=30pt]
  \grPetersen[RA=3,RB=1.5]
%  \SetUpEdge{style={->-}}
  \AssignVertexLabel{a}{\textsl{(a,0)},\textsl{(a,4)},\textsl{(a,3)},\textsl{(a,2)},\textsl{(a,1)}}
  \AssignVertexLabel{b}{\textsl{(b,0)},\textsl{(b,4)},\textsl{(b,3)},\textsl{(b,2)},\textsl{(b,1)}}
\end{tikzpicture}

However, the arcs on the outer cycle are oriented in the wrong direction, and I cannot see how to change them without changing the other, correctly-oriented arcs.

Any suggestions would be much appreciated.


It is part of tkzgraph/berge - refer to Altermundus' "Plotting named graphs". Here is a minimal document containing the above code.

\documentclass{article}
\usepackage{tkz-graph}
\usepackage{tkz-berge}
\begin{document}
\begin{tikzpicture}[->,>=triangle 45,rotate=90,scale=1.2,style=thick]
  \newcommand{\aset}[2]{$\{#1,#2\}$}
  \tikzset{VertexStyle/.style={draw,rectangle}}
  \SetVertexNoLabel
  \SetVertexMath
  \SetUpVertex[MinSize=30pt]
  \grPetersen[RA=3,RB=1.5]
%  \SetUpEdge{style={->-}}
  \AssignVertexLabel{a}{\textsl{(a,0)},\textsl{(a,4)},\textsl{(a,3)},\textsl{(a,2)},\textsl{(a,1)}}
  \AssignVertexLabel{b}{\textsl{(b,0)},\textsl{(b,4)},\textsl{(b,3)},\textsl{(b,2)},\textsl{(b,1)}}
\end{tikzpicture}
\end{document}
share|improve this question
    
I'm afraid you'll have to hack the \grPetersen macro in the tkz-berge.sty file... –  Count Zero Aug 25 '12 at 19:00
    
@CountZero Yes a hack is necessary. Better is to create with tkz-berge a new macro to define something like \grEmptyPetersen. –  Alain Matthes Aug 26 '12 at 15:48

1 Answer 1

Here perhaps a solution. I modified my macro that I defined in tkz-berge.sty. The better way is to learn tkz-berge or to learn tikz to create your own macros. You can find some ideas inside the code of tkz-berge but you also look at the document NamedGraphs to find some examples NamedGraphs

Remark :tkz-berge loads tkz-graph and tikz

\documentclass{article}
\usepackage{tkz-berge} 
\makeatletter

\renewcommand*{\grPetersen}[1][]{%
\begingroup%
    \setkeys[GR]{cl}{#1}%
        \begin{scope}[<-]
            \grCycle[#1]{5}%     
        \end{scope}
        \edef\tkzb@rtemp{\cmdGR@cl@RB}
        \edef\tkzb@ptemp{\cmdGR@cl@prefixx}
        \grStartwo[#1,RA=\tkzb@rtemp,prefix=\tkzb@ptemp]{2}
        \EdgeIdentity{\cmdGR@cl@prefix}{\cmdGR@cl@prefixx}{5} 
\endgroup%
}  
\makeatother


\begin{document}
\begin{tikzpicture}[->,>=triangle 45,rotate=90,scale=1.2,style=thick]
  \newcommand{\aset}[2]{$\{#1,#2\}$}
  \tikzset{VertexStyle/.style={draw,rectangle}}
  \SetVertexNoLabel
  \SetVertexMath
  \SetUpVertex[MinSize=30pt]
  \grPetersen[RA=3,RB=1.5]
  \AssignVertexLabel{a}{\textsl{(a,0)},\textsl{(a,4)},\textsl{(a,3)},\textsl{(a,2)},\textsl{(a,1)}}
  \AssignVertexLabel{b}{\textsl{(b,0)},\textsl{(b,4)},\textsl{(b,3)},\textsl{(b,2)},\textsl{(b,1)}}
\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.