# Tree graphic using tikz

I want to mimic the tree of the picture, but i can not understand from tikz manual how to do some things:

• aligned lines (the should not start from the upper center of the node point)
• perfectly squared lines: i want all the angles to be 90°: now i just aproximate them with the \tikzstyle{level 1}=[level distance=14mm,sibling distance=25mm] command.
• i'd like the dashed line to start with a little continuous line, and possibly to end with a dot under the h_i label: i tried on the top right to add another (empty) node, but in this way the continuous line is too long.

How should i do these edits?

Any help would be greatly appreciated.

Here my MWE

\documentclass[11pt,a4paper]{article}

\usepackage{tikz}
\usepackage{tikz-qtree}

\begin{document}

\begin{tikzpicture}[scale=1,font=\footnotesize]
\tikzset{
solid node/.style={circle,draw,inner sep=1,fill=black},
hollow node/.style={}
}

\tikzstyle{level 1}=[level distance=14mm,sibling distance=25mm]

\node[solid node,label=right:{$\phi$},label=left:{$t_0$}]{} [grow=up]
child {node[solid node,label=right:{$\phi$}] {}
child {node[solid node,label=right:{$\phi$}]{}
child {node[solid node,label=right:{$\phi$}]{}
child{
%node[solid node,label=right:{$\phi$}] {}
child{node[hollow node,label=45:{$h_\omega$}] {}    edge from parent[dashed]}
child[missing]
}
child {node[solid node,label=right:{$\neg\phi$}] {}
child[missing]
child {node[solid node,label=right:{$\neg\phi$}] {}
child[missing]
child {node[hollow node,label=135:{$h_3$}] {}   edge from parent[dashed]
}
}
}
}
child {node[solid node,label=right:{$\neg\phi$}] {}
child[missing]
child {node[solid node,label=right:{$\neg\phi$}] {}
child[missing]
child {node[hollow node,label=135:{$h_2$}] {}   edge from parent[dashed]
}
}
}
}
child {node[solid node,label=right:{$\neg\phi$}] {}
child[missing]
child {node[solid node,label=right:{$\neg\phi$}] {}
child[missing]
child {node[hollow node,label=135:{$h_1$}] {}   edge from parent[dashed]
}
}
}
}
child {node[solid node,label=right:{$\neg\phi$}] {}
child[missing]
child {node[solid node,label=right:{$\neg\phi$}] {}
child[missing]
child {node[hollow node,label=135:{$h_0$}] {}       edge from parent[dashed]
}
}
};
\end{tikzpicture}

\end{document}


• Welcome to TeX.SX. Questions about how to draw specific graphics that just post an image of the desired result are really not reasonable questions to ask on the site. Please post a minimal compilable document showing that you've tried to produce the image and then people will be happy to help you with any specific problems you may have. See minimal working example (MWE) for what needs to go into such a document. – Stefan Pinnow Oct 23 '17 at 8:41
• – user30471 Oct 23 '17 at 9:11
• @StefanPinnow done. :) – mattinodigitale Oct 23 '17 at 10:32
• @Andrew thanks, but i'm trying with a different approach, i guess. – mattinodigitale Oct 23 '17 at 10:32

I wouldn't use tikz-qtree for such a simple graph.

I suggest to you a solution with \foreach and an ordinary positioning:

\documentclass[11pt,a4paper]{article}

\usepackage{tikz}
\usetikzlibrary{positioning, calc}

\begin{document}
\begin{tikzpicture}[font=\footnotesize,
every node/.style={circle,draw,inner sep=1,fill=black}]
\node[label=right:{$\phi$},label=left:{$t_{0}$}](p0){};
\foreach \i [evaluate=\i as \j using int(\i - 1)] in {1,2,3} {
\node[label=below right:{$\phi$}, above right= of p\j](p\i){};
\draw (p\j) -- (p\i);
}
\node[above right= of p3, label=above right:{$h_{\omega}$}] (p4) {};
\draw (p3) -- ($(p3)!0.3!(p4)$) edge[dashed] (p4);
\foreach \i in {0,1,2,3}{
\coordinate (pl0\i) at (p\i);
\foreach \il [evaluate=\il as \jl using int(\il - 1)] in {1,2} {
\node[label={$\neg\phi$}, above left= of pl\jl\i](pl\il\i){};
\draw (pl\jl\i) -- (pl\il\i);
}
\node[above left= of pl2\i, label=above left:{$h_{\i}$}] (end\i) {};
\draw (pl2\i) -- ($(pl2\i)!0.3!(end\i)$) edge[dashed] (end\i);
}
\end{tikzpicture}
\end{document}


• Wow, this is perfect! I will try to understand how you did it, how you use positioning and the \foreach command! Thank you so much! – mattinodigitale Oct 24 '17 at 18:15
• @mattinodigitale It's simpler that it seems, I just used above right= of and above left= of. The p or pl followed by the index are only the name of the nodes. You could also add a lenght after =. If you need some explanation, just ask, we are here to help. Thank you for accepting my answer! – CarLaTeX Oct 24 '17 at 18:24