This example shows two methods for finding a minimal coloring of the faces of a planar graph. First, we review the built-in approach for finding a minimal coloring using
FindPlanarColoring
. This method includes the outer face of the graph, that is, the face that outlines the graph on the plane, in the computation. Then we implement custom functions to find a minimal coloring that ignores the outer face.
accounts for the outer face by default can be a limitation. Suppose
g
is a 10×10 grid graph. When we ask for the minimal coloring of
g
, it's likely that we expect to color the checkerboard faces, and that we don't consider that the outer face (the outline of the board itself) is a face to be colored. Failing to consider this, and reusing the technique above to color
g
, the result appears sub-optimal:
Define a grid graph:
In[6]:=
g=GridGraph[{1,1}10,ImageSizeTiny]
Out[6]=
Find the faces of g, coordinates of g' s vertices and a planar coloring of g:
In fact, this result really is a minimal coloring only if one includes the outer face in the list of faces that must be colored. In the plot, that outer face is behind all the other faces, and is blue. With that said, it's still not the coloring we likely expected. And a checkerboard is obviously two-colorable, so how can we omit the outer face from the computation?
The first step is identifying the outer face on
g
. Since the outer face on any planar graph always contains all other (inner) faces, it must be the largest in area. We can easily write a function to retrieve the face with the largest area from a given planar graph, as follows: