答案1
像这样(带有pstricks
)吗?
\documentclass{article}
\usepackage{array}
\usepackage{mathtools, amsfonts, amssymb}
\usepackage{pstricks-add}
\usepackage{auto-pst-pdf}
\begin{document}
\begin{center}
\sffamily\everymath{\scriptstyle}
\begin{pspicture}
\psset{arrows=->, arrowinset=0.15, linewidth=0.6pt, nodesep=2pt, labelsep=2pt, colsep=1cm, rowsep=1.5cm, linejoin=1}
\begin{psmatrix}
& \ovalnode{S}{\,start\strut\,}\\
& \ovalnode{A}{\enspace\,A\strut\enspace\,} \\
\ovalnode{B}{\enspace\,B\strut\enspace\,} & \\
& \ovalnode{C}{\enspace\,C\strut\enspace\,}\\
\end{psmatrix}
\ncline{S}{A}\nbput{\renewcommand\arraystretch{0.8}\begin{tabular}{|>{\footnotesize}l|}\hline Some\\ condition\\\hline\end{tabular}}
\ncline[]{A}{B}\nbput{\footnotesize[true]}%
\ncline[]{A}{C}\naput{\footnotesize[false]}%
\ncline{B}{C}\nbput{\renewcommand\arraystretch{0.8}\begin{tabular}{|>{\footnotesize}l|}\hline Some other\\ condition\\\hline\end{tabular}}
\ncdiagg[angleA=50, armA=2.4]{C}{A}\nbput{\footnotesize[expression]}%
\end{pspicture}
\end{center}
\end{document}
答案2
使用 tikz
\documentclass[margin=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes,positioning}
\tikzset{myellipse/.style={ellipse,draw,minimum width=1.3cm,minimum height=5mm},
myrectangle/.style={draw,text width=1.2cm,align=center,midway,font=\scriptsize},
branode/.style={midway,font=\scriptsize}}
\begin{document}
\begin{tikzpicture}[>=stealth]
\node[myellipse](1){start};
\node[myellipse,below=of 1](2){A};
\node[myellipse,below left=of 2](3){B};
\node[myellipse,below right=of 3](4){C};
\draw[->](1)--(2)node[myrectangle,left=1mm]{some condition};
\draw[->](2)--(3)node[branode,left,anchor=south east]{[true]};
\draw[->](3)--(4)node[myrectangle,left=1mm,anchor=north east]{some other condition};
\draw[->](2)--(4)node[branode,right]{[false]};
\draw[->](4)--+(2,2)coordinate(5)node [branode,right,anchor=north west]{[expression]};
\draw[->](5)--(1);
\end{tikzpicture}
\end{document}