2018-04-22 22:26:17 +02:00
|
|
|
|
% assign a set of colors to each vertex
|
2018-04-11 21:34:33 +02:00
|
|
|
|
{color(V, C)} :- vertex(V), color(C).
|
2018-04-22 22:26:17 +02:00
|
|
|
|
|
|
|
|
|
% at most one color per vertex
|
|
|
|
|
:- color(V, C1), color(V, C2), C1 != C2.
|
|
|
|
|
|
|
|
|
|
% at least one color per vertex
|
2018-04-08 20:28:04 +02:00
|
|
|
|
covered(V) :- color(V, _).
|
|
|
|
|
:- vertex(V), not covered(V).
|
2018-04-22 22:26:17 +02:00
|
|
|
|
|
|
|
|
|
% adjacent vertices don’t share the same color
|
2018-04-11 21:34:33 +02:00
|
|
|
|
:- color(V1, C), color(V2, C), edge(V1, V2).
|
2018-04-22 22:26:17 +02:00
|
|
|
|
|
|
|
|
|
#show color/2.
|
|
|
|
|
|
|
|
|
|
#external vertex(1).
|
|
|
|
|
#external edge(2).
|
|
|
|
|
#external color(1).
|