TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

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.

share|improve this question

marked as duplicate by Jubobs, mafp, clemens, morbusg, azetina Oct 26 '13 at 16:39

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

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. – Claudio Fiandrino Oct 26 '13 at 15:42
Have you tried \draw (a) -- node[above,sloped] {x} (b); for the edges and \node[label=90:$\varphi_1$] (phi1) at (x,y) {};? – Tom Bombadil 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? – Sean Allred Oct 26 '13 at 16:12
@SeanAllred That minute things don't make a difference. What is important is the structure of the network. – pushpen.paul Oct 26 '13 at 17:23
I more than suspected, but this concession makes it a lot easier to implement, as you can see with the accepted answer. – Sean Allred Oct 26 '13 at 17:29
up vote 5 down vote accepted

Here's an idea how to do it:




[   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);



enter image description here

share|improve this answer

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