我有以下基本代码。我需要绘制如下网络。有人能帮我修改一下这个代码吗?
梅威瑟:
\documentclass{article}
\usepackage{subcaption, pgf, tikz,geometry, hyperref}
\geometry{left=1in,right=1in,top=1in,bottom=1in}
\usepackage{tikz}
\usetikzlibrary{arrows, automata, calc}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}[
> = stealth, % arrow head style
shorten > = 1pt, % don't touch arrow head to node
auto,
node distance = 3cm, % distance between nodes
semithick % line style
]
\tikzstyle{every state}=[
draw = black,
thick,
fill = white,
minimum size = 4mm
]
\node (a) {...};
\node[state] (b) at ($ (a) + (0:2) $) {m};
\node (a0) at ($ (b) + (90:1) $) {};
\node (c) at ($ (b) + (0:2) $) {...};
\node[state] (d) at ($ (a) + (-45:1.5) $) {j};
\node[state] (e) at ($ (b) + (-45:1.5) $) {k};
\node[state] (f) at ($ (d) + (-45:1.5) $) {i};
\path[] (a) edge node {$\dots$} (b);
\path[] (b) edge node {$\vdots$} (a0);
\path[->] (a) edge node {} (d);
\path[->] (b) edge node {} (d);
\path[->] (b) edge node {} (e);
\path[->] (c) edge node {} (e);
\path[->] (d) edge node {} (f);
\path[->] (e) edge node {} (f);
\end{tikzpicture}
\caption{Assembly topology with diamond}
\end{figure}
\end{document}
我的结果是:
答案1
edge
命令默认会画一条线,如果你不想要它,请使用edge[draw=none]
。但此选项不会在你想要的位置画点。
作为替代解决方案,我建议使用以下代码。它显示了对原始代码的一些更改:
- 它使用
every state/.style
而不是\tikzstyle
。参见:应该使用 \tikzset 还是 \tikzstyle 来定义 TikZ 样式? - 它使用
positioning
库而不是calc
相关坐标。 - 点被绘制为常规节点。
结果如下:
代码如下:
\documentclass{article}
\usepackage{subcaption, pgf, tikz,geometry, hyperref}
\geometry{left=1in,right=1in,top=1in,bottom=1in}
\usepackage{tikz}
\usetikzlibrary{arrows, automata, calc, positioning}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}[
> = stealth, % arrow head style
shorten > = 1pt, % don't touch arrow head to node
auto,
node distance = 3cm, % distance between nodes
semithick, % line style
every state/.style={
draw = black,
thick,
fill = white,
minimum size = 4mm
}
]
\node (a) {\dots};
\node[state, right=2cm of a] (b) {m};
\node[right=2cm of b] (c) {\dots};
\node[above=1mm of b] {\vdots};
\node[state, below left=1cm and 1cm of b] (d) {j};
\node[state, below right=1cm and 1cm of b] (e) {k};
\node[state, below right=1cm and 1cm of d] (f) {i};
\path[->] (a) edge node {} (d);
\path[->] (b) edge node {} (d);
\path[->] (b) edge node {} (e);
\path[->] (c) edge node {} (e);
\path[->] (d) edge node {} (f);
\path[->] (e) edge node {} (f);
\end{tikzpicture}
\caption{Assembly topology with diamond}
\end{figure}
\end{document}