3

This is the code to a graph I'm drawing, but I only want the vertices "a" and "e" to be labeled; the rest should just show as vertices without a label. How can I do that?

\documentclass{article}
\usepackage{tikz}
\usepackage{tkz-graph}
\usepackage{tkz-berge}
\begin{document}
\begin{tikzpicture}[scale=2]
    \GraphInit[vstyle=Classic]
        \SetUpVertex[FillColor=black, MinSize=8pt]
            \Vertex[Math,Lpos=180,x=0,y=-1]{a}
            \Vertex[Math,Lpos=90,x=1,y=0]{b} 
            \Vertex[Math,Lpos=270,x=1,y=-2]{c}
            \Vertex[Math,Lpos=90,x=3,y=0]{d}
            \Vertex[Math,Lpos=270,x=3,y=-2]{e}
            \Vertex[Math,x=4,y=-1]{f}
        \SetUpEdge[lw=1.5pt] 
            \Edges(a,b,c,d,e,f,d,b,e,c,a)
    \end{tikzpicture}
\end{document}

enter image description here

4

You can add NoLabel to the vertices that shouldn't have a label. For those you can also remove Math,LPos=.., as those don't have any effect when there are no labels.

\documentclass{article}
\usepackage{tkz-graph}
\begin{document}
\begin{tikzpicture}[scale=2]
    \GraphInit[vstyle=Classic]
        \SetUpVertex[FillColor=black, MinSize=8pt]
            \Vertex[Math,Lpos=180,x=0,y=-1]{a}
            \Vertex[x=1,y=0,NoLabel]{b} 
            \Vertex[x=1,y=-2,NoLabel]{c}
            \Vertex[x=3,y=0,NoLabel]{d}
            \Vertex[Math,Lpos=270,x=3,y=-2]{e}
            \Vertex[x=4,y=-1,NoLabel]{f}
        \SetUpEdge[lw=1.5pt] 
            \Edges(a,b,c,d,e,f,d,b,e,c,a)
\end{tikzpicture}
\end{document}

enter image description here

  • +1. Also, Lpos for those vertices with NoLabel can also be removed, as they have no effect anymore :-) – hooy Apr 18 '16 at 8:13
  • @hooy Indeed, good point. Will edit. – Torbjørn T. Apr 18 '16 at 8:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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