答案1
通过使用 TikZ 库matrix
作为节点和arrows.meta
箭头:
\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta,
matrix,
positioning}
\tikzset{
}
\begin{document}
\begin{tikzpicture}[
every edge/.style = {draw=gray, semithick, -Straight Barb},
hashtable/.style = {matrix of nodes,
nodes in empty cells,
nodes = {draw, minimum size=8mm, anchor=center,
inner sep=0pt, outer sep=0pt},
column sep=-\pgflinewidth,
row sep=-\pgflinewidth},
]
\matrix (m1) [hashtable]
{
\\ \\ \\
};
%
\matrix (m2) [hashtable, right=of m1]
{
& & \\
& & \\
& & \\
};
%
\draw (m1-1-1) edge (m2-1-1)
(m1-2-1) edge (m2-2-1)
(m1-3-1) edge (m2-3-1);
\end{tikzpicture}
\end{document}
答案2
可以使用 TikZ 轻松绘制(参见第一个代码)。第二个代码仅用于与 Asymptote 进行比较。
\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usepackage{asymptote}
\begin{document}
\begin{tikzpicture}
\draw
(0,0) grid (1,3)
(1,.5) coordinate (A1)
(1,1.5) coordinate (A2)
(1,2.5) coordinate (A3);
\draw[shift={(2.5,0)}]
(0,0) grid (3,3)
(0,.5) coordinate (B1)
(0,1.5) coordinate (B2)
(0,2.5) coordinate (B3);
\foreach \i in {1,2,3}
\draw[->,shorten >=1mm,shorten <=1mm] (A\i)--(B\i);
\end{tikzpicture}
\hspace{1cm}
\begin{asy}
unitsize(1cm);
import geometry;
pair[] A={(1,.5),(1,1.5),(1,2.5)};
add(grid(1,3,red));
transform t=shift(2.5,0);
pair[] B={(0,.5),(0,1.5),(0,2.5)};
add(t*grid(3,3,blue));
for(int i=0; i<A.length;++i){
pair p=relpoint(A[i]--t*B[i],.1);
pair q=relpoint(A[i]--t*B[i],.9);
draw(p--q,Arrow(TeXHead));
}
\end{asy}
\end{document}