0

I want to edit my flowchart because it has an error. I want to change this line

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

so that the arrow/node that goes to (step2) will go to the arrow/node before (geq) decision. That's all. Thank you!

\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
  • If I understand you correctly, you want \path [line] (labeled.east) -- ++(7mm,0mm) |- node [pos=0.3,sloped,above] {FALSE} (v);, i.e. change (step2) to (v). (After fixing the mistakes mentioned in marmot's answer, of course.) – Torbjørn T. Feb 28 '18 at 10:13
1

There were two { which I replaced by \{ in order to fix the code. More precisely, there was \ at the end of 43 and a \ { in line 48 which I fixed. I also implemented Torbjørn T.'s comment.

\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}
1
  • I think the OP also wants \path [line] (labeled.east) -- ++(7mm,0mm) |- node [pos=0.3,sloped,above] {FALSE} (v);, cf. the description in the question, and my comment. – Torbjørn T. Feb 28 '18 at 10:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.