Conjugacy classes of a nonabelian group of order $p^4$ Apologies in advance for the long text! I will explain what I have done so far, and then I will present my question.
Consider a nonabelian group of order $p^4$, where $p$ is a prime. Then, the center $Z(G)$ cannot have order $p^3$ or $p^4$, since both these cases would lead to the contradiction that $G$ is abelian. So we consider:
Case I: Order of $Z(G)$ is $p^2$     i.e.,$|Z(G)|=p^2$
The class equation is given by $|G|=|Z(G)|+\Sigma|G:C_G(g_i)|$, where the $g_i$ are representatives of the distinct conjugacy classes of G not contained in the center $Z(G).$ I deduced that for each $g\notin Z(G),$ $|G:C_G(g)|=p.$ So the class equation becomes $p^4=p^2+kp,$ where $k$ is the number of distinct conjugacy classes not contained in the center. This gives $k=p^3-p$ and hence the number of conjugacy classes of $G$ is $p^3+p^2-p$
Case II: $|Z(G)|=p$
I was able to prove that for any $g\notin Z(G),|G:C_G(g)|=p$ or $p^2.$ That means that, a conjugacy class not contained in the center can have size $p$ or $p^2.$
My question is: Is there any way to determine how many conjugacy classes of size $p$ is there, and how many conjugacy classes of size $p^2$ is there?
I would really appreciate any help regarding this question. Thank you!
 A: Here is a quick summary of what is happening - I have to admit that I did some computer calculations first and worked out what was happening.
It is not hard to see that a group $G$ of order $p^4$ with class two has centre of order $p^2$, so if $|Z(G)|=p$ then $G$ has class three and $|[G,G]|=p^2$.
Since the order of the automorphism group of a group of order $p^2$ is not divisible by $p^2$, we must have $|C_G([G,G])| = p^3$.
Then the elements in $C_G([G,G]) \setminus Z(G)$ have centralizers of order $p^3$ and classes of order $p$. There are $p^3-p$ such elements, and the remaining $p^4-p^3$ elements have centralizers of order $p^2$ and lie in classes of size $p^2$.
To see that a group of class $2$ has centre of order $p^2$, suppose not and let $G$ be a counterexample. Then $|Z(G)|=p$ and $G/Z(G)$ is abelian of order $p^3$. Then the commutator map $(g,h) \to [g,h]$ induces a bilinear map $G/Z(G) \times G/Z(G) \to Z(G)$.
Since $G/Z(G)$ cannot be cyclic, it is isomorphic to $C_p \times C_p \times C_p$ or to $C_p \times C_{p^2}$.
In the first case, let $a,b,c$ be inverse images in $G$ of generators of the three copies of $C_p$, and let $Z(G) = \langle z \rangle$.
Suppose that $[a,b]=z^i$, $[a,c]=z^j$, $[b,c]=z^k$ with $0 \le i,j,k < p$. We cannot have $i=j=k=0$, so suppose that $i \ne 0$. Then $[a,b^tc] = z^{it+j}$ and so choosing $t = -j/i\bmod p$ gives $[a,b^tc] = 1$. Similarly we can find $s$ with $[b,a^sc] = 1$, and then $a^sb^tc \in Z(G)$, contradiction.
The case $G/Z(G) = C_p \times C_{p^2}$ is easier, because the $p$-th power of the inverse image in $G$ of a generator of the $C_{p^2}$ factor is in $Z(G)$.
