A triangle in an undirected graph is a set of 3 nodes that all have edges to each other. Let G be a graph with n nodes. Each of the (n choose 2) possible edges exist with probability p. What is the expected number of triangles in G?
I know I use the Expectation formula. So far I have  ${N}\choose{3}$ times some probability. I am supposed to use the expectation formula Any hints?

Let $X$ be the random variable that counts the triangles in $G$. Then
$$X = \sum_{i,j,k \in V(G)} \chi_{i,j,k}$$
where
$$\mathbb{\chi}_{i,j,k} = \begin{cases}1, \; \text{if } \{i,j,k\} \text{ are pariwise connected} \\
0, \; \text{otherwise} \end{cases}$$
From your question I am assuming that the graph is undirected and that the probability of each edge existing in the graph is constant and independent of all other edges. Let's call that probability $p$. Then
$$\mathbb{P}[\chi_{i,j,k} = 1] = \mathbb{P}[\{i,j\} \in E(G)]\cdot \mathbb{P}[\{j,k\} \in E(G)]\cdot \mathbb{P}[\{k,i\} \in E(G)] = p^3$$
Now from the linearity of expectation we get that the expected number of triangles in $G$ is equal to
$$\mathbb{E}[X] = \mathbb{E}\left[\sum_{i,j,k \in V(G)} \chi_{i,j,k}\right]
=\sum_{i,j,k \in V(G)}\mathbb{E}[\chi_{i,j,k}] = \sum_{i,j,k \in V(G)}\mathbb{P}[\chi_{i,j,k} = 1] = \binom{n}{3}\cdot p^3$$
