I'm drawing trees in graph theory. Some of the nodes are overlapped. Can anyone help?
% Red-black tree
% Author: Madit
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}
\tikzset{
treenode/.style = {align=center, inner sep=0pt, text centered,
font=\sffamily},
arn_n/.style = {treenode, circle,black, draw=black, text width=1.5em}% arbre rouge noir, noeud noir
%arn_r/.style = {treenode, circle, black, draw=black,
%text width=1.5em},% arbre rouge noir, noeud rouge
%arn_x/.style = {treenode, circle, black, draw=black,
% text width=1.5em}% arbre rouge noir, nil
}
\begin{document}
%1
\begin{tikzpicture}[->,>=stealth',level/.style={sibling distance = 5cm/#1,
level distance = 1.5cm}]
\node [arn_n] {4}
child{ node [arn_n] {3}
child{ node [arn_n] {1}
child{ node [arn_n] {5} } %for a named pointer
child{ node [arn_n] {}}
}
child{ node [arn_n] {2}
%child{ node [arn_n] {18}}
%child{ node [arn_n] {}}
}
child{ node [arn_n] {2}
%child{ node [arn_n] {18}}
%child{ node [arn_n] {}}
}
}
child{ node [arn_n] {3}
child{ node [arn_n] {1}
%child{ node [arn_n] {5} } %for a named pointer
%child{ node [arn_n] {}}
}
child{ node [arn_n] {2}
%child{ node [arn_n] {18}}
%child{ node [arn_n] {}}
}
child{ node [arn_n] {2}
%child{ node [arn_n] {18}}
%child{ node [arn_n] {}}
}
}
child{ node [arn_n] {3}
child{ node [arn_n] {1}
%child{ node [arn_n] {5} } %for a named pointer
%child{ node [arn_n] {}}
}
child{ node [arn_n] {2}
%child{ node [arn_n] {18}}
%child{ node [arn_n] {}}
}
child{ node [arn_n] {2}
%child{ node [arn_n] {18}}
%child{ node [arn_n] {}}
}
}
;
\end{tikzpicture}
\end{document}




sibling distancefor level 2.Sibling distancefor level 1 is 5cm, and for level two is 2.5cm, so right most child and left most child are placed at same place. – Ignasi Nov 11 '13 at 12:00