# put a label inside loop made by path

I am completely new to tikz so excuse me if it seems easy. I am going to put a label inside the closed path I have written(mostly taken from here):

\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=3cm,
thick,main node/.style={circle,draw,font=\Large\bfseries}]
\node[main node] (2) {2};
\node[main node] (1) [below left  of=2] {1};
\node[main node] (3) [below right of=2] {3};
\path
(1) edge node [below]{} (2)
edge node[below] {} (3)
(2) edge node[right] {} (3)
(3) ;
\end{tikzpicture}


Thanks for any guide.

• Your code is not compileable. It must start with the \document{class} and end with the \document{document}. – AndréC Jan 12 at 8:21
• Where exactly do you want to add the text? – AndréC Jan 12 at 8:23
• @AndréC just in the middle of three nodes. – Abolfazl Jan 12 at 8:33

If you don't know which "center" you're talking about, I suggest you use the barycentric coordinates to do so. (See pages 136 et seq. of manual 3.1 13.2.2 Barycentric Systems)

\documentclass[tikz,border=5mm]{standalone}
\usetikzlibrary{arrows}

\begin{document}
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=3cm,
thick,main node/.style={circle,draw,font=\Large\bfseries}]
\node[main node] (2) {2};
\node[main node] (1) [below left  of=2] {1};
\node[main node] (3) [below right of=2] {3};
\path
(1) edge node [below]{} (2)
edge node[below] {} (3)
(2) edge node[right] {} (3)
(3) ;
\node at (barycentric cs:1=1,2=1 ,3=1) {Text};
\end{tikzpicture}
\end{document}


off-topic:

• use only numbers for node names is not good practice. instead 1, 2 and 3 is better to use for example n1, or n2 and n3
• if you not label edges than don't clutter code with empty nodes.
• for labeling of edges is handy to use quotes library
• at using barycentric coordinates be careful: between colon or comas and node names had not be an empty space
• it seems that you have a mess in code for drawing arrows

using solution for placing nodes inside triangle suggested in @AndréC answer (+1) the mwe can be as follows:

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta, positioning, quotes}

\begin{document}
\begin{tikzpicture}[
node distance = 17.3mm and 10mm,
every edge/.style = {draw, semithick, -Stealth, shorten >=1pt},
every edge quotes/.style = {inner sep=1pt,
font=\footnotesize, text=gray,
sloped, auto=left},
main/.style = {circle, draw, semithick,
minimum size=3ex, inner sep=2pt,
font=\bfseries}
]
\node (n1) [main] {1};
\node (n2) [main, above right=of n1] {2};
\node (n3) [main, below right=of n2] {3};

% note: between ":" or "," and "<node name>" had not to be empty space!
\node at (barycentric cs:n1=1 ,n2=1 ,n3=1) {text};

\draw   (n1) edge ["2" ']    (n3)
(n1) edge ["3"]      (n2)
(n2) edge ["1"]      (n3);
\end{tikzpicture}
\end{document}