[Tex/LaTex] Typesetting digraph with weighted edges, varying vertex size, multiple lines in vertex

dimensionsgraphstikz-pgf

I would like to draw the graph displayed in the following picture with TikZ and also do some modifications:

enter image description here

Firstly I want to carry the labels of the nodes to the inside as a second line.
For instance inside node a it will display a, and then below (0.5 70/70) (preferably with a smaller font than a).

Moreover I would like to change the sizes of the nodes wrt. the the numeric value displayed in the label. So as an example the node e will be approximately twice as big as node a.

Best Answer

Here's one possibility:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}

\definecolor{myyellow}{RGB}{255,255,150}

\newcommand\mytext[3][\scriptsize]{#2\\#1 #3}
\newcommand\mynode[4][]{%
  \node[mynode,#1,text width=\the\dimexpr#2cm*3] (#3) {\mytext{#3}{#2 #4}}; 
}

\begin{document}

\begin{tikzpicture}[
node distance=2cm,
mynode/.style={
  circle,
  draw,
  fill=myyellow,
  align=center}
]
\mynode{0.67}{d}{(130/61)}
\mynode[below=of d]{0.45}{c}{(130/61)}
\mynode[below=of c]{0.50}{a}{(130/61)} 
\mynode[left=of a]{0.67}{b}{(130/61)} 
\mynode[right=of c]{0.95}{e}{(130/61)}
\draw[->] 
  (d) -- node[rotate=90,below] {\mytext[\normalsize]{0.9}{(72/8)}} (c); 
\draw[->] 
  (c) -- node[rotate=90,below] {\mytext[\normalsize]{0.9}{(72/8)}} (a);
\draw[->] 
  (d) -- node[sloped,below] {\mytext[\normalsize]{0.9}{(72/8)}} (b); 
\draw[->] 
  (e) -- node[sloped,below] {\mytext[\normalsize]{0.9}{(72/8)}} (a); 
\draw[->] 
  (b) to[bend left] node[above] {\mytext[\normalsize]{0.9}{(72/8)}} (a); 
\draw[->] 
  (a) to[bend left] node[below] {\mytext[\normalsize]{0.9}{(72/8)}} (b); 
\end{tikzpicture}

\end{document}

enter image description here

The syntax for the \mynode command is

\mynode[<options>]{<value>}{<name>}{<additional text>}

The optional argument passes <options> to a \node; <value> will be used to internally calculate the node size, and also in the label; <name> will be used for the label and to name the node, <additional text> is the text that will accompany <value> in the label.

Related Question