We propose a semidefinite programming (SDP) algorithm for community detection\nin the stochastic block model, a popular model for networks with latent\ncommunity structure. We prove that our algorithm achieves exact recovery of the\nlatent communities, up to the information-theoretic limits determined by Abbe\nand Sandon (2015). Our result extends prior SDP approaches by allowing for many\ncommunities of different sizes. By virtue of a semidefinite approach, our\nalgorithms succeed against a semirandom variant of the stochastic block model,\nguaranteeing a form of robustness and generalization. We further explore how\nsemirandom models can lend insight into both the strengths and limitations of\nSDPs in this setting.\n