Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Find all proper k-colorings of a specified graph
ResourceFunction["FindProperColorings"][g,k] finds all proper k-colorings of the graph g. |
Define a graph:
In[1]:= | ![]() |
Out[1]= | ![]() |
Find all its proper 3-colorings:
In[2]:= | ![]() |
Out[2]= | ![]() |
Display the proper 3-colorings:
In[3]:= | ![]() |
Out[4]= | ![]() |
FindProperColorings works on disconnected graphs:
In[5]:= | ![]() |
Out[5]= | ![]() |
In[6]:= | ![]() |
Out[6]= | ![]() |
In[7]:= | ![]() |
Out[7]= | ![]() |
FindProperColorings works on directed graphs:
In[8]:= | ![]() |
Out[8]= | ![]() |
In[9]:= | ![]() |
Out[9]= | ![]() |
In[10]:= | ![]() |
Out[10]= | ![]() |
FindProperColorings works on multigraphs:
In[11]:= | ![]() |
Out[11]= | ![]() |
In[12]:= | ![]() |
Out[12]= | ![]() |
In[13]:= | ![]() |
Out[13]= | ![]() |
Define a graph:
In[14]:= | ![]() |
Out[14]= | ![]() |
A proper k-edge-coloring of a graph g is a function assigning each edge of g one of k colors such that incident edges receive distinct colors:
In[15]:= | ![]() |
Find the proper 3-edge-colorings of the graph:
In[16]:= | ![]() |
Out[16]= | ![]() |
Display the proper 3-edge-colorings:
In[17]:= | ![]() |
Out[9]= | ![]() |
Define a graph:
In[18]:= | ![]() |
Out[18]= | ![]() |
The chromatic polynomial f of a graph g is a function such that f(k) counts the proper k-colorings of g. Here is the chromatic polynomial of g3:
In[19]:= | ![]() |
Out[19]= | ![]() |
Use the chromatic polynomial to count the proper k-colorings of g3 for 1≤k≤5:
In[20]:= | ![]() |
Out[20]= | ![]() |
Confirm that this matches the number of proper colorings returned by FindProperColorings:
In[21]:= | ![]() |
Out[21]= | ![]() |
This work is licensed under a Creative Commons Attribution 4.0 International License