# Dashing one edge from parent in a tree: why does it work

This is related to the question How to make a connection in a tree with a dashed line?. Therein, it is asked how one can make one connection between a parent node and a child dashed.

The final solution proposed is along the line of alternating the edge from parent[solid] and edge from parent[dashed], which is not only ugly, but also incomplete: when drawing nodes at each child, the node inherits (albeit in a weird fashion) the dashed or solid property of the edge from parent.

\documentclass{standalone}
\usepackage{pgfplots}
\usetikzlibrary{trees}
\def\es{edge from parent[solid]}
\def\ed{edge from parent[dashed]}
\begin{document}
\begin{tikzpicture}[every node/.style={draw},level/.style={sibling distance=20mm/#1}]


  \node {}
child{
node {}
child{
node {}
child{
node {}
child{node{}}
child}
child{node{}}}
child
child{
child}
\ed}
child {child[missing] child{child} child {child{child child} child}};


this outputs:

This was the original problem called for in the aforementioned question.

The proposed solution, adding \es every other places, resuts in:

  \node {}
child{
node {}
child{
node {}
child{
node {}
child{node{}}
child}
child{node{}}
\es}
child{\es}
child{
child
\es}
\ed}
child {child[missing] child{child} child {child{child child} child}};


which is displayed as:

has two serious problems: the redundancy, and the fact that a node appears dashed.

Finally, after many attempts, I came up with the following solution:

  \node {}
child{
node {}
child{
node {}
child{
node {}
child{node{}}
child}
child{node{}}}
child
child{
child};
\path \ed;}
child {child[missing] child{child} child {child{child child} child}}


which nicely displays as:

Question: Why? Why do I need a \path? Why doesn't it work with just \ed?

Thanks!

-

I hope it's ok to provide an answer which is not really an answer but an advertisement for my own (tikz-based) tree drawing package, forest. (Until recently, it's available on ctan and also included in TeX Live.)

In forest, the properties of each node and parent-child edge can be set individually. So the stated problem is solved by simply saying edge=dashed at the desired location. (If one wants to set this property for the whole (sub)tree, for tree={edge=dashed} must be used.)

Here's the code. I didn't bother with specifying some nodes as coordinates, since this is irrelevant for the answer, but it can be done: just say coordinate at the node. I did demonstrate what to do with the missing node, though.

\documentclass{standalone}
\usepackage{forest}
\begin{document}
\begin{forest}
for tree={draw}
[
[,edge=dashed[[[][]][]][][[]]]
[,calign=first[[]][[[][]][]]]
]
\end{forest}
\end{document}


-