Color coding the colorings dictionary in graph_colorings
Suppose I color the vertices of a graph properly, and I wish to obtain the color code for each vertex, where color code for each vertex is defined as a tuple of the color of the vertex along with number of neighbors corresponding to each color to some vertex. How do I get at that? Will all_graph_colorings
or first_coloring
help in that: Some pseudo code using first_coloring
beginning would be:
from sage.graphs.graph_coloring import first_coloring
G = graphs.WheelGraph(5)
d=first_coloring(G, 5)
l=[]
for i in G.vertices():
for j in G.neighbors(i):
l.append(d[i],d[j])
return l
In the above code, I think there are several problems. First of all, the first_coloring
does not cover all possible colorings and is a list and not a dictionary. The all_graph_colorings
though gives a dictionary, but I am unsure of how to access the elements there. Next, the double iteration might not produce the tuple that I want as I have mentioned only pairs to be appended to the list l
. Again, on running the code, I get the error append
method only takes one argument and two are given. How do I fix that? The color code concept is inspired from the irregular chromatic number of the graph explained in some detail here. Any ideas? Thanks beforehand.