Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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
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. –  Claudio Fiandrino 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) {};? –  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
1  
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
add comment

marked as duplicate by Jubobs, mafp, cgnieder, 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.

1 Answer

up vote 2 down vote accepted

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

share|improve this answer
add comment

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