流程图:帮助我改进

流程图:帮助我改进

我想编辑我的流程图,因为它有错误。我想更改此行

% added sloped, above to the node options to rotate it
\path [line] (labeled.east) -- ++(7mm,0mm) |- node [pos=0.3,sloped,above] {FALSE} (step2); "

这样指向的箭头/节点(step2)就会指向(geq)决策之前的箭头/节点。就这样。谢谢!

\documentclass[12pt,letterpaper]{article}
\usepackage[margin=1in]{geometry}
\usepackage[latin1]{inputenc}
\usepackage{tikz,amsmath,amssymb,amsthm}
\usetikzlibrary{shapes,arrows.meta,positioning}


\definecolor{clr1}{RGB}{179,235,205}
\definecolor{clr2}{RGB}{254,217,166}
\definecolor{clr3}{RGB}{222,203,228}
\definecolor{clr4}{RGB}{251,180,174}
\definecolor{clr5}{RGB}{204,235,197}
\definecolor{clr6}{RGB}{255,255,179}
\definecolor{clr7}{RGB}{229,216,189}

% Define block 
\tikzset{
decision/.style={diamond, draw, fill=clr1, 
text width=5em, text badly centered, inner sep=1pt},
block1/.style={rectangle, draw, fill=clr2, 
text width=5em, text centered, rounded corners, minimum height=5em},
block2/.style={rectangle, draw, fill=clr3, 
text width=10em, text centered, minimum height=6em},
block3/.style={rectangle, draw, fill=clr4, 
text width=13em, text centered, minimum height=5em},
line/.style={draw, thick, -Latex},
cloud1/.style={draw, ellipse,fill=clr5, 
minimum height=5em},
cloud2/.style={draw, ellipse,fill=clr6, 
minimum height=5em, text width=7em},
block4/.style={rectangle, draw, fill=clr7,   
 text width=12em, text centered, minimum height=8em}
}

\begin{document}
\pagestyle{empty}
\begin{tikzpicture}[node distance = 7mm, auto]
% Place nodes
\node [cloud1]                         (input)    {INPUT};
\node [cloud2, below =of input]         (mn)       {$L(m,1),W(3,n)$ where 
$m,n \in \mathbb{N}$};
\node [block1, above left=1cm and 2cm of mn]         (step1)    {STEP 1:};
\node [block2, left=2.3cm of step1]    (vertex)   {$V(W(3,n)) = \{v\} \cup \
{v_{(i,j)} |
                                                   i \in \{1,2,3,\ldots,n\}     , j \in \{1,2,3\} \}$};
\node [block2, below=of vertex]        (edge)     {$E(W(3,n))= \{ vv_{(i,j)} | i \in \{1,2,\ldots,n\} ,
                                                   j \in \{1,2,3\}\} \cup \  {v_{(i,j)}v_{(i,j+1)} | 
                                                   i \in \{1,2,\ldots,n\} , 
                                                   j \in \{1,2,\}\} \cup \{ v_{(i,1)}v_{(i,3)} |
                                                   i \in \{1,2,\ldots,n\}\}$};
  \node [block1, at={(edge-|step1)}]     (step2)    {STEP 2:};
  \node [block3, below=1.3cm of step2]   (v)        {Let $\ell : V(W(3,n))   \longrightarrow \{0,1,2,\ldots\}$ where $\ell(v_0)=0$};
  \node [decision,
       below left=1.5cm and 2.5cm of v]  (geq)      {$m\geq n$};
  \node [block3, at={(geq-| v)}]         (1)        {$\ell(V_{(i,j)})=jm+(i-1), i \in \{1,2,\ldots n\}, j \in \{1,2,3\}$};
  \node [decision, below=of geq]         (lessthan) {$m<n$};
  \node [block3, at={(lessthan -| 1)}]   (2)        {$\ell(v_{i,j})=jm+(j-1)(n-m)+(i-1), i \in \{1,2,3,\ldots,n\}$ and $j \in \{1,2,3\}$};
  \node [cloud2,
       right=-5mm of 2, yshift=-3.5cm] (labeled)  {Each vertex has label.};
  \node [cloud1, left=2cm of labeled]    (output)   {OUTPUT};
  \node [block4, left=of output]         (optimal)  {Optimal $L(m,1)$-labeling for triangular windmill graph $(W(3,n))$.};


% Draw edges
\path [line] (input) --  (mn);
\path [line] (mn) -| (step1);
\path [line] (edge) -- (step2);
\path [line] (step1) -- (vertex);
\path [line] (vertex) -- (edge);
\path [line] (step2) -- (step2 |- v.north);
% added [pos=0.25] for the node
% in a -| path, midway/pos=0.5 is at the corner, so 0.25 is halfway to the corner
\path [line] (v) -| node [pos=0.25] {and} (geq);
\path [line] (geq) -- node {TRUE} (1);
\path [line] (geq) -- node  {FALSE} (lessthan);
\path [line] (lessthan) -- node {TRUE}(2);
\path [line] (1) -| node [near start] {TRUE} (labeled);
\path [line] (2) -| node [near start] {TRUE} (labeled);
\path [line] (labeled) -- node {TRUE} (output);
\path [line] (output) -- (optimal);
% added sloped, above to the node options to rotate it
\path [line] (labeled.east) -- ++(7mm,0mm) |- node [pos=0.3,sloped,above] {FALSE} (step2);

% place node relative to the current bounding box
\node [above=3ex, font=\bfseries\Large] at (current bounding box.north)   {FLOWCHART};
\end{tikzpicture}
\end{document}

