12. Let $S$ be the set composed of the sides and diagonals of a regular pentagon. If any two elements are chosen from it, the probability that these two elements have the same length is ( ).
(A) $\frac{2}{5}$
(B) $\frac{4}{9}$
(C) $\frac{1}{2}$
(D) $\frac{5}{9}$
(E) $\frac{4}{5}$
12. B.
$$
\frac{C_{5}^{2}+C_{5}^{2}}{C_{10}^{2}}=\frac{20}{45}=\frac{4}{9} .
$$