Mantel's Theorem proof verification

Pick any vertex $x \in V$ of degree $k$ (that is, let $k = d(x)$). Then $G$ contains $k$ edges of the form: $$ xy_1, xy_2, \ldots, xy_k $$ where $y_1,y_2,\ldots,y_k \in V$. Hence, in the summation: $$ \sum_{xy \in E}(d(x) + d(y)) $$ we know that the term $d(x)$ will appear exactly $k$ times. In other words, the vertex $x$ will contribute an amount of: $$ \underbrace{d(x) + d(x) + \cdots + d(x)}_{k \text{ times}} = k \cdot d(x) = d(x) \cdot d(x) = d^2(x) $$ Thus, since $x$ was arbitrary, it follows that: $$ \sum_{xy \in E}(d(x) + d(y)) = \sum_{x \in V} d^2(x) $$ as desired.


In the sum $S:=\sum_{xy\in E}\bigl(d(x)+d(y)\bigr)$ the ends $x$ and $y$ of each edge $e=xy$ get $d(x)$, resp. $d(y)$, points each. This means that every vertex $x\in V$ gets $d(x)$ points for each edge having an end at $x$. It follows that $S=\sum_{x\in V}d^2(x)$.