TransWikia.com

Tikz: How to turn node into arrows?

TeX - LaTeX Asked by KaneM on August 15, 2020

I have the tikz diagram below and I am trying to change the white nodes into arrows from the parent node.
Here is the current diagram

enter image description here

Here is what is a rough sketch of what I am trying to make: enter image description here

I have posted what I have so far below. Any help in making this would be very much appreciated

documentclass[11pt]{report}
usepackage{tikz}
begin{document}
    begin{tikzpicture}[level/.style={sibling distance=90mm/#1},scale=0.7]
  node [circle,draw,fill=gray,scale=0.7] (z){$s_0$}
    child {node [circle,draw,scale=0.7](d){$a_1$}
      child {node [circle,draw,fill=gray,scale=0.6] (a) {$s_1'$} 
      child {node {$vdots$}}edge from parent node[left=4mm] {small{$r=10$}}edge from parent node[ fill=white] {tiny{$1$}}
    }
  }
  child {node [circle,draw,scale=0.7] (a) {$a_2$}
    child {node [circle,draw,fill=gray,scale=0.6] (b) {$s_2'$}
      child {node {$vdots$}}
      child {node {$vdots$}}edge from parent node[ above=0.2mm, left=3mm] {small{$r=20$}}edge from parent node[ fill=white] {tiny{$0.5$}}
    }
    child {node [circle,draw,fill=gray,scale=0.6] (g) {$s'_3$}
      child {node {$vdots$}}
        child [grow=right] {node (q) {s'} edge from parent[draw=none]
            child [grow=up] {node (r) {a} edge from parent[draw=none]
            child [grow=up] {node (s) {$s$} edge from parent[draw=none]}}
        }edge from parent node[ above=1mm, right=2mm] {small{$r=75$}}edge from parent node[ fill=white] {tiny{$0.5$}}
    }
  }

;



end{tikzpicture}

end{document}



One Answer

You can add ->,level 2/.style={-} to the options of your tikzpicture environment to draw an arrow to the first child level.

documentclass[11pt]{report}
usepackage{tikz}
begin{document}
    begin{tikzpicture}[
            level/.style={sibling distance=90mm/#1},
            ->,
            level 2/.style={-},
            scale=0.7]
    node [circle,draw,fill=gray,scale=0.7] (z){$s_0$}
        child {node [circle,draw,scale=0.7](d){$a_1$}
            child {node [circle,draw,fill=gray,scale=0.6] (a) {$s_1'$} 
            child {node {$vdots$}}edge from parent node[left=4mm] {small{$r=10$}}edge from parent node[ fill=white] {tiny{$1$}}
        }
    }
    child {node [circle,draw,scale=0.7] (a) {$a_2$}
        child {node [circle,draw,fill=gray,scale=0.6] (b) {$s_2'$}
            child {node {$vdots$}}
            child {node {$vdots$}}edge from parent node[ above=0.2mm, left=3mm] {small{$r=20$}}edge from parent node[ fill=white] {tiny{$0.5$}}
        }
        child {node [circle,draw,fill=gray,scale=0.6] (g) {$s'_3$}
            child {node {$vdots$}}
                child [grow=right] {node (q) {s'} edge from parent[draw=none]
                    child [grow=up] {node (r) {a} edge from parent[draw=none]
                    child [grow=up] {node (s) {$s$} edge from parent[draw=none]}}
                }edge from parent node[ above=1mm, right=2mm] {small{$r=75$}}edge from parent node[ fill=white] {tiny{$0.5$}}
        }
    }

;



end{tikzpicture}

end{document}

Answered by luki on August 15, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP