我使用 TikZ 包创建了如左图所示的流程图(我使用的代码如下)。我想添加曲线边缘流程图和循环,使其如右图所示。
先感谢您。
我的代码。
\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{calc,trees,positioning,arrows,chains,shapes.geometric,
decorations.pathreplacing,decorations.pathmorphing,shapes,
matrix,shapes.symbols}
\usepackage{array}
\usepackage{amsmath}
\usepackage{amsxtra}
\usepackage{amsfonts}
\usepackage{amssymb}
\begin{document}
\begin{center}
\tikzstyle{decision} = [diamond, draw, fill=blue!20,text width=6.5em, text badly centered, node distance=5cm, inner sep=0pt]
\tikzstyle{block} = [rectangle,fill=blue!20, text width=8em, text centered, rounded corners, minimum height=4em]
\tikzstyle{line} = [draw, -latex']
\tikzstyle{arco} = [draw,->]
\tikzstyle{cloud} = [draw, circle,fill=red!20, node distance=4cm,minimum height=4em]
\tikzstyle{pil} = [->,thick,shorten <=2pt, shorten >=2pt]
\begin{tikzpicture}[node distance = 2cm, auto]
% Place nodes
\node [block]
(12)
{1nialize model};
\node [block, left of=12, node distance=6cm]
(11) {\\ Probability spaces \\ $(\mathbb{R},\mathcal{B}(\mathbb{R}),\mathbb{P})$\\ };
\node [cloud, right of=12]
(13)
{coments};
\node [block, below of=12]
(22)
{verify candidate models};
\node [block, below of=22]
(32) {rum candidate models};
\node [block, left of=32, node distance=6cm]
(31) {update model};
\node [decision, below of=32]
(decide) {is best candidate better?};
\node [block, below of=decide, node distance=6cm]
(stop) {stop};
% Draw edges
\path [line] (12) -- (22);
\path [line] (13) -- (22);
\path [line] (22) -- (32);
\path [line] (32) -- (decide);
\path [line] (decide) -| node [near start] {yes} (31);
\path [line] (31) |- (22);
\path [line] (decide) -- node {no}(stop);
\path [line] (11) -- (12);
\path [arco] (13) -- (12);
\path [arco] (13) |- (32);
\path [arco] (13) -- (stop);
\end{tikzpicture}
\end{center}
\end{document}
答案1
我刚刚添加
\draw [very thick,->] (13) to [out=-90,in=0] (32);
\draw [very thick,->] (13) to [out=-90,in=45] (decide.east);
\draw [very thick,->] (13) to [out=-90,in=60] (stop.east);
\draw [very thick,->] (13) edge[loop right] (13);
到您的代码
\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{calc,trees,positioning,arrows,chains,shapes.geometric,
decorations.pathreplacing,decorations.pathmorphing,shapes,
matrix,shapes.symbols}
\usepackage{array}
\usepackage{amsmath}
\usepackage{amsxtra}
\usepackage{amsfonts}
\usepackage{amssymb}
\begin{document}
\begin{center}
\tikzstyle{decision} = [diamond, draw, fill=blue!20,text width=6.5em, text badly centered, node distance=5cm, inner sep=0pt]
\tikzstyle{block} = [rectangle,fill=blue!20, text width=8em, text centered, rounded corners, minimum height=4em]
\tikzstyle{line} = [draw, -latex']
\tikzstyle{arco} = [draw,->]
\tikzstyle{cloud} = [draw, circle,fill=red!20, node distance=4cm,minimum height=4em]
\tikzstyle{pil} = [->,thick,shorten <=2pt, shorten >=2pt]
\begin{tikzpicture}[node distance = 2cm, auto]
% Place nodes
\node [block] (12) {1nialize model};
\node [block, left of=12, node distance=6cm] (11) {\\ Probability spaces \\ $(\mathbb{R},\mathcal{B}(\mathbb{R}),\mathbb{P})$\\ };
\node [cloud, right of=12] (13) {coments};
\node [block, below of=12] (22) {verify candidate models};
\node [block, below of=22] (32) {rum candidate models};
\node [block, left of=32, node distance=6cm] (31) {update model};
\node [decision, below of=32] (decide) {is best candidate better?};
\node [block, below of=decide, node distance=6cm] (stop) {stop};
% Draw edges
\path [line] (12) -- (22);
\path [line] (13) -- (22);
\path [line] (22) -- (32);
\path [line] (32) -- (decide);
\path [line] (decide) -| node [near start] {yes} (31);
\path [line] (31) |- (22);
\path [line] (decide) -- node {no}(stop);
\path [line] (11) -- (12);
\path [arco] (13) -- (12);
\path [arco] (13) |- (32);
%\draw [red] (13) .. controls (13 |- 32) .. (32);
\draw [very thick,->] (13) to [out=-90,in=0] (32);
\draw [very thick,->] (13) to [out=-90,in=45] (decide.east);
\draw [very thick,->] (13) to [out=-90,in=60] (stop.east);
\draw [very thick,->] (13) edge[loop right] (13);
\path [arco] (13) -- (stop);
\end{tikzpicture}
\end{center}
\end{document}