# how to add a label to a path?

For example (used by another thread):

\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{trees}
\begin{document}
\begin{tikzpicture}[level distance=1.5cm, grow=down,
every node/.style={draw, circle, thin},
edge from parent/.style={-latex, thick, draw}
]
\node (P) {P}
child {node (Q) {Q}
child {node (T) {T}}
child {node (U) {U}}
}
child {node (R) {R}}
child {node (S) {S}};

\path (P) -- coordinate[midway] (PQ) (Q);
\path (P) -- coordinate[midway] (PR) (R);

\draw (PQ) to[bend right=22] (PR);
\end{tikzpicture}
\end{document}


how can I add a label, e.g., M to the line PQ?

-
Never use the minimal class. It exists for very different purposes than preparing examples. –  egreg Mar 19 '13 at 23:29
See Herbert's answer in What is the advantage of using minimal over article when creating a standalone graphic? minimal doesn't define everything you always wanted. It may work in this instance, but it's not always transferable to other minimal examples. –  Werner Mar 19 '13 at 23:35

Putting the label is easy by using another node. The problem is, with the draw to every node style, all of your nodes are drawn as circles, which I think you do not want for the node with the label M. You can use scope inside your tikzpicture to separate the styles as I did here.

\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{trees}
\begin{document}
\begin{tikzpicture}
\begin{scope}[level distance=1.5cm, grow=down,
every node/.style={draw, circle, thin},
edge from parent/.style={-latex, thick, draw}
]
\node (P) {P}
child {node (Q) {Q}
child {node (T) {T}}
child {node (U) {U}}
}
child {node (R) {R}}
child {node (S) {S}};

\path (P) -- coordinate[midway] (PQ) (Q);
\path (P) -- coordinate[midway] (PR) (R);

\draw (PQ) to[bend right=22] (PR);
\end{scope}

\node [above left] at (PQ) {M}; % Draws the node labeled M

\end{tikzpicture}

\end{document}


-

Since the release of pgf/TikZ 3.0 it's easier to label edges, using the quotes syntax. If you already got an edge, it could be as simple as adding "text" to the edge option. Here, let's make it after the tree is drawn:

\path (P) edge["M"'] (Q);


Your bend line looks like an angle. With the also new angles library, you could add

pic[draw,angle radius=0.8cm] {angle=Q--P--R}


to the path above, for this. Now you don't even need to define coordinates (PQ) and (PR). Also the bend line is more like a radius, not just a connection between midpoints.

A complete code, modifying the suggestion by hpesoj626:

\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{trees,quotes,angles}
\begin{document}
\begin{tikzpicture}
\begin{scope}[level distance=1.5cm, grow=down,
every node/.style={draw, circle, thin},
edge from parent/.style={-latex, thick, draw}
]
\node (P) {P}
child {node (Q) {Q}
child {node (T) {T}}
child {node (U) {U}}
}
child {node (R) {R}}
child {node (S) {S}};
\end{scope}
\path (P) edge["M"'] (Q) pic[draw,angle radius=0.8cm] {angle=Q--P--R};
\end{tikzpicture}
\end{document}


-