![我们如何绘制一个带有向上、向下、向左和向右四个箭头的圆形物体的图表?](https://linux22.com/image/465524/%E6%88%91%E4%BB%AC%E5%A6%82%E4%BD%95%E7%BB%98%E5%88%B6%E4%B8%80%E4%B8%AA%E5%B8%A6%E6%9C%89%E5%90%91%E4%B8%8A%E3%80%81%E5%90%91%E4%B8%8B%E3%80%81%E5%90%91%E5%B7%A6%E5%92%8C%E5%90%91%E5%8F%B3%E5%9B%9B%E4%B8%AA%E7%AE%AD%E5%A4%B4%E7%9A%84%E5%9C%86%E5%BD%A2%E7%89%A9%E4%BD%93%E7%9A%84%E5%9B%BE%E8%A1%A8%EF%BC%9F.png)
我想要绘制如下内容:
其动机是为了说明一些人称之为“二维链表“
class TwoDeeNode {
// NODE HAS FOUR MEMBER VARIABLES
Pointer<TwoDeeNode> left;
Pointer<TwoDeeNode> right;
Pointer<TwoDeeNode> up;
Pointer<TwoDeeNode> down;
}
但是,那乳胶代码几乎无法阅读,现在我陷入困境。
最终,我可能会也可能不会编写一个编译器,将一些人类可读的图表编译成乳胶图表的代码。
然而,我们在乳胶?
我打算使用一个具有五个中心对齐列的数组。
\begin{array}{ccccc}
...
\end{array}
与往常一样,“&”符号&
在源代码中充当列分隔符。
\require{enclose}
\usepackage{graphicx}
\begin{array}{ccccc}
\text{} & \text{} & \Large{\enclose{circle}{x.up}} & \text{} & \text{} \\\\
\text{} & \text{} & \text{} & \text{} & \text{} \\\\
\Large{\enclose{circle}{x.left}} & \xleftarrow{left} & \Large{\enclose{circle}{x}} & \xrightarrow{right} & \Large{\enclose{circle}{x.right}} \\\\
\text{} & \text{ } & \scriptsize{down}\large{\downarrow} & \large{\downarrow} \\\\
\text{} & \text{} & \Large{\enclose{circle}{x.down}} & \text{} & \text{} & \text{} & \text{} & \\\\
\end{array}
答案1
像这样:
代码:
\documentclass[tikz,border=10pt]{standalone}
\begin{document}
\begin{tikzpicture}
\draw (0,0) circle(.2) node {$x$};
\draw (3,0) ellipse(.8 and .2) node {$x.right$};
\draw (-3,0) ellipse(.8 and .2) node {$x.left$};
\draw (0,1.5) ellipse(.8 and .2) node {$x.up$};
\draw (0,-1.5) ellipse(.8 and .2) node {$x.down$};
\draw[-latex] (.8,0)--(1.5,0) node[midway,yshift=.15cm] {\tiny $right$};
\draw[-latex] (-.8,0)--(-1.5,0) node[midway,yshift=.15cm] {\tiny $left$};
\draw[-latex] (0,.5)--(0,1) node[midway,right] {\tiny $up$};
\draw[-latex] (0,-.5)--(0,-1) node[midway,left] {\tiny $down$};
\end{tikzpicture}
\end{document}