The role of polarity on the stability of graphitic compounds