[Tex/LaTex] Typing Complete Graphs with edge and vertex label

graphicstikz-pgf

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?

enter image description here

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

Best Answer

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}

output

You can also add edge labels very easily:

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

\begin{document}
\begin{tikzpicture}
  \graph[circular placement, radius=4cm,
         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}

output