\tikzset{
mymat/.style={
matrix of math nodes,
text height=2.5ex,
text depth=0.75ex,
text width=3.25ex,
align=center,
column sep=-\pgflinewidth
},
mymats/.style={
mymat,
nodes={draw,fill=#1}
}
}
\begin{tikzpicture}[>=latex]
\matrix[mymat,anchor=west,row 2/.style={nodes=draw}]
at (0,0)
(mat1)
{
& \\
N1 \\
};
\matrix[mymat,right=of mat1,row 2/.style={nodes={draw,fill=gray!30}}]
(mat2)
{
& \\
t_2 & t_4 \\
};
\matrix[mymat,anchor=west,row 2/.style={nodes=draw}]
at (0,-1)
(mat3)
{
& \\
N2 \\
};
\matrix[mymat,right=of mat3,row 2/.style={nodes={draw,fill=gray!30}}]
(mat4)
{
& & \\
t_1 & t_3 & t_4 \\
};
\matrix[mymat,anchor=west,row 2/.style={nodes=draw}]
at (0,-2)
(mat5)
{
& \\
N3 \\
};
\matrix[mymat,right=of mat5,row 2/.style={nodes={draw,fill=gray!30}}]
(mat6)
{
& &\\
t_1 & t_2 & t_3 \\
};
\matrix[mymat,anchor=west,row 2/.style={nodes=draw}]
at (0,-3)
(mat7)
{
& \\
N4 \\
};
\matrix[mymat,right=of mat7,row 2/.style={nodes={draw,fill=gray!30}}]
(mat8)
{
& \\
t_3 & t_4 \\
};
\matrix[mymat,anchor=west,row 2/.style={nodes=draw}]
at (0,-4)
(mat9)
{
& \\
N5 \\
};
\matrix[mymat,right=of mat9,row 2/.style={nodes={draw,fill=gray!30}}]
(mat10)
{
& \\
t_1 & t_3 \\
};
\matrix[mymat,anchor=west,row 2/.style={nodes=draw}]
at (2,-5)
(mat11)
{
& & & &\\
t_1 & t_2 & t_3 & t_4 & t_5\\
};
\begin{scope}[shorten <= -2pt]
\draw[*->]
(mat1-2-1.east) -- (mat2-2-1.west);
\draw[*->]
(mat3-2-1.east) -- (mat4-2-1.west);
\draw[*->]
(mat5-2-1.east) -- (mat6-2-1.west);
\draw[*->]
(mat7-2-1.east) -- (mat8-2-1.west);
\draw[*->]
(mat9-2-1.east) -- (mat10-2-1.west);
\end{scope}
\end{tikzpicture}
部分代码取自这里
答案1
\documentclass[margin=3.14mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix,fit,positioning,arrows.meta,arrows}
\begin{document}
\tikzset{
mymat/.style={
matrix of math nodes,
text height=2.5ex,
text depth=0.75ex,
text width=3.25ex,
align=center,
column sep=-\pgflinewidth
},
mymats/.style={
mymat,
nodes={draw,fill=#1}
}
}
\begin{tikzpicture}[>=latex]
\matrix[mymat,anchor=west,row 2/.style={nodes=draw}]
at (0,0)
(mat1)
{
& \\
N1 \\
};
\matrix[mymat,right=of mat1,row 2/.style={nodes={draw,fill=gray!30}}]
(mat2)
{
& \\
t_2 & t_4 \\
};
\matrix[mymat,anchor=west,row 2/.style={nodes=draw}]
at (0,-1)
(mat3)
{
& \\
N2 \\
};
\matrix[mymat,right=of mat3,row 2/.style={nodes={draw,fill=gray!30}}]
(mat4)
{
& & \\
t_1 & t_3 & t_4 \\
};
\matrix[mymat,anchor=west,row 2/.style={nodes=draw}]
at (0,-2)
(mat5)
{
& \\
N3 \\
};
\matrix[mymat,right=of mat5,row 2/.style={nodes={draw,fill=gray!30}}]
(mat6)
{
& &\\
t_1 & t_2 & t_3 \\
};
\matrix[mymat,anchor=west,row 2/.style={nodes=draw}]
at (0,-3)
(mat7)
{
& \\
N4 \\
};
\matrix[mymat,right=of mat7,row 2/.style={nodes={draw,fill=gray!30}}]
(mat8)
{
& \\
t_3 & t_4 \\
};
\matrix[mymat,anchor=west,row 2/.style={nodes=draw}]
at (0,-4)
(mat9)
{
& \\
N5 \\
};
\matrix[mymat,right=of mat9,row 2/.style={nodes={draw,fill=gray!30}}]
(mat10)
{
& \\
t_1 & t_3 \\
};
\matrix[mymat,anchor=west,row 2/.style={nodes=draw}]
at (2,-5.5)
(mat11)
{
& & & &\\
t_1 & t_2 & t_3 & t_4 & t_5\\
};
\node[draw,dashed,red,fit=(mat10-2-1) (mat2-2-1) (mat4-2-3),inner sep=2mm] (f1){};
\draw[red,->] (f1) to[out=-90,in=90] (mat11-2-3.north);
\begin{scope}[shorten <= -2pt]
\draw[*->]
(mat1-2-1.east) -- (mat2-2-1.west);
\draw[*->]
(mat3-2-1.east) -- (mat4-2-1.west);
\draw[*->]
(mat5-2-1.east) -- (mat6-2-1.west);
\draw[*->]
(mat7-2-1.east) -- (mat8-2-1.west);
\draw[*->]
(mat9-2-1.east) -- (mat10-2-1.west);
\end{scope}
\end{tikzpicture}
\end{document}