答案1
凸起可以用弧线来制作:arc(90:-90:3pt)
向右凸起,arc(180:0:3pt)
垂直凸起。位置可以进行计算,但对于仅有两个凸起的情况来说这有点麻烦,因此在下面的图中它们是手工定位的。
下面的代码定义了一个命令
\drawdh[options for \draw]{from-node}{to-node}{edge label}
from-node
绘制一条从到 的水平对角线to-node
,并将对角线标记为edge label
。同样,还有一个\drawdv
绘制垂直对角线的命令。
\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,calc,circuits.ee.IEC}
\tikzset
{op/.style={circle,draw,minimum width=2.5em,inner sep=1pt,font=\small},
cp/.style={op,node contents=copy},
eq/.style={op,node contents={$=$}},
eq0/.style={op,node contents={${=}0$}},
br/.style={op,node contents={BR}},
gr/.style={ground,right,point down},
dec/.style={op,node contents={$-1$}},
inc/.style={op,node contents={$+1$}},
>=stealth
}
\newcommand\drawdh[4][]% diagonal horizontal
{\draw[#1]
let \p1=(#2),\p2=(#3) in
(#2) -- node[above,font=\scriptsize]{#4}
({\x1+abs(\y2-\y1)*sign(\x2-\x1)},\y2) -- (#3);%
}
\newcommand\drawdv[4][]% diagonal vertical
{\draw[#1]
let \p1=(#2),\p2=(#3) in
(#2) -- node[above,font=\scriptsize]{#4}
(\x2,{\y1+abs(\x2-\x1)*sign(\y2-\y1)}) -- (#3);%
}
\begin{document}
\begin{tikzpicture}[node distance=1cm,circuit ee IEC]
% below n
\node (n) {$n$};
\node (c1) [cp,below=of n];
\node (e1) [eq0,below right=of c1];
\node (c2) [cp,below=of e1];
\node (b1) [br,below left=of c1,yshift=-3cm];
\node (d1) [dec,left=3cm of e1];
\draw[->] (n) -- coordinate (nc1) (c1);
\draw[->] (c1) -- (e1);
\draw[->] (e1) -- (c2);
\drawdv[->]{c1}{b1}{}
\drawdh[->]{c2}{b1}{}
\draw[->] (b1) -- node[above,font=\scriptsize]{T} ++( 0.8,-0.8) coordinate (b1T);
\draw (b1T) -- +(0,-0.2) node[gr]{};
\draw[->] (b1) --node[above,font=\scriptsize]{F} ++(-0.8,-0.8) -| (d1);
\draw[->] (d1) |- (nc1);
% below x
\node[left=6.5cm of n] (x) {$x$};
\node (c3) at (x|-c2) [cp];
\node (b2) [br,below left=of c3,yshift=-1.5cm];
\node (e2) [eq,below right=of c3];
\draw[->] (x) -- coordinate[pos=0.8] (xc3) (c3);
\drawdv[->]{c3}{b2}{}
\draw[->] (c3)--(e2);
\draw[->] (b2) -- node[above,font=\scriptsize]{T} ++( 0.8,-0.8) coordinate (b1T);
\draw (b1T) -- +(0,-0.2) node[gr]{};
\draw[->] (b2) --node[above,font=\scriptsize]{F} ++(-0.8,-0.8) -- ++(-0.5,0) |- (xc3);
\draw[->] (d1) |- (nc1);
\draw[->] (c2) |- (b2);
% below v
\node[right=2.5cm of x,%
label={[right,align=left,yshift=-6ex]$v_{n-1}$\\$v_{n-2}$\\$\vdots$\\$v_0$}] (v) {};
\drawdv[<-]{e2}{v}{}
% below 0
\node[right=3.5cm of n] (0) {$0$};
\node (b3) at (0|-b1) [br];
\node (b4) [br,below right=4mm of b3,yshift=-1.5cm];
\node (i1) [inc,below left=4mm of b4,yshift=-1cm];
\draw[->] (0) -- coordinate[pos=0.8] (0b3) (b3);
\drawdh[->]{c2}{b3}{}
\draw[->] (b3) -- node[above,font=\scriptsize]{T} ++(-0.8,-0.8) -- ++(0,-5) node[below]{answer};
\drawdv[->]{b3}{b4}{F}
\drawdv[->]{b4}{i1}{T}
\draw[->] (b4) -- node[above,font=\scriptsize]{F} ++( 0.8,-0.8) -- ++(0.5,0) coordinate (b4F);
\draw[->] (i1) |- ($(b4F)+(0,-2)$) |- (0b3);
\draw[->] (e2) -- ++(0,-1.4) arc(90:-90:3pt) |- ($(b4)+(-1.83,0)$) arc(180:0:3pt) -- (b4);
\end{tikzpicture}
\end{document}