I am using TikZ to draw graph, and want to add edge weights. I have seen some successful example like this. However, when I try to do the same thing, it doesn't work. Could anyone know the reason? Much indebted!
The following is my current code:
\documentclass{article}
\usepackage{tikz}
\usepackage{caption}
\begin{document}
\tikzstyle{every node}=[circle, draw, fill=black!100, inner sep=0pt, minimum width=4pt]
\begin{figure}[h]
\centering
\begin{tikzpicture}
\foreach \r in {1,...,4}
{
\foreach \s in {1,...,4}
{
\node (\r\s) at ({cos(\r*90)*(2+sqrt(2)*0.5*cos(45+\s*90))-sin(\r*90)*(sqrt(2)*0.5*sin(45+\s*90))},{sin(\r*90)*(2+sqrt(2)*0.5*cos(45+\s*90))+cos(\r*90)*(sqrt(2)*0.5*sin(45+\s*90))}) {};
}
\foreach \s in {5,6}
{
\node (\r\s) at ({cos(\r*90)*(2)-sin(\r*90)*(1+sqrt(3))*(\s-5.5)},{sin(\r*90)*(2)+cos(\r*90)*(1+sqrt(3))*(\s-5.5)}) {};
}
\draw[-] (\r1)--(\r2);
\draw[-] (\r3)--(\r4);
\draw[-] (\r2)--(\r3);
\draw[-] (\r4)--(\r1);
\draw[-] (\r5)--(\r2);
\draw[-] (\r5)--(\r3);
\draw[-] (\r6)--(\r4);
\draw[-] (\r6)--(\r1);
}
\draw[-] (16)--(25);
\draw[-] (26)--(35);
\draw[-] (36)--(45);
\draw[-] (46)--(15);
\end{tikzpicture}
\caption*{\footnotesize{Figure 2}}
\end{figure}
\end{document}
The code currently looks like:

My goal is:

What I have tried, like the solution in the successful example, but fails in my case, I add \draw (16) -- node {weight} (34);, then it becomes:

{ }-looking button at the top of the editor box, or use the keyboard shortcutCtrl + K. Short bits of inline code can be marked by surrounding them with backticks: `. – Paul Gessler Jun 07 '15 at 22:41\draw (16) -- node {weight} (34);Why ask about computer-generation. There is a lot of trigonometric calculation going on in your code.Do you know that TikZ knows polar coordinates:(<angle>:<distance>). With thecalclibrary, you can easily add different coordinates and such. – Qrrbrbirlbel Jun 07 '15 at 23:05every nodestyle. It is also applied to the edge nodes. You will need to declare an own style for the dots which you will need to use at those nodes you alread have. (A separate style for the edge node is usually also helpful.) – Qrrbrbirlbel Jun 07 '15 at 23:22