I'm drawing a binary tree using tikz-qtree
. In my binary tree the order of children is important, so I need distinguish which edge is the left one and the right one. In my sample code I can't distinguish if the node 1 is left or right. There is a way to specify this?
\documentclass[demo]{article}
\usepackage{tikz,tikz-qtree}
\begin{document}
\begin{figure}[ht]\begin{center}\begin{tikzpicture}[grow'=up]
\Tree [.\node(8){8};
[.\node(5){5};
[.\node(3){3};
\node(1){1}; ]
\node(6){6}; ]
\node(12){12}; ]
\end{tikzpicture}\end{center}\end{figure}
\end{document}
Best Answer
You can specify edges explicitly when needed, and specify
[draw=none]
. I've also simplified your tree: you don't need to enclose every node in a\node
command unless you have independent reasons for referring to them. For this kind of tree, it might be helpful to make every node a uniform size, so that the sibling distances don't vary. You can do this by setting a minimum size for theevery tree node/.style
. I've given a second tree showing how this can be done. In a single tree, you could add the option to the{tikzpicture}
environment itself instead of using\tikzset
.