答案1

为了修复代码,{我用 替换了两个。更准确地说,我修复了43 行末尾的 和48 行的 。我还实施了 Torbjørn T. 的评论。\{\\ {

\documentclass[12pt,letterpaper]{article}
\usepackage[margin=1in]{geometry}
\usepackage[latin1]{inputenc}
\usepackage{tikz,amsmath,amssymb,amsthm}
\usetikzlibrary{shapes,arrows.meta,positioning}


\definecolor{clr1}{RGB}{179,235,205}
\definecolor{clr2}{RGB}{254,217,166}
\definecolor{clr3}{RGB}{222,203,228}
\definecolor{clr4}{RGB}{251,180,174}
\definecolor{clr5}{RGB}{204,235,197}
\definecolor{clr6}{RGB}{255,255,179}
\definecolor{clr7}{RGB}{229,216,189}

% Define block 
\tikzset{
decision/.style={diamond, draw, fill=clr1, 
text width=5em, text badly centered, inner sep=1pt},
block1/.style={rectangle, draw, fill=clr2, 
text width=5em, text centered, rounded corners, minimum height=5em},
block2/.style={rectangle, draw, fill=clr3, 
text width=10em, text centered, minimum height=6em},
block3/.style={rectangle, draw, fill=clr4, 
text width=13em, text centered, minimum height=5em},
line/.style={draw, thick, -Latex},
cloud1/.style={draw, ellipse,fill=clr5, 
minimum height=5em},
cloud2/.style={draw, ellipse,fill=clr6, 
minimum height=5em, text width=7em},
block4/.style={rectangle, draw, fill=clr7,   
 text width=12em, text centered, minimum height=8em}
}

\begin{document}
\pagestyle{empty}
\begin{tikzpicture}[node distance = 7mm, auto]
% Place nodes
\node [cloud1]                         (input)    {INPUT};
\node [cloud2, below =of input]         (mn)       {$L(m,1),W(3,n)$ where 
$m,n \in \mathbb{N}$};
\node [block1, above left=1cm and 2cm of mn]         (step1)    {STEP 1:};
\node [block2, left=2.3cm of step1]    (vertex)   {$V(W(3,n)) = \{v\} \cup 
\{v_{(i,j)} |
i \in \{1,2,3,\ldots,n\}     , j \in \{1,2,3\} \}$};
\node [block2, below=of vertex]        (edge)     {$E(W(3,n))= \{ vv_{(i,j)} | i
                                                   \in \{1,2,\ldots,n\} , j \in
                                                   \{1,2,3\}\} \cup  
                                                   \{v_{(i,j)}v_{(i,j+1)} |  i
                                                   \in \{1,2,\ldots,n\} ,  j \in
                                                   \{1,2,\}\} \cup \{
                                                   v_{(i,1)}v_{(i,3)} | i \in
                                                   \{1,2,\ldots,n\}\}$};
  \node [block1, at={(edge-|step1)}]     (step2)    {STEP 2:};
  \node [block3, below=1.3cm of step2]   (v)        {Let $\ell : V(W(3,n))   \longrightarrow \{0,1,2,\ldots\}$ where $\ell(v_0)=0$};
  \node [decision,
       below left=1.5cm and 2.5cm of v]  (geq)      {$m\geq n$};
  \node [block3, at={(geq-| v)}]         (1)        {$\ell(V_{(i,j)})=jm+(i-1), i \in \{1,2,\ldots n\}, j \in \{1,2,3\}$};
  \node [decision, below=of geq]         (lessthan) {$m<n$};
  \node [block3, at={(lessthan -| 1)}]   (2)        {$\ell(v_{i,j})=jm+(j-1)(n-m)+(i-1), i \in \{1,2,3,\ldots,n\}$ and $j \in \{1,2,3\}$};
  \node [cloud2,
       right=-5mm of 2, yshift=-3.5cm] (labeled)  {Each vertex has label.};
  \node [cloud1, left=2cm of labeled]    (output)   {OUTPUT};
  \node [block4, left=of output]         (optimal)  {Optimal $L(m,1)$-labeling for triangular windmill graph $(W(3,n))$.};


% Draw edges
\path [line] (input) --  (mn);
\path [line] (mn) -| (step1);
\path [line] (edge) -- (step2);
\path [line] (step1) -- (vertex);
\path [line] (vertex) -- (edge);
\path [line] (step2) -- (step2 |- v.north);
% added [pos=0.25] for the node
% in a -| path, midway/pos=0.5 is at the corner, so 0.25 is halfway to the corner
\path [line] (v) -| node [pos=0.25] {and} (geq);
\path [line] (geq) -- node {TRUE} (1);
\path [line] (geq) -- node  {FALSE} (lessthan);
\path [line] (lessthan) -- node {TRUE}(2);
\path [line] (1) -| node [near start] {TRUE} (labeled);
\path [line] (2) -| node [near start] {TRUE} (labeled);
\path [line] (labeled) -- node {TRUE} (output);
\path [line] (output) -- (optimal);
% added sloped, above to the node options to rotate it
%\path [line] (labeled.east) -- ++(7mm,0mm) |- node [pos=0.3,sloped,above] {FALSE} (step2);
\path [line] (labeled.east) -- ++(7mm,0mm) |- node [pos=0.3,sloped,above] {FALSE} (v);

% place node relative to the current bounding box
\node [above=3ex, font=\bfseries\Large] at (current bounding box.north)   {FLOWCHART};
\end{tikzpicture}
\end{document}

相关内容