chromaticPolynomial G
The chromatic polynomial is an invariant of a graph that counts the number of vertex colorings. The value of this polynomial at a natural number n is the number of ways to color the vertices of G using at most n colors, such that no adjacent vertices have the same color.
This method computes the chromatic polynomial as a multiple of the characteristic polynomial of the graphic matroid. Indeed, if M = M(G) is the graphic matroid corresponding to a graph G, then the chromatic polynomial of G equals the characteristic polynomial of M times x^k, where k is the number of connected components of G (which is distinct from the number of components of M).


The Four Color Theorem states that if G is a planar graph, then its chromatic polynomial has value > 0 at n = 4. In accordance with this, we see that K5 is not planar (on the other hand, note that K_{3,3} is bipartite, hence 2colorable):

The object chromaticPolynomial is a method function.