0

enter image description here

I want to draw line from diamond box to start and without individual line from start to four rectangle i want to draw a single branching line from start to sensor data A, sensor data B, sensor data C and sensor data D.

Here is my code:

\tikzset{
decision/.style = {diamond, draw, 
  text width=4.5em, text badly centered, node distance=3cm, inner sep=0pt},
block/.style = {rectangle, draw,  
  text width=5em, text centered, rounded corners, minimum height=4em},
  block2/.style = {rectangle, draw,  
  text width=9em, text centered, rounded corners, minimum height=4em},
line/.style = {draw, -latex'},
cloud/.style = {draw, ellipse, node distance=3cm,
  minimum height=2em},
subroutine/.style = {draw,rectangle split, rectangle split horizontal,
  rectangle split parts=3,minimum height=1cm,
  rectangle split part fill={red!50, green!50, blue!20, yellow!50}},
connector/.style = {draw,circle,node distance=3cm},
data/.style = {draw, trapezium,node distance=3cm}
}
\begin{tikzpicture}[node distance = 2cm, auto]

\node [connector] (start) {Start};
\node [block, below of=start] (B) {sensor data B};
\node [block, left of=B] (A) {sensor data A};
    \node [block, right of=B] (C) {sensor data C};
  \node [block, right of=C] (D) {sensor data D};
  \node [connector,below of=B] (sum) {Sum};
  \node [block2, below of=sum] (read) {Read the sum of sensor data};
  \node [block2, below of=read] (con) {Convert sensor data in percentage};
  \node [decision, below of=con] (decide) {Data $\geq$ 25\%?};

\path [line] (start) -- (A);
\path [line] (start) -- (B);
\path [line] (start) -- (C);
\path [line] (start) -- (D);
\path [line] (A) -- (sum);
\path [line] (B) -- (sum);
\path [line] (C) -- (sum);
\path [line] (D) -- (sum);
\path [line] (sum) -- (read);
 \path [line] (read) -- (con);
 \path [line] (con) -- (decide);

\end{tikzpicture}
1

For more detail, you may want to look through chapter five, Tutorial: Diagrams as Simple Graphs in the pgf manual; It explains in much more words what to do to achieve the effects you want. You can solve the problems that you have by using edge lines, -| and going around your block D with the calc package. I have changed your code,

\usetikzlibrary{shapes.geometric}
\usetikzlibrary{arrows}
\usetikzlibrary{calc}
\tikzset{
decision/.style = {diamond, draw, 
  text width=4.5em, text badly centered, node distance=3cm, inner sep=0pt},
block/.style = {rectangle, draw,  
  text width=5em, text centered, rounded corners, minimum height=4em},
  block2/.style = {rectangle, draw,  
  text width=9em, text centered, rounded corners, minimum height=4em},
line/.style = {draw, -latex'},
cloud/.style = {draw, ellipse, node distance=3cm,
  minimum height=2em},
subroutine/.style = {draw,rectangle split, rectangle split horizontal,
  rectangle split parts=3,minimum height=1cm,
  rectangle split part fill={red!50, green!50, blue!20, yellow!50}},
connector/.style = {draw,circle,node distance=3cm},
data/.style = {draw, trapezium,node distance=3cm}
}
\begin{tikzpicture}[node distance = 2cm, auto]

\node [connector] (start) {Start};
\node [block, below of=start] (B) {sensor data B};
\node [block, left of=B] (A) {sensor data A};
\node [block, right of=B] (C) {sensor data C};
\node [block, right of=C] (D) {sensor data D};
\node [connector,below of=B] (sum) {Sum};
\node [block2, below of=sum] (read) {Read the sum of sensor data};
\node [block2, below of=read] (con) {Convert sensor data in percentage};
\node [decision, below of=con] (decide) {Data $\geq$ 25\%?};

\path [line] (start.south) -| (A);
\path [line] (start.south) -| (B);
\path [line] (start.south) -| (C);
\path [line] (start.south) -| (D);
\path [line] (A) -- (sum);
\path [line] (B) -- (sum);
\path [line] (C) -- (sum);
\path [line] (D) -- (sum);
\path [line] (sum) -- (read);
\path [line] (read) -- (con);
\path [line] (con) -- (decide);
\path[line] (decide) -| ($(D.east) + (1cm,0)$) |- (start);

\end{tikzpicture}

I hope this helps you on your quest. The path back to the beginning goes via D to avoid changing it again if you re-arrange your drawing. If you add more blocks, you may have to change D.east to reflect that.

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.