# Connect nodes in path statement

I am trying to draw a sequence of nodes which I would like to connect.

The following path specification draws a triangle but connects the coordinates instead of the nodes at those coordinates.

\draw (0,0)
+(90:1cm) node {1} to
+(210:1cm) node {2} to
+(330:1cm) node {3} to
+(90:1cm);


What I would like instead would be something like the following code which connects the nodes and not the center positions stated in the path.

\draw (0,0)
+(90:1cm) node[name=a]  {}
+(210:1cm) node[name=b] {}
+(330:1cm) node[name=c] {};
\foreach \from/\to in {a/b, b/c, c/a}
\draw (\from) -- (\to);


Is there a direct way to do this without naming the nodes and drawing the lines manually?

edit: On the left is the first snippet and on the right the second, I want to have the right one:

• naming the nodes is a convenient way! other ways is more complex I think May 7 at 12:23
• I don't know if I understood properly your question, so are you looking for something like this? postimg.cc/WFZH113f/3ed0c296 May 7 at 12:41
• @LukeTheWolf yes, that is exactly what I am looking for (and approximately what the second snippet produces) May 7 at 13:29
• @MartinR I have used a different structure, but if you just need the node connection it could be useful too. So tell me if you want me to post it anyway May 7 at 13:31
• @LukeTheWolf I just added a picture of the problem. As long as it is simpler than naming the nodes and also scales to larger geometries, I am interested May 7 at 13:39

## 3 Answers

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

\begin{document}
\begin{tikzpicture}[every node/.style={circle, draw}]
\draw node (1) {1} --++(-60:2cm) node (2) {2} --++(180:2cm) node (3){3} (1)--(2)--(3)--(1);
\end{tikzpicture}
\end{document}


Since I'm used to write automata, I found that was easier to draw a triangle in this way:

\documentclass[12pt]{article}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{arrows,automata}
\begin{document}
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=3cm,
scale = 1,transform shape]

\node[state] (1) {$1$};
\node[state] (2) [below left of=1] {$2$};
\node[state] (3) [below right of=1] {$3$};

\path [-] (1) edge (2)
[-] (2) edge (3)
[-] (1) edge (3);

\end{tikzpicture}
\end{document}


It probably doesn't solve the problem the same way you were asking for, but as we discussed in the comment, this is how I would solve it.

In any case, you can take a cue from this and rewrite it in some other ways!

I guess you will get that naming the nodes is a convenient feature when you are more familiar with TikZ.

In the following, all nodes have no name.

\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}
\def\r{1.5}
\draw (90:\r)--(210:\r)--(-30:\r)--cycle;
\path[nodes={draw,circle,fill=white}]
(90:\r) node{1}
(210:\r) node{2}
(-30:\r) node{3};
\end{tikzpicture}
\end{document}