How many adjacent edges in an $n \times n$ grid of squares?

Solution 1:

There are $n$ adjacent edges in each horizontal line segment and there are $n-1$ such line segments. This leads to a total of $n(n-1)$ $\color{red}{\text{horizontal adjacent edges}}$. And since a square is symmetric, there are an equal number of $\color{blue}{\text{vertical adjacent edges}}$ too. Therefore, the total number of adjacent edges in a $n\times n$ grid is given by: $$ 2n(n-1)$$ enter image description here

Solution 2:

A $n\times n$ grid has $n^2$ squares. There are $n-1$ columns of vertical adjacent edges, and each column contains $n$ edges. The number of horizontal adjacent edges is the same: the total number of adjacent edges is $2n(n-1)$.