Tikzpicture 绘制网络

Tikzpicture 绘制网络

。

我正在尝试使用 tikzpicture 绘制此网络。任何帮助或支持都将不胜感激

\documentclass{article}
\usepackage{tikz}
\begin{document}
\tikzstyle{block}=[draw, circle, scale=0.15, text centered, node distance=1.5cm]
\tikzstyle{line}=[draw, -latex']
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{shapes, decorations, shadows} 
\usetikzlibrary{decorations.pathmorphing}  
\usetikzlibrary{decorations.shapes}  
\usetikzlibrary{fadings}  
\usetikzlibrary{patterns}  
\usetikzlibrary{calc}
\begin{figure*}[!htb]
\centering
\resizebox{0.45\textwidth}{!}{%
\begin{tikzpicture}
\node[block, fill=green, thin](0){}; \node[block, fill=green, right of=0](0)
{};\node[block, fill=green, right of=0](0){};\node[block, fill=green, right of=0](0)
{};\node[block, fill=green, right of=0](0){};
\node[block, fill=green, below of=0](1){}; \node[block, fill=green, below of=1](2){};
\node[block, fill=green, left of=1](1){}; \node[block, fill=green, left of=1](1)
{};\node[block, fill=green, left of=1](1){}; \node[block, fill=green, left of=1](1){};
\node[block, fill=green, left of=2](2){}; \node[block, fill=green, left of=2](2){}; 
\node[block, fill=green, left of=2](2){}; \node[block, fill=green, left of=2](2){};
\end{tikzpicture}
}
\caption{Network representation} \label{Fig: 1}
\end{figure*} 
\end{document}

答案1

像这样吗?

\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{arrows.meta,calc}
\begin{document}
\begin{tikzpicture}[>={Stealth[length=1ex]}, font=\footnotesize, x=1.75cm,y=1.75cm]

\foreach \j in {0,...,5}{
  \foreach \i [evaluate={\c=int(\j<5 || \i > 0);}] in {0,...,3}{
    \ifnum\c>0
    \node [circle, draw, fill=blue!20, inner sep=0, minimum size=0.25cm] at (\j, 3.5-\i) (node-\i-\j) {};
    \else
      \node [circle, inner sep=0, minimum size=0.25cm] at (\j, 3.5-\i) (node-\i-\j) {};
    \fi
  }
}

\foreach \j in {0,...,5}{
  \ifnum\j<5
    \draw [<-] (node-0-\j) -- ++(0,.5) node [midway, right] {$B_{\j}$}  node [at end, above] (time-\j) {\j};
  \else
     \path (node-0-\j) -- ++(0,.5) node [at end, above] {$T=\j$};
  \fi
}

\node [above=.5cm] at (time-2) {Time period};

\foreach \i in {0,...,3}{
  \node at (-1, 3.5-\i) (asset age-\i) {$\ifnum\i=3 N=\fi\i$};
  \ifnum\i>0
    \node [above] at (-.5, 3.5-\i) {$n_{\i}$};
  \fi
}

\node [above left=.5cm, rotate=90] at (asset age-2) {Asset age};

\foreach \j in {0,...,4}{
  \foreach \i [evaluate={\J=int(\j+1); \I=int(\i+1);}] in {0,...,2}{
    \ifnum\i<2
      \draw [->] (node-\i-\j) to [out=345, in=105] node [midway, right] {$Y_{\i\j}$} (node-\I-\J);
    \fi
    \draw [->, dotted] (node-\i-\j) -- node [midway,anchor=(\i>1)*180] {$X_{\i\j}$} (node-\I-\J);
  }
}

\foreach \j in {0,...,5}
  \foreach \i in {1,...,3}
    \draw [->](node-\i-\j) -- ($(node-\i-\j |- 0,0) + (1/2-\i/8,0)$)
      node [pos={\i==2 ? 1/8 : 3/4}, anchor=(\i<2)*180] {$S_{\i\j}$};

\foreach \i/\j in {0/1,1/2,2/3,3/4}
  \node [left] at (node-\i-\j) {$a_{\i\j}$};
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容