我希望箭头看起来像附图一样,但我不确定该怎么做,因为我是一个新手,而且我很挣扎。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{setspace}
\setstretch{1.5}
\usepackage{lipsum}
\tikzstyle{startstop} = [rectangle, rounded corners, minimum width=6.5cm, minimum height=1cm,text centered, text width= 6.5cm, draw=black]
% Process
\tikzstyle{process} = [rectangle, rounded corners, minimum width=6.5cm, minimum height=1cm, text width= 6.5cm, text centered, draw=black]
\tikzstyle{decision} = [diamond, minimum width= 3cm, minimum height=1cm, text width= 3cm, text centered, draw=black]
\tikzstyle{arrow} = [thick,->,>=stealth]
\begin{document}
\begin{figure}[ht]
\begin{tikzpicture}[node distance=1cm]
\node (start) [startstop] {Initialize empty master problem};
\node (pro1) [process, below of=start, yshift=-0.1cm] {Generate initial columns from direct services, $\forall$ $o$ $\in$ $O$};
\node (pro2) [process, below of=pro1, yshift=-0.1cm] {Solve MP and calculate duals of constraints};
\node (pro3) [node distance=2cm] [process, below of=pro2, yshift=-0.1cm] {Update graph weights};
\node (pro4) [process, below of=pro3, yshift=-0.2cm] {Generate k-shortest paths and their columns};
\node (dec1) [decision, below of=pro4, yshift=-1.8cm] {Check if reduced costs $>$ 0};
\node (pro5) [process, below of=dec1, yshift=-1.8cm ] {\textbf{Stop}: Solution is optimal};
\draw [arrow] (start) -- (pro1);
\draw [arrow] (pro1) -- (pro2);
\draw [arrow] (pro2) -- (pro3);
\draw [arrow] (pro3) -- (pro4);
\draw [arrow] (pro4) -- (dec1);
\draw [arrow] (dec1) -- node[anchor=east] {yes} (pro5);
\draw [arrow] (dec1.east) -| node[anchor=north] {no} (pro2.north east);
\end{tikzpicture}
\end{figure}
\end{document}
答案1
类似这样的事情应该可以工作:
\draw [arrow] (dec1.east) to node[anchor=north] {no} ++(0:2) |- (pro2.east);
表示0
角度(0:2)
, 表示2
该角度内的距离(以厘米为单位)。2
根据需要调整 。