2

Hey TeX Stack Exchangers,

I have to draw some really basic undirected graphs in TikZ and struggling to find documentation that fits my needs. Each of my graphs has 10 edges and an equal number of degrees per vertice. I want to draw 3 graphs as follows:

  1. A graph with 20 nodes each with a degree of 1
  2. A graph with 10 nodes each with a degree of 2
  3. A graph with 5 nodes each with a degree of 4

I obviously don't want to hand code all of these nodes and edges. I've been playing around with loops in TikZ but it is really frustrating. The closest thing I found for graph #2 is this link but it isn't much help.

Thanks!

  • Thanks @HarishKumar! Turns out my problems are solved easily with tkz-berge. One of the hardest things about starting out with LaTeX is knowing what things are called in order to look them up. – plast Sep 25 '15 at 13:34
3

With a special package for graphs it is easy:

\documentclass{article}

\usepackage{tkz-berge}
\begin{document}

\begin{tikzpicture}
\SetVertexMath
\grEmptyPath[prefix=v,RA=2,RS=0]{5}
\grEmptyPath[prefix=w,RA=2,RS=3]{5}
\EdgeIdentity{v}{w}{5}
\end{tikzpicture}

\begin{tikzpicture}

\SetVertexMath
\grCycle[RA=2]{10}
\end{tikzpicture}

\begin{tikzpicture}

\SetVertexMath
\grComplete[RA=2]{5}
\end{tikzpicture}

\end{document} 

See documentation of tkz-berge.

enter image description here

  • Wow thanks I didn't know this package existed. I will definitely dive in! – plast Sep 25 '15 at 13:30

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.