TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 10 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

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.