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.

  • 2
    Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. Commented Apr 19, 2013 at 0:28

2 Answers 2


Here's one possibility:



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


node distance=2cm,
\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)}
  (d) -- node[rotate=90,below] {\mytext[\normalsize]{0.9}{(72/8)}} (c); 
  (c) -- node[rotate=90,below] {\mytext[\normalsize]{0.9}{(72/8)}} (a);
  (d) -- node[sloped,below] {\mytext[\normalsize]{0.9}{(72/8)}} (b); 
  (e) -- node[sloped,below] {\mytext[\normalsize]{0.9}{(72/8)}} (a); 
  (b) to[bend left] node[above] {\mytext[\normalsize]{0.9}{(72/8)}} (a); 
  (a) to[bend left] node[below] {\mytext[\normalsize]{0.9}{(72/8)}} (b); 


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.


Here is one way you can have text in the nodes and also have the node scaled to the weight:

enter image description here


  • You need to carefully select the value of the \DefaultSize based on the range of your data.
  • As per Qrrbrbirlbel's suggestion I have scaled based on the sqrt of the size parameter so as to keep the area proportional to the weight.




\tikzset{My Style/.style={circle,draw=black, ultra thick, fill=yellow!40,align=center}}

    % #1 = optional node paramaters
    % #2 = label
    % #3 = scale
    % #4 = additional text
    \node [My Style, minimum size=\NodeSize,#1] (#2) {#2 \\ {\tiny #3 #4}}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .