The path $1,2,3$ contains two edges: $\{1,2\}$ and $\{2,3\}$. Therefore, its length is $2$. Miriam Briskman, CC BY-NC 4.0.
\documentclass[border=1pt]{standalone}
\usepackage{tikz}
\tikzset{
vertex/.style={draw, circle, very thick, minimum size=1cm},
edge/.style={very thick}
}
\begin{document}
\begin{tikzpicture}
\node[vertex] (1) at (0,0) {$1$};
\node[vertex] (2) at (2,0) {$2$};
\node[vertex] (3) at (4,0) {$3$};
\draw[edge] (1) -- (2);
\draw[edge] (2) -- (3);
\end{tikzpicture}
\end{document}