我第一次使用 TikZ 绘制一个简单的 Kripke 模型,并使用符号child
来生成新节点。我怎样才能将边变成箭头?
\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}
我知道如何通过在开头传递一个选项来改变所有边缘的颜色或厚度\begin{tikzpicture}
,但我无法将它们变成箭头。
另外,既然我们已经这样做了,有没有办法标记这些边?还是我只能简单地node
为所有节点使用符号?
谢谢你的帮助,
Piotr
答案1
您可以edge from parent/.style
使用箭头;使用edge from parent
您可以标记边缘:
\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}