4

I need to draw an image like this:

I saw this and this, but I could not modify it properly. Basically, I could not write the on the labels. Need your help.

5
  • 1
    Please, show the code you used. The questions you linked are very good as starting point, what you need is to add some label on the nodes. Oct 26 '13 at 15:42
  • 1
    Have you tried \draw (a) -- node[above,sloped] {x} (b); for the edges and \node[label=90:$\varphi_1$] (phi1) at (x,y) {};? Oct 26 '13 at 16:10
  • Is it important that each edge meets at the border around the node? That is, is it ok if the edges seem to 'meet' somewhere in the center of the node, with the node overlaid atop the meeting point? Oct 26 '13 at 16:12
  • @SeanAllred That minute things don't make a difference. What is important is the structure of the network.
    – hola
    Oct 26 '13 at 17:23
  • 2
    I more than suspected, but this concession makes it a lot easier to implement, as you can see with the accepted answer. Oct 26 '13 at 17:29
8

Here's an idea how to do it:

Code

\documentclass[tikz,border=2mm]{standalone}

\begin{document}

\begin{tikzpicture}
[   cnode/.style={draw=black,fill=#1,minimum width=3mm,circle},
]
    \node[cnode=red,label=0:$\Sigma$] (s) at (6,-3) {};
    \node at (0,-4) {$\vdots$};
    \node at (3,-4) {$\vdots$};
    \foreach \x in {1,...,4}
    {   \pgfmathparse{\x<4 ? \x : "n"}
        \node[cnode=blue,label=180:$x_{\pgfmathresult}$] (x-\x) at (0,{-\x-div(\x,4)}) {};
        \node[cnode=gray,label=90:$\varphi_{\pgfmathresult}$] (p-\x) at (3,{-\x-div(\x,4)}) {};
        \draw (p-\x) -- node[above,sloped,pos=0.3] {$\omega_{\pgfmathresult}$} (s);
    }
    \foreach \x in {1,...,4}
    {   \foreach \y in {1,...,4}
        {   \draw (x-\x) -- (p-\y);
        }
    }
\end{tikzpicture}

\end{document}

Output

enter image description here

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