我想用 TIKZ 绘制这样的图像。
我想将正方形转换为矩形,因此我使用 Tikz。但是,我无法在 TIKZ 中绘制这些点。这是我编写的代码。
\begin{tikzpicture}[%
->,
>=stealth',
shorten >=1pt,
node distance=2cm,
thick,
every state/.style={%
fill=white,
draw=black,
text=black
}
]
\node[state] (A) {$A$};
\node[state] (B1) [right of=A] {$B$};
\node[state] (B2) [above of=B1] {$B$};
\node[state] (B3) [below of=B1] {$B$};
\node[state] (B4) [below of=B3,node distance=4cm] {$B$};
\node[state] (B5) [above of=B1,node distance=4cm] {$B$};
\draw[below of=B5] node {...};
\node[state] (C1) [right of=B1] {$C$};
\node[state] (C2) [right of=B2] {$C$};
\node[state] (C3) [right of=B3] {$C$};
\node[state] (D) [right of=C1] {$D$};
\path (A) edge node [above, xshift=-1mm,very near start] {$N$} node [above, xshift=1mm,very near end] {$1$} (B1)
(A) edge node [above, xshift=-1mm,very near start] {$1$} node [above, xshift=1mm,very near end] {$1$} (B2)
(A) edge node [above, xshift=-1mm,very near start] {$1$} node [above, xshift=1mm,very near end] {$1$} (B3)
(B1) edge node [above, xshift=-1mm,very near start] {$1$} node [above, xshift=1mm,very near end] {$1$} (C1)
(B2) edge node [above, xshift=-1mm,very near start] {$1$} node [above, xshift=1mm,very near end] {$1$} (C2)
(B3) edge node [above, xshift=-1mm,very near start] {$1$} node [above, xshift=1mm,very near end] {$1$} (C3)
(C1) edge node [above, xshift=-1mm,very near start] {$1$} node [above, xshift=1mm,very near end] {$1$} (D)
(C2) edge node [above, xshift=-1mm,very near start] {$1$} node [above, xshift=1mm,very near end] {$1$} (D)
(C3) edge node [above, xshift=-1mm,very near start] {$1$} node [above, xshift=1mm,very near end] {$1$} (D);
% Hard-coded the token location since i don't know about it.
% \fill[black] (0.00,1.00) circle (2pt);
%\fill[black] (3.00,1.00) circle (2pt);
%\fill[black] (6.00,1.00) circle (2pt);
\end{tikzpicture}
有人可以告诉我怎样让它工作吗?
答案1
我通过选项弄清楚了$\ldots$
,我们可以绘制点,而另一个选项draw=none
不会为该节点绘制圆圈。
如果有人需要,这是代码
\begin{tikzpicture}[%
->,
>=stealth',
shorten >=1pt,
node distance=1.75cm,
thick,
every state/.style={%
fill=white,
draw=black,
text=black
}
]
\node[state] (A) {$A$};
\node[state] (B1) [right of=A,node distance=3cm] {$B$};
\node[state] (B2) [above of=B1] {$B$};
\node[state] (B3) [below of=B1] {$B$};
\node[state] (B6) [above of=B2,draw=none,node distance=1cm] {$\ldots$};
\node[state] (B5) [above of=B6,node distance=1cm] {$B$};
\node[state] (B7) [below of=B3,draw=none,node distance=1cm] {$\ldots$};
\node[state] (B4) [below of=B7,node distance=1cm] {$B$};
\node[state] (C1) [right of=B1] {$C$};
\node[state] (C2) [right of=B2] {$C$};
\node[state] (C3) [right of=B3] {$C$};
\node[state] (C6) [above of=C2,draw=none,node distance=1cm] {$\ldots$};
\node[state] (C5) [above of=C6,node distance=1cm] {$C$};
\node[state] (C7) [below of=C3,draw=none,node distance=1cm] {$\ldots$};
\node[state] (C4) [below of=C7,node distance=1cm] {$C$};
\node[state] (D) [right of=C1,node distance=3cm] {$D$};
\path (A) edge (B1)
(A) edge (B2)
(A) edge (B3)
(A) edge (B4)
(A) edge (B5)
(B1) edge (C1)
(B2) edge (C2)
(B3) edge (C3)
(B4) edge (C4)
(B5) edge (C5)
(C1) edge (D)
(C2) edge (D)
(C3) edge (D)
(C4) edge (D)
(C5) edge (D);
\end{tikzpicture}