Number of vertices of degree 1 - Expectation and Variance Let $G\in G(n,p),0\le p\le \binom n 2=N$ where $G(n,p)$ consists of all $\binom N p$ subgraphs of $K_n$ with $p$ edges.
Now let $X$ be the number of vertices of degree $1$ in $G\in G(n,p)$. 
Why is $\mathbb E[X]=n(n-1)p(1-p)^{n-2}$? I do not see how to derive this in a combinatorial way, same with $Var X$, would be great if you can help me out. 
 A: For every vertex $x$, let $U_x=1$ if the degree of $x$ is $1$ and $0$ otherwise. Then:


*

*There are $n$ vertices $x$ and $X=\sum\limits_xU_x$.

*For every $x$, $U_x=1$ happens when one chooses one edge starting from $x$ ($n-1$ choices), one makes it open (probability $p$) and one makes the $n-2$ others closed (probability $(1-p)^{n-2}$). Thus, $$E(U_x)=(n-1)p(1-p)^{n-2}.$$

*This yields $E(X)=\sum\limits_xE(U_x)=$ $____$.

*For every $x\ne y$, $U_xU_y=1$ can happen in two ways. 

*

*Either one makes the edge $xy$ open (probability $p$), every other edge starting from $x$ closed (probability $(1-p)^{n-2}$) and every other edge starting from $y$ closed (probability $(1-p)^{n-2}$). 

*Or one makes the edge $xy$ closed (probability $1-p$), exactly one of the other $n-2$ edges starting from $x$ open and the others closed (probability $(n-2)p(1-p)^{n-3}$), and likewise for the edges starting from $y$. 

*Thus,
$$
E(U_xU_y)=p(1-p)^{2n-4}+(1-p)(n-2)^2p^2(1-p)^{2n-6}.
$$


*Let $a=E(U_x)$ and $b=E(U_xU_y)$ for $x\ne y$, then $a$ and $b$ are computed above, and $X^2=\sum\limits_xU_x+\sum\limits_{x\ne y}U_xU_y$ hence
$$
\mathrm{var}(X)=E(X^2)-E(X)^2=(na+n(n-1)b)-(na)^2.
$$

