0

I would like to be able to add an arbitrary edge to one of the graphs in tkz-berge. For example, in the graph below I want to add an edge between v0 and v4.

cycle graph

\documentclass[a4paper]{article}

\usepackage{tikz}
\usepackage{tkz-berge}

\begin{document}

\begin{tikzpicture}
  \GraphInit[vstyle=Normal];
  \grCycle[prefix=v,Math=true,RA=2]{10};
\end{tikzpicture}

\end{document}

The tkz-berge documentation describes many \Edge... commands, but they all seem to be schemas for adding edges. I didn't see a command for adding a single, arbitrary edge.

I did try using the plain \Edge command from tkz-graph, guessing the automatically generated vertex label, but had no success. For example, I tried the following:

\Edge(0)(4);
\Edge($v_0$)($v_4$);

I suspect that under the hood there must be a command that's used by the various \Edge... commands to add a single edge.

EDIT Here's the final solution. The labelling scheme is, for example, vertex v_0 has the label v0.

enter image description here

\documentclass[a4paper]{article}

\usepackage{tikz}
\usepackage{tkz-berge}

\begin{document}

\begin{tikzpicture}
  \GraphInit[vstyle=Normal];
  \grCycle[prefix=v,Math=true,RA=2]{10};
  \Edge(v0)(v4);
\end{tikzpicture}

\end{document}
| improve this question | | | | |
1

Something like this

enter image description here

OR

enter image description here

\documentclass[a4paper]{article}

\usepackage{tikz}
\usepackage{tkz-berge}

\begin{document}

\begin{tikzpicture}
  \GraphInit[vstyle=Shade]
  \grCycle[prefix=a,Math=true,RA=4]{10}%
  \EdgeInGraphFromOneToComp{a}{10}{0}
\end{tikzpicture}

\end{document}

OR

\documentclass[a4paper]{article}

\usepackage{tikz}
\usepackage{tkz-berge}

\begin{document}

\begin{tikzpicture}
    \GraphInit[vstyle=Shade]
    \grCycle[prefix=a,Math=true,RA=4]{10}%
    \Edge[](a0)(a4)
\end{tikzpicture}

\end{document}
| improve this answer | | | | |
  • The \EdgeInGraphFromOneToComp command draws edges from a vertex to all other vertices in the graph. I just want to draw a single edge. – mhwombat Nov 27 '19 at 14:20
  • from a0 to a4? as above edit – js bibra Nov 27 '19 at 14:21
  • Grand! Note that in my example, I'm using Math=true, so the vertices are labeled with subscripts. However, \Edge(v0)(v4); does the trick. – mhwombat Nov 27 '19 at 15:12
  • Glad to be of help--my first time being exposed to tikz-berge – js bibra Nov 27 '19 at 15:17

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.