6

.

I am trying to draw this network using a tikzpicture. Any help or support will be much appreciated

\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}
  • The nodes could be aligned using a matrix. to[bend left] will handle the curved arrows (see page 171). node[midway,above right] or node[midway,below left] could be used to label the arrows. – John Kormylo Sep 17 '14 at 12:38
  • I don't really know how to fix the problem you mentioned in your deleted question, so my only suggestion is the brute-force one: Uninstall/remove all of MikTeX, and reinstall it, or install TeX Live instead (tug.org/texlive/acquire-netinstall.html - download and run install-tl-windows.exe) – Torbjørn T. Sep 20 '14 at 9:59
9

Something like this?

\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}

enter image description here

  • Sure Mark. I respectfully and truly appreciate your support and help. Stay blessed. – user28251 Sep 17 '14 at 12:52
  • How do I answer the question I can't find tikzlibrary{arrows.meta} as an error. Thanks. – user28251 Sep 17 '14 at 16:50
  • @user28251 either (a) use \usetikzlibrary{arrows} and >=stealth in the keys for the tikzpicture, or (b) update to the latest version of PGF & TiKZ. – Mark Wibrow Sep 17 '14 at 17:05
  • Mark is there anyway you could do this without Stealth?? Because I have updated my PGF and TIKZ but am still getting this error with stealth – user28251 Sep 17 '14 at 17:22
  • Miktext2.9 does not know of the latest update in pgf and tikz so please I might your help. Thanks. – user28251 Sep 17 '14 at 17:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.