I'm trying to reproduce a graph from a paper using Tikz, the graph that I'm trying to reproduce is the following:
But without the horizontal curved line and brackets on the left subtree. So far, this is what I get:
\documentclass[a4paper,12pt]{article}
\usepackage{tikz}
\tikzset{
treenode/.style = {align=center, inner sep=0pt, text centered,
font=\sffamily\Large\bfseries, text width=5cm},
burned/.style = {treenode, circle, white, draw=red, fill=red, text width=1.5em, very thick},
saved/.style = {treenode, circle, white, draw=green, fill=green, text width=1.5em, very thick},
untouch/.style = {treenode, circle, white, draw=gray, fill=gray, text width=1.5em, very thick}
}
\begin{document}
\begin{tikzpicture}[auto, node distance=2cm, thick]
% nodes
\node[burned](1){F};
\node[saved](2) [below left of=1] {S};
\node[untouch](3) [below left of=2] {};
\node[untouch](4) [below right of=2] {};
\node[burned](5) [below of=1] {B};
\node[burned](6) [below right of=1] {B};
\node[saved](7) [below of=5] {S};
\node[burned](8) [below of=6] {B};
\node[untouch](9) [below of=7] {};
\node[saved](10) [below of=8] {S};
\node[untouch](11) [below of=9] {};
\node[untouch](12) [below of=11] {};
\node[untouch](13) [below of=10] {};
\node[untouch](14) [below of=13] {};
%edges
\path
(1) edge node [right] {} (2)
edge node [below] {} (5)
edge node [left] {} (6)
(2) edge node [right] {} (3)
edge node [right] {} (4)
(5) edge node [below] {} (7)
edge node [left] {} (8)
(7) edge node [below] {} (9)
(9) edge node [below] {} (11)
(11) edge node [below] {} (12)
(6) edge node [right] {} (7)
edge node [below] {} (8)
(8) edge node [below] {} (10)
(10) edge node [below] {} (13)
(13) edge node [below] {} (14);
\end{tikzpicture}
\end{document}
Which produces the following graph:
So, basically I have three questions:
- Is there any way to avoid the overlapping between the edges and nodes?
- Also, there is any way to get the nodes from the same level to be aligned? (Like in the graph of the paper)
- There is another LaTex package or tikz library with a more intuitive syntax to draw graphs (i.e. graphs with edges/nodes)? Maybe something similar do Graphviz dot syntax.
sibling distance
doesn't do anything here, because you're not actually using the tree syntax of TikZ. See chapter 21 Making Trees Grow in the manual for a description of how it works.sibling distance
attribute. I edited my question for further reference.