How to modify the distance between branches when drawing trees using TiKZ?
Rather than setting this all manually, you can use tikz-qtree
to construct these kinds of trees very easily, and it will adjust the sibling distance automatically. (I've enlarged the default sibling distance slightly; but no other manual changes are required.)
\documentclass{article}
\usepackage{tikz-qtree}
\begin{document}
\tikzset{edge from parent/.style=
{draw, edge from parent path={(\tikzparentnode) -- (\tikzchildnode)}}}
\begin{tikzpicture}[every tree node/.style={draw,circle},sibling distance=.25cm]
\matrix{
\Tree
[.0
[.1 5 5 5 5 ]
[.2 ]
]
&
\Tree [.0
[.1 5 5 5 5 5 5 ]
[.2 6 6 ]
]
\\};
\end{tikzpicture}
\end{document}
You can change the sibling distance
for each level of the tree individually, using level <number>/.style={sibling distance=<value>}
:
\documentclass[a4paper,landscape]{scrartcl}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[
auto,
level 1/.style={sibling distance=40mm},
level 2/.style={sibling distance=10mm}]
\node [circle,draw] (z){0}
child {
node[circle,draw] (a) {1}
child {
node[circle,draw] (c) {5}
}
child {
node[circle,draw] (d) {5}
}
child {
node[circle,draw] (e) {5}
}
child {
node[circle,draw] (f) {5}
}
}
child {
node[circle,draw] (b) {2}
}
;
\end{tikzpicture}
\end{document}