答案1
可以tikz-cd
使用一个相当简单的语法。
\documentclass{article}
\usepackage{tikz-cd}
\begin{document}
\[
\begin{tikzcd}[arrows=dash,every label=\textstyle]
3214 \arrow[r,"3"] \arrow[d,"3"] &
4213 \arrow[r,"2"] \arrow[d,"3"] &
4312 \arrow[d,"2"] \\
3241 \arrow[r,"3"] \arrow[d,"2"] &
4231 \arrow[r,"1"] \arrow[d,"1"] &
4132 \arrow[d,"1"] \\
3421 \arrow[r,"2"] &
2431 \arrow[r,"1"] &
1432
\end{tikzcd}
\]
\end{document}
答案2
这是一种可能性。其他可能性包括处理边缘等,但使用复制和粘贴速度更快。
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
\matrix (perms) [matrix of nodes,row sep=1cm,column sep=1cm]
{
3214 & 4213 & 4312 \\
3241 & 4231 & 4132 \\
3421 & 2431 & 1432 \\
};
\draw (perms-1-1) -- (perms-1-2) node[midway,above]{3};
\draw (perms-1-2) -- (perms-1-3) node[midway,above]{2};
\draw (perms-2-1) -- (perms-2-2) node[midway,above]{3};
\draw (perms-2-2) -- (perms-2-3) node[midway,above]{1};
\draw (perms-3-1) -- (perms-3-2) node[midway,above]{2};
\draw (perms-3-2) -- (perms-3-3) node[midway,above]{1};
%
\draw (perms-1-1) -- (perms-2-1) node[midway,right]{3};
\draw (perms-1-2) -- (perms-2-2) node[midway,right]{3};
\draw (perms-1-3) -- (perms-2-3) node[midway,right]{2};
\draw (perms-2-1) -- (perms-3-1) node[midway,right]{2};
\draw (perms-2-2) -- (perms-3-2) node[midway,right]{1};
\draw (perms-2-3) -- (perms-3-3) node[midway,right]{1};
\end{tikzpicture}
\end{document}
答案3
另一种解决方案,结果类似。
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\node(SW) at (0,0){3421};
\node(SC) at (2,0){2431};
\node(SE) at (4,0){1432};
\node(CW) at (0,2){3241};
\node(CC) at (2,2){4231};
\node(CE) at (4,2){4132};
\node(NW) at (0,4){3214};
\node(NC) at (2,4){4213};
\node(NE) at (4,4){4312};
\draw(SW) -- node[above]{2} (SC) -- node[above]{1} (SE);
\draw(CW) -- node[above]{3} (CC) -- node[above]{1} (CE);
\draw(NW) -- node[above]{3} (NC) -- node[above]{2} (NE);
\draw(SW) -- node[right]{2} (CW) -- node[right]{3} (NW);
\draw(SC) -- node[right]{1} (CC) -- node[right]{3} (NC);
\draw(SE) -- node[right]{1} (CE) -- node[right]{2} (NE);
\end{tikzpicture}
\end{document}
它与前一个没什么不同。我只是在 @marmot 发布他的答案之前就开始写了。