I'm using tikz
in study material and I want to show analogy between RB trees and B-trees (2,3,4 tree). I want my output looks something like this example from Wikipedia.
For RB tree I'm using almost exactly same settings as is showed in http://www.texample.net/tikz/examples/red-black-tree/ (just different settings for nil node). I could create 3 nodes in same layer, but it would use manually set position. I also do not know, hot to put these nodes together in rectangle.
Would anybody give me hints or solution? I will be very grateful.
Edit: I've tried this:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}
\begin{document}
\tikzset{
treenode/.style = {align=center, inner sep=4pt, text centered,font=\sffamily},
bnode/.style = {treenode, circle, white, font=\sffamily\bfseries, draw=black, fill=black, text width=1.5em},
rnode/.style = {treenode, circle, red, draw=red, text width=1.5em, very thick},
nilnode/.style = {treenode, minimum width=1.3em, minimum height=0.9em}
}
\begin{tikzpicture}[->,>=stealth',level/.style={sibling distance = 6cm/#1, level distance = 1.5cm}]
\node [bnode] {13}
child[level distance = 0cm]{ node [rnode] {8}
child{ node [bnode] {1}
child[level distance = 0cm]{ node [nilnode] {Nil} }
child[level distance = 0cm]{ node [rnode] {6}
child{ node [nilnode] {Nil} }
child{ node [nilnode] {Nil} }
}
}
child{ node [bnode] {11}
child[level distance = 0cm]{ node [nilnode] {Nil}}
child[level distance = 0cm]{ node [nilnode] {Nil}}
}
}
child[level distance = 0cm]{ node [rnode] {17}
child{ node [bnode] {15}
child[level distance = 0cm]{ node [nilnode] {Nil}}
child[level distance = 0cm]{ node [nilnode] {Nil}}
}
child{ node [bnode] {25}
child[level distance = 0cm]{ node [rnode] {22}
child{ node [nilnode] {Nil} }
child{ node [nilnode] {Nil} }
}
child[level distance = 0cm]{ node [nilnode] {Nil}}
}
}
;
\end{tikzpicture}
\end{document}
Output is this:
I need at least the rectangle as border of merged node. If you also know, how to insert some separator (under the arrows in same layer), it would be even better.
//I hope, that now the post meet the rules about question and sorry for previous version.