[OS X TeX] Complete Graphs on n vertices

Luís Fernando Sequeira lfsequeira at gmail.com
Sun Nov 27 16:37:15 CET 2022


As promised, here is a version of the code to draw a complete graph, using tikz. 
In this complete example, it draws K28, but it works with any number of nodes.
I added an optional parameter so you can easily change the size of the drawing.

I find it quite nice, too :-)

Regards

Luís Sequeira

----------
%!TEX TS-program = xelatex

\documentclass{article}

\pagestyle{empty}

\usepackage{tikz}

\newcommand{\K}[2][5]{
    \begin{tikzpicture}
      \newcommand{\ang}{360/#2}
      \foreach \i in {1,...,#2}
         \foreach \j in {1,...,#2}
            \draw (\ang*\i:#1) -- (\ang*\j:#1);
   \end{tikzpicture}
}

\begin{document}
\begin{center}
\K[3]{23}
\end{center}
\end{document}
----------
----------- Please Consult the Following Before Posting -----------
TeX FAQ: https://www.tug.org/mactex/faq/index.html
List Reminders and Etiquette: https://sites.esm.psu.edu/~gray/TeX/
List Archives: http://dir.gmane.org/gmane.comp.tex.macosx
                https://email.esm.psu.edu/pipermail/macosx-tex/
TeX on Mac OS X Website: https://www.tug.org/mactex/index.html
List Info: https://email.esm.psu.edu/mailman/listinfo/macosx-tex



More information about the macostex-archives mailing list.