1

I have a similar question, as asked here: How to set style of a single edge in the tree (TikZ) ?

I have a tree, built with tikz. I want to style some single edges dashed, instead of solid. So i did what was mentioned in the above thread and it did work, but strangely the edged of the nodes themselves followed by the node which has the incoming dotted edge are dotted, too. Why?

Here is the example from the thread mentioned above, changed to dotted edges:

\documentclass{article}
\usepackage{tikz}
\begin{document}
    \begin{tikzpicture} [
    level 1/.style={sibling distance = 2cm, level distance = 1cm},
    level 2/.style={sibling distance = 1cm},
    level 3/.style={sibling distance = 1cm},
    every node/.style={circle, draw=black,thin, minimum size = 0.5cm},
    emph/.style={edge from parent/.style={dashed,red,very thick,draw}},
    norm/.style={edge from parent/.style={solid,black,thin,draw}}
    ]

    \begin{scope}[xshift=6cm]
    \node{} 
    child[emph] { node {}
        child[norm] { node {} }
        child[norm] { node {}
            child[emph] { node {} }
            child { node {} }
        }
    }
    child { node {}
        child { node {} }
        child { node {} }
    }
    child { node {} }
    ;
    \end{scope}
    \end{tikzpicture}

\end{document}

And here is what it looks like: enter image description here

1 Answer 1

1

You need to add solid to every nodes/.style

\documentclass{article}
\usepackage{tikz}
\begin{document}
    \begin{tikzpicture} [
    level 1/.style={sibling distance = 2cm, level distance = 1cm},
    level 2/.style={sibling distance = 1cm},
    level 3/.style={sibling distance = 1cm},
    every node/.style={circle,solid, draw=black,thin, minimum size = 0.5cm},
    emph/.style={edge from parent/.style={dashed,red,very thick,draw}},
    norm/.style={edge from parent/.style={solid,black,thin,draw}}
    ]

    \begin{scope}[xshift=6cm]
    \node{} 
    child[emph] { node {}
        child[norm] { node {} }
        child[norm] { node {}
            child[emph] { node {} }
            child { node {} }
        }
    }
    child { node {}
        child { node {} }
        child { node {} }
    }
    child { node {} }
    ;
    \end{scope}
    \end{tikzpicture}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .