I'm trying to represent in LaTeX a binary tree implementing a map data structure. Someone told me TikZ was the best tool for that, but I'm failing to achieve my goal. I find TikZ... overhelming?
After exploring a lot of alternatives, this is the first time I think I'm close to an acceptable solution, at least for this very tree.
\documentclass{article}
\usepackage{tikz}
\usepackage{array}
\usetikzlibrary{arrows}
\begin{document}
\newcolumntype{x}[1]{>{\centering\arraybackslash\hspace{0pt}}p{#1}}
\newcommand{\tnode}[2]{
\begin{tabular}{x{2em}|x{2em}}
\tiny{}clave & \tiny{}dato \
$#1$ & $#2$ \\hline
\tiny{}izq & \tiny{}der \
&
\end{tabular}}
\newcommand{\leftedge}{[edge from parent path = {
([xshift=0px, yshift=0px]\tikzparentnode.center)
-- (\tikzchildnode.north)}]}
\newcommand{\rightedge}{[edge from parent path = {
([xshift=0px, yshift=-0px]\tikzparentnode.center)
-- (\tikzchildnode.north)}]}
\begin{tikzpicture}[
level distance=7em,
every node/.style = {align=center, font=\ttfamily,
inner sep=0pt, draw,},
level 1/.style={sibling distance=20em},
level 2/.style={sibling distance=12em},
level 3/.style={sibling distance=6em},
thick, *->, shorten >=2px, >=latex,
]
\node (root) {\tnode{5}{15}}
child[left] { node {\tnode{1}{11}} \leftedge{}
child[right] { node {\tnode{3}{13}} \rightedge{}
child[left] { node {\tnode{2}{12}} \leftedge{}}
child[right] { node {\tnode{4}{14}} \rightedge{}}
}
}
child[right] { node {\tnode{7}{17}} \rightedge{}
child[left] { node {\tnode{6}{16}} \leftedge{}}
};
\end{tikzpicture}
\end{document}
I need left-child pointing arrows to depart from the center of the corresponding izq quarter, and the same for right and der. But I don't know how to set those anchors in my \tnode's. So I have decided to accept using a handwired amount of pixels to shift from a well-known anchor, as the node center is.
But then I find that the black circle I want as a starting tip is not centered around the edge starting point, so the circle position to shift it from is not fixed in a desirable way for my purposes.
I know that multipart nodes exist in TikZ and something called matrix too. I know \tikzmark exist also (for defining new anchors), but it seems it doesn't work well with \tabular.
At this point of desperation, I just want to fix my code in a way I can understand!
I have read something that should be a solution, but I'm sorry, I don't get it.
Is there a simpler solution? Or could someone help me to fix my picture along the lines of the linked one?
Thanks and sorry for the low quality of my question.


