Monochromatic triangels in a graph - variance 
Consider the complete graph $K_n$ and consider a random colouring of the edges
with $3$ colours. Let $X$ be the random variable which counts the
number of monochromatic triangles in $K_n$, i.e. triangles whose
edges have the same colour. Compute $\mathbb{E}\left[X  \right]$ and
$\text{Var}\left[X  \right]$.

My attempt:
For simplicity we will denote the colour of an edge by
$\gamma\colon E\to \{1, 2, 3\} $. Moreover,
we introduce the indicator variable
$$
 X_{\{u, v, w\}} = \begin{cases}
  1, \text{ all edges in the triangle } u, v, w \text{ have the same colour}
  \\[5pt]
  0, \text{ else}
 \end{cases}
$$
This yields
\begin{align*}
 P\left( X_{\{u, v, w\} } =1\right) &= 
 \sum_{k = 1}^{3} P\left( \gamma\left( \{u, v\}  \right)=k  \right) 
 \cdot P\left( \gamma\left( \{u, w\}  \right)=k  \right) \cdot 
 P\left( \gamma\left( \{w, v\}  \right)=k  \right) 
 \\[10pt]
 &= 3 \cdot \frac{1}{27}=\frac{1}{9}= 
 \mathbb{E}\left[X_{\{u, v, w\} }  \right]
.\end{align*}
Using $X=\displaystyle \sum_{\{u, v, w\} \subseteq [n]}^{} X_{\{u, v, w\} }$
yields by
linearity of the expected value
$$
 \mathbb{E}\left[X\right]= \sum_{\{u, v, w\} \subseteq [n]}^{} 
 \mathbb{E}\left[X_{\{u, v, w\} } \right]
 = \binom{n}{3} \cdot \frac{1}{9}.
$$
For the variance we want to find $\mathbb{E}\left[X^2 \right]$
which can be done via case distinction:

*

*$| \{u, v, w\} \cap \{x, y, z\} |=3\colon $
$$
\mathbb{E}\left[ X_{\{u, v, w\}}\cdot X_{\{x, y, z\} }\right]
= 
\mathbb{E}\left[ X_{\{u, v, w\}}^2\right]=
\mathbb{E}\left[ X_{\{u, v, w\}}\right]=\frac{1}{9}.
$$


*$| \{u, v, w\} \cap \{x, y, z\} |=2\colon $
$$
\mathbb{E}\left[X_{\{u, v, w\}}\cdot X_{\{x, y, z\}} \right]= \mathbb{E}\left[X_{\{u, v, w\}}  \middle|  X_{\{x, y, z\}}=1 \right]\cdot 
P\left(X_{\{x, y, z\}}=1 \right) = \frac{1}{3}\cdot \frac{1}{27}\cdot 3
= \frac{1}{27} .
$$


*$| \{u, v, w\} \cap \{x, y, z\} |=1\colon $
$$
 \mathbb{E}\left[X_{\{u, v, w\}}\cdot X_{\{x, y, z\}} \right]=\mathbb{E}\left[X_{\{u, v, w\}}  \middle|  X_{\{x, y, z\}}=1 \right]\cdot 
P\left(X_{\{x, y, z\}}=1 \right) = \frac{1}{9}\cdot \frac{1}{27}\cdot 3=\frac{1}{81}.
$$


*$| \{u, v, w\} \cap \{x, y, z\} |=\varnothing\colon $
$$
 \mathbb{E}\left[X_{\{u, v, w\}}\cdot X_{\{x, y, z\}} \right]= \mathbb{E}\left[X_{\{u, v, w\}}\right]\cdot \mathbb{E}\left[X_{\{x, y, z\}} \right]
 =\frac{1}{9}\cdot \frac{1}{9}=\frac{1}{81}.
$$
We finally obtain
\begin{align*}
 &\mathbb{E}\left[ X^2\right]=
 \sum_{\{u, v, w\} \subseteq E}^{} \sum_{\{x, y, z\} \subseteq E}^{} X_{\{u, v, w\}}\cdot X_{\{x, y, z\}}
 \\[10pt]
 &= \sum_{1}^{} \frac{1}{9}+\sum_{2}^{} \frac{1}{27}+\sum_{3}^{} \frac{1}{81}+\sum_{4}^{} \frac{1}{81}
 \\[10pt]
 &= \binom{n}{3} \cdot \frac{1}{9}+\binom{n}{4}\cdot  \binom{4}{2} \cdot \frac{1}{27}+\binom{n}{5} \cdot 5\cdot \binom{4}{2} \cdot \frac{1}{81}
 + \binom{n}{6} \cdot \binom{6}{3} \frac{1}{81}
.\end{align*}
Is my computation for $\mathbb{E}\left[ X^2\right]$ correct?
 A: The overall approach is correct, but there are some mistakes.
Your expected value for the case $|\{x,y,z\} \cap \{u,v,w\}| =2$ is wrong. Here, we have two triangles sharing a single edge, so there are $5$ edges. There are $3$ colors, and for each, a $(\frac13)^5$ probability that all $5$ edges have that color, for an overall probability of $3 \cdot (\frac13)^5 = \frac1{81}$.
Separately, the factor of $\binom n4 \binom 42$ is wrong. Once you have chosen $\binom n4$ vertices to use for your two triangles, there are $4$ ways to choose the first triangle, and $3$ ways to choose the second triangle, so we should get $12 \binom n4$.
But that is insignificant, because once we have gotten a $\frac1{81}$ expected value in each of the off-diagonal cases, we can just take
$$
   \mathbb E[X^2] = \binom n3 \cdot \frac19 + \left(\binom n3^2 - \binom n3\right) \cdot \frac1{81}.
$$
Do not try to simplify this, because a lot of this expression will cancel with $\mathbb E[X]^2 = \binom n3^2 \cdot \frac1{81}$ when we find the variance.
