# Typing Complete Graphs with edge and vertex label

I'm new here. I think this is the right place to ask this question.

Basically I would like to type a simple looking complete graph like this:

http://commons.wikimedia.org/wiki/File:Complex_network_K6_complete_graph.png

What I want is to place vertex and edge labels on top of the edges and vertices.

How would I go on doing that? What packages am I supposed to use and what commands should I type?

Sorry I should have included this picture to show what I have in mind. Thank you!

-
Some graph examples made with tkz-graph package: altermundus.com/pages/tkz/graph/index.html and graphtheoryinlatex.blogspot.com.es – Ignasi May 13 '14 at 8:44

You can use TikZ and its amazing graph library for this.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{graphs,graphs.standard}

\begin{document}
\begin{tikzpicture}
\graph { subgraph K_n [n=8,clockwise,radius=2cm] };
\end{tikzpicture}
\end{document}


You can also add edge labels very easily:

\documentclass[tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{graphs,graphs.standard,quotes}

\begin{document}
\begin{tikzpicture}
empty nodes, nodes={circle,draw}] {
\foreach \x in {a,...,f} {
\foreach \y in {\x,...,f} {
\x -- \y;
};
};
a --["3"'] b;
a --["2"' near start] c;
a --["1", near start] e;
a --["1",] f;
e --["2"'] f;
};
\foreach \x [count=\idx from 0] in {a,...,f} {
\pgfmathparse{90 + \idx * (360 / 6)}
\node at (\pgfmathresult:4.4cm) {\x};
};
\draw (a) edge[red, thick] node[black,left,pos=.2] {1} (d);
\end{tikzpicture}
\end{document}


-
You could define a macro which takes a parameter of the number of nodes and then separate each of the circle with degree 360/#1. I was about to post a solution along those lines, but probably better if you make that minor tweak. – Peter Grill May 13 '14 at 4:40
@PeterGrill Like I did in my edit? – Sean Allred May 13 '14 at 5:06
Looks good..... – Peter Grill May 13 '14 at 5:19
One problem with your labelled edges is that some labels are over-written. The labels 1<-->4 and 2<-->5 are hiding behind 3<-->6 (I think). – corporal May 13 '14 at 6:12
Thank you for this. How could I tweak this a bit so that it will look like that picture on my edit? Is there a way so that the edge labels and the vertex labels are outside? And how could I label them individually? Thank you! – chowching May 13 '14 at 6:45

run with xelatex

\documentclass[pstricks]{standalone}
\usepackage{pst-node,multido}
\begin{document}

\begin{pspicture}(-5,-5)(5,5)
\degrees[6]
\multido{\iA=1+1}{5}{%
\multido{\iB={\numexpr\iA+1\relax}+1}{\numexpr6-\iA}{\ncline{N\iA}{N\iB}}}
\multido{\iA=1+1}{5}{%   The same for the labels
\multido{\iB={\numexpr\iA+1\relax}+1}{\numexpr6-\iA}{%
\ncline[linestyle=none]{N\iA}{N\iB}\ncput*[npos=0.65]{\scriptsize$\iA\leftrightarrow\iB$}}}
\end{pspicture}

\end{document}


-
Sorry. 4<->6 and 5<->1 need some space to avoid overlapping each other. – kiss my armpit May 13 '14 at 15:45

Just another suggestion with PSTricks. Readability level is kept high in both code and its output.

\documentclass[pstricks]{standalone}
\usepackage{pst-eucl}
\degrees[6]

\begin{document}

\begin{pspicture}(-5,-5)(5,5)
\ncline[strokeopacity=.25]{N\iB}{N\iA}\ncput*[nrot=:U,npos=.8]{\scriptsize$\iA\leftrightarrow\iB$}}}

6<->ϛ is still understandable, unless either 6 or 9 appears twice. – kiss my armpit May 13 '14 at 7:23