Competitive accumulation of sulfur and graphite on the cobalt surface