0

I want to draw an 2-D Array with linked lists in tikz. It should look like that: TODO

I have tried a few things with \matrix but it didn't work out. I'm using \documentclass{scrartcl}.

Does anybody have an idea? Thank you so much!

1 Answer 1

2

enter image description here

\documentclass[border=4pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix,positioning,arrows}

% tex.stackexchange.com/questions/22687/multirow-in-tikz-matrix
\tikzset{
    table nodes/.style={
        draw,
        align=center,
        minimum height=7mm,
        minimum width =7mm,
        text depth=0.5ex,
        text height=2ex
    },      
    table/.style={
        matrix of nodes,
        row sep=-\pgflinewidth,
        column sep=-\pgflinewidth,
        nodes={
            table nodes
          },
        nodes in empty cells
     }
}

\begin{document}
\begin{tikzpicture}
  \matrix[table] (A)
  { |[draw=none]|
        &a&b&c&d&e&f&g&h&i\\
    maxC&5&4&5&5&5&4&2&5&4\\
    maxC& & & & & & & & & \\
  };
  \matrix[table,below=of A-3-2] (B) {c\\g\\};
  \matrix[table,below=of A-3-6] (C) {b\\e\\f\\i\\};
  \matrix[table,below=of A-3-8] (D) {a\\c\\d\\e\\};
  \foreach \s/\t in {8/B,3/C,7/C,10/C,2/D,4/D,5/D,6/D,9/D}
    \draw[-stealth',shorten >=3pt,shorten <=3pt] (A-3-\s.south) -- (\t-1-1.north);
\end{tikzpicture}
\end{document}
1
  • Thank you so much, it works perfectly :-)
    – bearniva
    Commented Feb 9, 2021 at 12:53

You must log in to answer this question.

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