How can I correctly display my AVL tree in LaTex? Solo left baby hanging right

The code below works almost perfectly, however child 9, 7, hangs right down, and not like the left one. How can i fix this?

\usepackage{tikz} \usepackage{xytree} \begin{tikzpicture}[level/.style={sibling distance=60mm/#1}] \node [circle,draw] {4} child { node [circle,draw] {2} child {node [circle,draw] {1} } child { node [circle,draw]{3} } } child {node [circle,draw] {6} child {node [circle,draw] {5} } child {node [circle,draw] {9} child {node [circle, draw] {7}} } }; \end{tikzpicture}} 

Thanks CB

+4
source share
2 answers

After consulting with tikz management, as suggested, I was able to fix it as follows.

 \begin{tikzpicture}[level/.style={sibling distance=60mm/#1}] \node [circle,draw] {4} child { node [circle,draw] {2} child {node [circle,draw] {1} } child { node [circle,draw]{3} } } child {node [circle,draw] {6} child {node [circle,draw] {5} } child {node [circle,draw] {9} child {node [circle, draw] {7}} child [missing] } }; \end{tikzpicture} 
+2
source

The code below works for me. It is based on your code with changes.

1) use the tikz library trees and 2) change the formatting of one node (node ​​7)

See the tikz manual for more information.

 \documentclass{article} \usepackage{tikz} \usetikzlibrary{trees} \begin{document} \begin{tikzpicture}[level/.style={sibling distance=60mm/#1}] \node [circle,draw] {4} child { node [circle,draw] {2} child {node [circle,draw] {1} } child { node [circle,draw]{3} } } child {node [circle,draw] {6} child {node [circle,draw] {5} } child {node [circle,draw] {9} child[grow via three points={one child at (-1,-1) and two children at (-.5,1) and (.5,1)}] {node [circle, draw] {7}} } }; \end{tikzpicture} \end{document} 
+6
source

Source: https://habr.com/ru/post/1304256/


All Articles