Take the 2-minute tour ×
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'm trying the draw a tree using the TikZ package, but I don't know how to draw a child node that has many parents. An example for that, is given by this picture power set graph

My problem is how to draw the level 3.

share|improve this question
3  
By definition this is not a tree, but a (more general) graph. –  Caramdir Jun 8 '12 at 22:51
add comment

1 Answer 1

up vote 11 down vote accepted

You can use two trees sitting on top of each other.

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[sibling distance=2.5cm]
\node (topnode) at (0,5) { {\{\{1\}\{2\}\}\{3\}\{4\}}\} } 
child { node {{\{\{1,2\}\{3\}\{4\}}\}} }
child { node {{\{\{1,3\}\{2\}\{4\}}\}} }
child { node {{\{\{1,4\}\{2\}\{3\}}\}} }
child { node {{\{\{2,3\}\{1\}\{4\}}\}} }
child { node {{\{\{2,4\}\{1\}\{3\}}\}} }
child { node {{\{\{3,4\}\{1\}\{2\}}\}} }
;

\node[minimum width=3cm](bottomnode) {\{\{1,2,3,4\}\}} [grow'=up]
child { node {{\{\{1,2,3\}\{4\}}\}} }
child { node {{\{\{1,2,4\}\{3\}}\}} }
child { node {{\{\{1,2\}\{3,4\}}\}} }
child { node {{\{\{1,3,4\}\{2\}}\}} }
child { node {{\{\{1,3\}\{2,4\}}\}} }
child { node {{\{\{1,4\}\{2,3\}}\}} }
child { node {{\{\{2,3,4\}\{1\}}\}} }
;
\foreach \x in {1,2,3}{
\draw (topnode-1) -- (bottomnode-\x);
}
\end{tikzpicture}
\end{document}

enter image description here

I'll leave the connection lines to you if you don't mind. You can access each node by first writing up the parent node name followed by a dash and the item number e.g. (topnode-5).

share|improve this answer
2  
Very beautiful answer... New exercise: how to generalize the construction of this graph if initial set contains n elements? ;-) –  Paul Gaborit Jun 9 '12 at 0:05
3  
@PolGab I did it already... axiomatically :P –  percusse Jun 9 '12 at 0:45
add comment

protected by Martin Scharrer Jun 9 '12 at 13:43

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

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