Conjugacy classes of non-Abelian group of order $p^3$

We know that $Z(G) = p$. Suppose $[G:G_x] = p^2$ for some $x \notin Z(G)$. Then $G_x$ has $p$ elements, and since $Z(G) \subseteq G_x$, we have $Z(G) = G_x$. Now since $x$ is in $G_x$, it is also in $Z(G)$. From this it follows that $G_x = G$, and thus $Z(G) = G$, a contradiction. Thus $[G:G_x] = p$ for all $x \notin Z(G)$, showing that $G$ has $p^2 + p - 1$ conjugacy classes.


Suppose $g$ is a noncentral element. Then the centralizer of $g$ contains the centre of $G$, and also contains $g$ itself, giving it at least $p+1$ elements. Thus the centralizer has order $p^2$, so $g$ has $p$ conjugates. There are thus $p+\frac{p^3-p}{p}=p^2+p-1$ conjugacy classes.


The centraliser of a non-central element contains at least $p+1$ elements, since it contains the centre, with order $p$. It cannot have order equal to $p^3$, or the element would be central. Thus, the order of the centraliser or a non-central element is equal to $p^2$, and hence the index is equal to $p$, which is to say that it has $p$ conjugates. Therefore, there are $\frac{p^3 - p}{p} = p^2 - 1$ conjugacy classes of non-central elements, giving a total of $p^2 + p - 1$ conjugacy classes.