0

I want to draw the following diagram. How can I draw this diagram?

enter image description here

I did not find any examples to recreate the above image.

1
  • 1
    Hello. This is a rather complex (not difficult) drawing that you ask for here. I would start by creating a \newcommand which draws at a precise point a "block", placing a node at the center. Afterwards, connecting the nodes is pretty straightforward. Please provide a MWE of what you tried already.
    – SebGlav
    Commented Feb 17, 2021 at 15:11

2 Answers 2

2

Something to start

\documentclass[tikz,border=2mm]{standalone}

\usetikzlibrary{matrix,positioning}

\tikzset{
    blockline/.style={matrix of nodes, nodes in empty cells,
        row sep=0pt, column sep=-\pgflinewidth,
        nodes={anchor=center, minimum width=15mm, minimum height=8mm},},
}

\begin{document}

\begin{tikzpicture}

\matrix[blockline] (block1a) {
&|[draw]| &|[draw, label=block1a]| 500 &|[draw]| &\\ 0 & 1 & 2 & 3 & 4\\};
\draw ([yshift=-.5\pgflinewidth]block1a-1-1.north west)--([yshift=-.5\pgflinewidth]block1a-1-5.north east) ([yshift=.5\pgflinewidth]block1a-1-1.south west)--([yshift=.5\pgflinewidth]block1a-1-5.south east);

\matrix[blockline, below right=0mm and 10mm of block1a.south] (block2a) {
&|[draw]| &|[draw, label=block2a]| 502 &|[draw]| &\\ 23 & 24 & 25 & 26 & 27\\};
\draw ([yshift=-.5\pgflinewidth]block2a-1-1.north west)--([yshift=-.5\pgflinewidth]block2a-1-5.north east) ([yshift=.5\pgflinewidth]block2a-1-1.south west)--([yshift=.5\pgflinewidth]block2a-1-5.south east);

\draw[->] ([xshift=5mm]block1a-1-3.south) coordinate(aux)-- node[pos=.35,right]{right} (aux|-block2a.south)-|([xshift=-5mm]block2a-1-3.south);
\end{tikzpicture}

\end{document}

enter image description here

2

Here's for a starting point:

\documentclass[tikz,border=3.14159pt]{standalone}

\usetikzlibrary{matrix,positioning,arrows,arrows.meta,calc}

\tikzset{
    mymat/.style={
          matrix of nodes,
          anchor=center,
          row 2/.style={nodes=draw,nodes in empty cells},
          text height=2.8ex,
          text depth=0.75ex,
          text width=7ex,
          align=center,
          column sep=-\pgflinewidth
          },
    myarrow/.style={-{Stealth[scale=1.5]},rounded corners=2pt}
    }

\begin{document}
    \begin{tikzpicture}
        \matrix[mymat]
        at (0,0) 
        (mat1)
        {
         & & \small{block1a} & & \\
          &   & \large{500} &   &   \\
        0 & 1 & 2 & 3 & 4 \\
        };
        
        \matrix[mymat]
        at (-4,-3) 
        (mat2)
        {
         & & \small{block3a} & & \\
          &   & \large{501} &   &   \\
        11 & 12 & 13 & 14 & 15 \\
        };
        
        \draw[myarrow]
            ($(mat1-2-3.south)+(-.4,0)$) --++ (0,-4) node[left,pos=0.3]{left} -| ($(mat2-2-3.south)+(.4,0)$);
    \end{tikzpicture}
\end{document}

data structure

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .