4

I'm trying to draw a graph using tkz-berge, where many of the vertices might display the same value, is there a way I can do this?

Here is my code:

\begin{figure}[h]
\centering
\begin{tikzpicture}[scale=0.75,transform shape]
  \tikzstyle{LabelStyle}=[fill=white,sloped]
  \Vertex[x=0,y=0]{A}
  \Vertex[x=-2,y=-1]{B}
  \Vertex[x=2,y=-1]{C}
  \tikzstyle{EdgeStyle}=[post]
  \Edge[](A)(B)
  \Edge[](A)(C)
\end{tikzpicture}
\caption{\label{fig:typical}Cool graph}
\end{figure}

But instead of B<-A->C (is what this graph looks like), I'd like it to be, for example, something like B<-A->B. So basically I guess what I'm asking is, can I have the name of the vertex in the code be different from what is actually displayed on the screen (like a "label")?

P.S. I don't have enough reputation to create the tag 'tkz-berge', but there is a 'tkz-graph' tag. I can't tell if that package is different or an alternate name of berge, but it seems to be very similar, so tagging as that.

7

Use the L= option for \Vertex to have a different label:

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

\begin{document}

\begin{figure}
\centering
\begin{tikzpicture}[scale=0.75,transform shape]
  \tikzstyle{LabelStyle}=[fill=white,sloped]
  \Vertex[x=0,y=0]{A}
  \Vertex[x=-2,y=-1]{B}
  \Vertex[x=2,y=-1,L=B]{C}
  \tikzstyle{EdgeStyle}=[post]
  \Edge[](A)(B)
  \Edge[](A)(C)
\end{tikzpicture}
\caption{\label{fig:typical}Cool graph}
\end{figure}

\end{document}

enter image description here

As a side note, don't use the too restrictive placement specifier [h].

  • That's exactly what I was looking for! Will look into the [h] as well, thanks. – mindthief Oct 23 '12 at 1:47

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.