The vertex colouring problem is a complicated one. You're using the greedy algorithm, which gives usually good but often not optimal results.
So you need to count the vertices, and assign each a...