| 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'}}
| 2 | No.2 Revision |
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'}}
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.