Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can represent colorings as (unordered) set partitions of vertices:

from sage.graphs.graph_coloring import all_graph_colorings
G = Graph([('a','b'),('a','d'),('b','c'),('c','d'),('a','c')])
unique_colorings = { SetPartition(C) for C in all_graph_colorings(G, 3, color_classes=True) }
for C in unique_colorings:
    print(C)

This tells us that there is just one partition:

{{'a'}, {'b', 'd'}, {'c'}}

You can represent colorings as (unordered) set partitions of vertices:

from sage.graphs.graph_coloring import all_graph_colorings
G = Graph([('a','b'),('a','d'),('b','c'),('c','d'),('a','c')])
unique_colorings = { SetPartition(C) for C in set( map(SetPartition, all_graph_colorings(G, 3, color_classes=True) }
color_classes=True)) )
for C in unique_colorings:
    print(C)

This tells us that there is just one partition:

{{'a'}, {'b', 'd'}, {'c'}}