Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm using TikZ for the first time to draw a simple Kripke model, and I'm using the child notation to produce new nodes. How can I turn my edges into arrows?

\begin{tikzpicture}
  \node [circle,draw] (q0) {}
  child {node [circle,draw] (q1) {$p$}
    child {node [circle,draw] (q4) {$p$}
      child {node [circle,draw] (q7) {$p\land q$}}
      child {node [circle,draw] (q8) {$p\land q$}}
      child {node (q9) {} edge from parent[->, dashed]}}
    child {node [circle,draw] (q5) {$q$}}
    child {node (q6) {} edge from parent[dashed]}}
  child {node [circle,draw] (q2) {$p$}}
  child {node (q3) {} edge from parent[dashed]};
\end{tikzpicture}

I know how to change the color or thickness of all edges by passing an option at the beginning of \begin{tikzpicture}, but I can't turn them into arrows.

Also, while we're at it, is there a way to label these edges? Or am I left with simply using node notation for all my nodes?

Thanks for all your help,
Piotr

share|improve this question
1  
Welcome to TeX.SX. To insert labels to edges you can have a look to how to draw a process flow figure? –  Claudio Fiandrino Sep 5 '12 at 17:34
    
I will, thanks! –  pkazmierczak Sep 5 '12 at 19:44
add comment

1 Answer 1

up vote 8 down vote accepted

You can use edge from parent/.style to use arrows; using edge from parent you can label the edges:

\documentclass[12pt,a4paper]{article}
\usepackage{tikz}
\usetikzlibrary{trees,arrows}
\begin{document}

\begin{tikzpicture}[edge from parent/.style={draw,-latex}]
  \node [circle,draw] (q0) {}
  child {node [circle,draw] (q1) {$p$}
    child {node [circle,draw] (q4) {$p$}
      child {node [circle,draw] (q7) {$p\land q$} edge from parent node[left,near start] {a}}
      child {node [circle,draw] (q8) {$p\land q$}}
      child {node (q9) {} edge from parent[->, dashed]}}
    child {node [circle,draw] (q5) {$q$}}
    child {node (q6) {} edge from parent[dashed]}}
  child {node [circle,draw] (q2) {$p$}}
  child {node (q3) {} edge from parent[dashed]};
\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer
    
fantastic, thanks! –  pkazmierczak Sep 5 '12 at 19:43
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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