1

I have the following, picture and I want to make the edges between 1 and 3 and 1 and dotted. Also if I want to put names on the edges in the pictures how do I do that?

\documentclass{article}
\usepackage{tikz}
\begin{document}

 \begin{tikzpicture}[transform shape]
  \foreach \x in {1,...,4}{%
    \pgfmathparse{(\x-1)*360/4}
    \node[draw,circle,inner sep=0.15cm] (N-\x) at (\pgfmathresult:1.4cm) {\x};
  } 
  \foreach \x [count=\xi from 1] in {1,...,4}{%
    \foreach \y in {\x,...,4}{%
     \path (N-\x) edge[ultra thin,-] (N-\y);

  }
}
\end{tikzpicture}
        \end{document}
JMP
  • 3,238
Gidy
  • 123
  • The code fails with a number of errors. Could you please make sure your given code is compilable? – JMP Mar 28 '16 at 06:35
  • Thank you so much I was really trying to do it myself and made some failed code, sorry!! – Gidy Mar 28 '16 at 06:49
  • Your question is uncomplete. You want to have the edges between 1 and 3, 1 and ??? doted. – JMP Mar 28 '16 at 07:03
  • Related: http://tex.stackexchange.com/q/101262/2552 – Jake Mar 28 '16 at 07:06
  • Always test the code you post before you post it! (Even if you know it works....) – cfr Mar 28 '16 at 23:56
  • It would be nice to get some feedback on the answer I have given. Does this solve your problem? – JMP Mar 29 '16 at 09:36

1 Answers1

2

So here is some code. Sonce you did not mentioned the second node, where the edge starting from 1 should be dotted, I took 4. You basically need to tell tikz in the path options how to draw it. In this case I used [thin, densely dotted]. To place the name nodes you basically have to chose your previously defined node say x and chose the proper anchor, by saying (x.north) (x.west) and so on. Then you just have to properly align your name node with [left] [right] and so on.

\documentclass{article}
\usepackage{tikz}
\usepackage{ifthen}

\begin{document}

 \begin{tikzpicture}[transform shape]
  \foreach \x / \anchpos / \alignment in {1/east/right,2/north/above,3/west/left,4/south/below}{%
    \pgfmathparse{(\x-1)*360/4}
    \node[draw,circle,inner sep=0.15cm] (N-\x) at (\pgfmathresult:1.4cm) {\x};
        \node at (N-\x.\anchpos) [\alignment] {Name};
  } 
  \foreach \x [count=\xi from 1] in {1,...,4}{%
    \foreach \y in {\x,...,4}{%
            \ifthenelse{\x=1 \AND \(\y=3 \OR \y=4\)}{
                \path (N-\x) edge[thin,-,densely dotted] (N-\y);
                }{
                \path (N-\x) edge[ultra thin,-] (N-\y);
                }
  }
}
\end{tikzpicture}

\end{document}

enter image description here

JMP
  • 3,238