Sign up ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am trying to tek up a Bayesian network with nodes, edges, and truth tables next to each node like this:

enter image description here

What tools can I use to make something like that? Perhaps some package from the TikZ library?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Here's one possibility using TikZ; the tabular material was placed inside \nodes. The shapes library was used to have elliptical nodes.

The dcolumn package was used to get columns with alignment at the decimal separator; the booktabs package was used to build the tables (in particular, no vertical rules were drawn):




  node distance=1cm and 0cm,
  mynode/.style={draw,ellipse,text width=2cm,align=center}
\node[mynode] (sp) {Sprinkler};
\node[mynode,below right=of sp] (gw) {Grass wet};
\node[mynode,above right=of gw] (ra) {Rain};
\path (ra) edge[-latex] (sp)
(sp) edge[-latex] (gw) 
(gw) edge[latex-] (ra);
\node[left=of sp,left=0.5cm of sp]
& \multicolumn{2}{c}{Sprinkler} \\
Rain & \multicolumn{1}{c}{T} & \multicolumn{1}{c}{F} \\
F & 0.4 & 0.6 \\
T & 0.01 & 0.99 \\
\node[left=of sp,right=0.5cm of ra]
\multicolumn{2}{c}{Sprinkler} \\
\multicolumn{1}{c}{T} & \multicolumn{1}{c}{F} \\
0.2 & 0.8 \\
\node[left=of sp,below=0.5cm of gw]
& & \multicolumn{2}{c}{Grass wet} \\
\multicolumn{2}{l}{Sprinkler rain} & \multicolumn{1}{c}{T} & \multicolumn{1}{c}{F} \\
F & F & 0.4 & 0.6 \\
F & T & 0.01 & 0.99 \\
T & F & 0.01 & 0.99 \\
T & T & 0.01 & 0.99 \\



enter image description here

share|improve this answer
Unfortunately, I am not able to comment Gonzalo Medinas answer, but please note that the arrow between "Grass wet" and "Rain" points into the wrong direction, which makes the network cyclic! – black.firefly Jun 16 at 9:02
@black.firefly the fix is simple: change (gw) edge[-latex] (ra) to (gw) edge[latex-] (ra). I edited the answer to incorporate the change. Thanks. – Gonzalo Medina Jun 16 at 13:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.