Suppose I color the vertices of a graph properly, and I wish to obtain thertex, where color code for each vertex is defined as a tuple of the color of the vertex along with number of neighbors with each color to the vertex. How do I get at that? Will all_graph_colorings
or first_coloring
help in that: Some pseudo code 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, the double iteration might not produce the tuple that I want as I have mentioned only pairs to be appended to the list l
. Next, 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.