3

I'm trying to recreate this image in tikz: enter image description here

I've managed to draw the basic structure. I dont know exactly what and how to search for this problem, but can't manage to handle those 2 'columns' of text i.e. the 'Capture File' and 'CSV file' part. Also, is there a better way of handling those text boxes (the 'Frame length IP length ...' and 'Packets per second') on the extreme right and left as compared to the method i used?

    \documentclass{article}    
    \usepackage{lipsum}
    \usepackage{tikz}
    \usetikzlibrary{positioning}
    \usetikzlibrary{arrows}
\begin{document}

\begin{figure}
    \centering
    \begin{tikzpicture}
    \tikzstyle{arrow} = [thick,->,>=stealth]

    \node (block1a) [rectangle] {Capture File};
    \node (block1b) [rectangle, right= of block1a] {CSV File};

    \node (block2a) [rectangle, below=0.7cm of block1a, align=center, minimum width=3cm] {Feature Extraction  \\ Algorithm};

    \node (sidetext1) [rectangle, align= left, left= of block2a] {Frame length \\ IP length \\ TCP length \\ UDP length \\ Inter-packet delay};

    \draw[arrow] (block2a) -- (sidetext1);

    \node (block2b) [rectangle, below=0.7cm of block1b, align=center] {PPS Algorithm};

    \node(sidetext2)[rectangle, align= left, right= of block2b] {Packets per Second};

    \draw[arrow] (block2b)--(sidetext2);

    \node (block3a) [rectangle,below=0.7cm of block2a, align=center] {mean \& \\ standard deviation};

    \node (block3b) [rectangle,below=0.7cm of block2b,align=center] {mean \& \\ standard deviation};

    \node (final) [rectangle, minimum width=8cm, minimum height=0.8cm, text centered, draw=black, below=1 cm of block3a] {Feature Set};

    \draw[arrow] (block1a.south) -- (block2a.north);      
    \draw[arrow] (block2a.south)--(block3a.north);
    \draw[arrow] (block3a.south)--(final.north);
    \draw[arrow] (block1b.south)--(block2b.north);
    \draw[arrow] (block2b.south) --(block3b.north);
    \draw[arrow] (block3b.south) -- (final);

    \end{tikzpicture}
\end{figure} 

\end{document}

afaq
  • 347

1 Answers1

6

Adaptations

  • use \tikzset instead of \tikzstyle (see Should \tikzset or \tikzstyle be used to define TikZ styles?)
  • remove superfluous rectangle option (as it is default)
  • rearranged code
  • place node block3b at (block2b|-block3a), so that it is horizontally and vertically aligned
  • add \usetikzlibrary{calc} to place node final in the middle of the two columns with ([yshift=-10mm] $(block3a.south)!.5!(block3b.south)$)
  • draw vertical arrows to final using (block3a.south|-final.north)
  • removed spaces before and after \\
  • reduced font size of sidenodes and made a style sidenode for them
  • changed the line style to the sidenodes to dashed to differentiate from the other arrows

Result

enter image description here

Code

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{arrows}
\usetikzlibrary{calc}

\begin{document}

\begin{figure} \centering \begin{tikzpicture}[ arrow/.style = {thick,->,>=stealth}, sidenode/.style = {font=\footnotesize, align=left}, ]

    \node (block1a) [] {Capture File};
    \node (block2a) [below=7mm of block1a, align=center, minimum width=3cm] {Feature Extraction\\Algorithm};
    \node (block3a) [below=7mm of block2a, align=center] {mean \&\\standard deviation};

    \node (block1b) [right=20mm of block1a] {CSV File};
    \node (block2b) [below=of block1b, align=center] {PPS Algorithm};
    \node (block3b) [align=center] at (block2b|-block3a) {mean \&\\standard deviation};

    \node (sidetext1) [sidenode, left=of block2a] {Frame length\\IP length\\TCP length\\UDP length\\Inter-packet delay};
    \node (sidetext2) [sidenode, right=of block2b] {Packets per Second};

    \node (final) [minimum width=8cm, minimum height=0.8cm, text centered, draw=black] at ([yshift=-10mm] $(block3a.south)!.5!(block3b.south)$) {Feature Set};

    \draw[dashed] (block2a) -- (sidetext1);
    \draw[dashed] (block2b) -- (sidetext2);

    \draw[arrow] (block1a.south) -- (block2a.north);      
    \draw[arrow] (block2a.south) -- (block3a.north);
    \draw[arrow] (block3a.south) -- (block3a.south|-final.north);
    \draw[arrow] (block1b.south) -- (block2b.north);
    \draw[arrow] (block2b.south) -- (block3b.north);
    \draw[arrow] (block3b.south) -- (block3b.south|-final.north);
\end{tikzpicture}

\end{figure}

\end{document}

dexteritas
  • 9,161