2

I want to change the style of some edges of my tree. I want a dashed red path from to root to one leaf of my tree. But if I change some specific edges, all edges below also change. Even the labels are getting red what I do not want.

So that is what happens:

enter image description here

But I want something like that:

enter image description here

Any suggestions? It can't be so hard. But I spend over an hour trying to find out. Here is my code:

\documentclass[border=10pt,svgnames]{standalone} 

\usepackage{tikz}
\usetikzlibrary{positioning,automata,backgrounds}
\definecolor{light-gray}{gray}{0.6}


\begin{document}
\centering
\begin{tikzpicture}[level distance=1.5cm,
  level 1/.style={sibling distance=3cm},
  level 2/.style={sibling distance=1cm},
  level 3/.style={sibling distance=1cm},
  every node/.style={thin}]
  \node {1}
    child {node {00}
      child {node {00}}
      child {node {}}
      child {node {10}}
      child {node {}}
    }
    child {node {}}
    child {node {10}
    child {node {00} edge from parent[dashed, very thick, red]
    child {node {00}}  
    child {node {01}}
    child {node {10}}
    child {node {11} edge from parent[dashed, very thick, red]}
    }
    child {node {}}
    child {node {}}
    child {node {11}}
    }
    child {node {}};
\end{tikzpicture}
\end{document}
4

You can use Forest package with a simple syntax to customize every edges of your tree, just insert edge options like this

edge={dashed,red,thick}

Complete code

\documentclass[border=10pt,svgnames]{standalone} 
\usepackage{forest}

\begin{document}

\begin{forest}
for tree={delay={where content={}{content={\phantom{00}}}{}},s sep+=5mm,l+=5mm}
[1
  [00
     [00]
     []
     [10]
     []  
  ]
  []
  [10,edge={dashed,red,thick} 
     [00,edge={dashed,red,thick}
        [00]
        [01]
        [10]
        [11,edge={dashed,red,thick}]     
     ]
     []
     []
     [11]  
  ]
  [\phantom{00}]
]
\end{forest}

\end{document}

enter image description here

  • How would I draw a circle around a given node with a specific size and color? – Samuel Jan 25 '17 at 20:33
  • For example with root [1,circle,fill=red,inner sep=3mm – Salim Bou Jan 25 '17 at 20:38
  • Great! And what if I want only a red circle instead of filled red circle? Where do I find such information? I hope you can help me out. – Samuel Jan 25 '17 at 20:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.