13

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

14

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

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.