答案1
现在有文本。
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{chains,shadows.blur}
\begin{document}
\begin{tikzpicture}[auto,
node distance = 12mm,
start chain = going below,
box/.style = {draw,rounded corners,blur shadow,fill=white,
on chain,align=center}]
\node[box] (b1) {$x_1\leftarrow0$\\ $y_1\leftarrow0$};
\node[box] (b2) {$x_2\leftarrow\phi(x_1,x_3)$\\
$y_2\leftarrow\phi(y_1,y_3)$\\
$(x_2<10)$?};
\node[box] (b3) {$y_3\leftarrow y_2+x_2$\\ $x_3\leftarrow x_2+1$};
\node[box] (b4) {print($y_2$)};
\begin{scope}[rounded corners,-latex]
\path (b2.-40) edge[bend left=50] (b4.40)
(b1) edge (b2) (b2) edge (b3);
\draw (b3.230) -- ++(0,-0.3) -| ([xshift=-5mm]b2.west) |-
([yshift=3mm]b2.130) -- (b2.130);
\end{scope}
\end{tikzpicture}
\end{document}
我认为可以说基础知识并不太难学。每个人都遇到的问题是 pgfmanual 有 1000 多页,所以任何答案都可以以无数种不同的方式重复。在这里,您可以选择另一种方式来弯曲路径,可以使用节点矩阵和许多其他东西。您的问题是关于“绘制类似这样的控制流图的最简单方法?”。我不是声称这是最简单的方法,但它A可能的方式,在我看来,这相当简单。
答案2
一个简单的pstricks
解决方案:
\documentclass[svgnames, border=12pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{pst-node, pst-blur}
\usepackage{auto-pst-pdf}
\newcommand{\shadowframe}[1]{\psframebox[shadow, blur]{\enspace #1\enspace }}
\begin{document}
\psset{framearc=0.2, shadowcolor=DarkGray, shadowangle=-60}
\begin{psmatrix}[colsep =1cm, rowsep=1.2cm]
&[name=A] \shadowframe{$\begin{aligned}
x_1 & \leftarrow 0 \\ y_1 & \leftarrow 0
\end{aligned}$}\\
& [name=B] \shadowframe{$\begin{gathered}
\begin{aligned}
x_2 & \leftarrow \phi(x_1,x_3)\\ y_2 & \leftarrow \phi(y_1,y_3)
\end{aligned}\\
x_2 < 10\,?
\end{gathered}$}\\
\pnode{I} & [name=C] \shadowframe{$\begin{aligned}
y_3 & \leftarrow y_2 + x_2 \\ x_3 & \leftarrow x_2 + 1
\end{aligned}$}\\
& [name=D] \shadowframe{\makebox[5.75em][l]{print($y_2$)}}
%%% Links
\psset{arrows=->, arrowinset=0.12, linejoin=1, linearc=0.25}%, nodesep=4pt
\ncline{A}{B}
\ncline{B}{C}
\ncbar[arrows=-, angleA=-90,armA=1.2em, offsetA = -2em, angleB=90]{C}{I}%
\ncbar[angleA=90, angleB=90 , offsetB = -2em, armB=1.5em]{I}{B}%
\ncarc[arcangleA=50, arcangleB=60]{B}{D}% offsetB=2em,offset=1em,
\end{psmatrix}
\end{document}