Hello
I don’t understand your question. If it is a question of coloring a “Map”, just use Map colouring Theory. I made a small script for that. You specify the number of color, and the algorithm try. The only tricky part could be the frontier check, but it seems to work here.