答案1
如果问题出在路径上,这里有一个例子。
由于 Roland 使用了 TikZlings,因此我使用 TikZducks(以及合适的攻击者):
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\usetikzlibrary{ducks}
\usetikzlibrary{arrows.meta, bending}
\tikzset{
mymatr/.style = {
matrix of nodes,
nodes={inner sep=2pt,
text centered,
draw,
circle
},
}
}
\begin{document}
\begin{tikzpicture}[mypath/.style={draw, -Triangle}]
\matrix[mymatr] (mym) {
&&[10pt]&[10pt]&&&&[4pt]&&&&&&&&&&&&&[30pt]|[name=intermediate]|{}\\[10pt]
&&{}&&&&{}&&&&&&&&&&&&&&\\[10pt]
&|[name=sourcenode, fill=black]|&&&& {}&&&&&&&&&&{}\\[6pt]
&&|[name=a]|&&&&&&&{}\\[4pt]
&&&&|[name=b]|\\
&&&&&&&&&&&&&&&&&{}\\
{}\\
&&{}&&&&&|[name=c]|&&&&&\\[10pt]
&{}&&&&&&&&&&&|[name=d]|\\[10pt]
&&& {}&&&&&&&&&&&&&&&|[name=basestation, fill=red]|\\
};
\node[font=\small, anchor=north] at (basestation.south) {base station};
\node[anchor=210] (David) at ([xshift=3mm]basestation.east) {\includegraphics[width=.7cm]{David.png}};% put you image here
\node[font=\small, anchor=south, inner sep=0pt] at (David.north) {attacker};
\path (sourcenode.north east) -- ++(-1,0) pic[
scale=.3,
] {duck} coordinate (duck);
\node[font=\small, anchor=north east, inner ysep=0pt] at (sourcenode.west) {source node};
\node[font=\small, anchor=south west, inner sep=0pt] at ([yshift=8mm]duck) {duck};
\node[font=\small, anchor=west] (interlabel) at (intermediate.east) {Intermediate node};
\node[font=\small, anchor=south east] (packedlegend) at (interlabel.north east) {Packed transmission};
\draw[mypath] (packedlegend.west) to ++(-1,00);
\node[font=\small, anchor=south east] (attacklegend) at (packedlegend.north east) {The attacker tracks the path hop by hop};
\draw[mypath] (attacklegend.west) to[bend right] ++(-1,00);
\draw[mypath] (sourcenode) -- (a);
\draw[mypath] (a) -- (b);
\draw[mypath] (b) -- (c);
\draw[mypath] (c) -- (d);
\draw[mypath] (d) -- (basestation);
\draw[mypath] (a) to[bend right] (sourcenode);
\draw[mypath] (b) to[bend right] (a);
\draw[mypath] (c) to[bend right] (b);
\draw[mypath] (d) to[bend right] (c);
\draw[mypath] (basestation) to[bend right] (d);
\end{tikzpicture}
\end{document}
答案2
对 tikzpeople 和 tikzlings 的建议:
\documentclass[border=0.5cm]{standalone}
\usepackage{tikz}
\usepackage{tikzlings}
\usepackage{tikzpeople}
\tikzset{
blacks/.style = {circle,fill=black},
whites/.style = {circle,draw=black},
reds/.style = {circle,fill=red},
}
\begin{document}
\begin{tikzpicture}
%path nodes
\node[blacks,label={[label distance=0.1cm]200:\tiny source node}] at (0,0) (a1) {};
\node[whites] at (1,-1) (a2) {};
\node[whites] at (3,-2) (a3) {};
\node[whites] at (5,-3) (a4) {};
\node[whites] at (6,-5) (a5) {};
\node[reds,label={[label distance=0.1cm]-90:\tiny base station}] at (7,-7) (a6) {};
%legend
\draw[stealth-] (3,0.5) to[out=45,in=135] (3.5,0.5) node[right] {\tiny The attacker tracks the path hop by hop};
\draw[-stealth] (3,0) -- (3.5,0) node[right] {\tiny Packet transmission path};
\node[whites,label={[label distance=0.1cm]0:\tiny Intermediate node}] at (3.25,-0.5) {};
%Panda
\panda[above=of a1,yshift=0.5cm,scale=0.25];
%attacker
\node[right=of a6,guard,evil,mirrored,shield,sword,saturated,label={[label distance=0.1cm]90:\tiny attacker}] {};
%path forward
\foreach \x [remember=\x as \lastx (initially 1)] in {2,...,6}{
\draw[-stealth] (a\lastx)--(a\x);}
%path backward
\foreach \y [remember=\y as \lasty (initially 6)] in {5,...,1}{
\draw[-stealth] (a\lasty) [out=65, in=35] to (a\y);}
%random nodes
\foreach \z in {1,2,...,4}{
\node[whites] at (8*rnd,-6*rnd) {};
\node[whites] at (2*rnd,-6*rnd) {};
\z
}
\end{tikzpicture}
\end{document}