Consider a graph with $n$ vertices, where each edge between any two vertices is independently drawn with probability $p$. Let $D_i$ be the degree of vertex $i$. What is $E[D_i \cdot D_j]$?
Here is what I did. Clearly $D_i$ and $D_j$ are not independent so we cannot just split up the product. Instead, let $C$ be the event that vertices $i$ and $j$ are connected.
$E[D_i \cdot D_j]= E[D_i \cdot D_j| C]\cdot Pr(C)+E[D_i \cdot D_j| \bar C]\cdot Pr(\bar C)$
Now $D_i$ and $D_j$ are independent, so we can simplify $E[D_i \cdot D_j]=E[D_i] \cdot E[D_j]$. Thus, we have:
$((n-2))p+1)^2\cdot p + ((n-2)p)^2\cdot (1-p)$
But this is not right. Why? How can I correct this?