From a406cb43bd905a550c426963e595f8c82b5e8bcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Sun, 8 Apr 2018 20:28:04 +0200 Subject: [PATCH] Update graph coloring example with placeholders This replaces the former graph coloring example with a new formulation that makes use of the newly supported placeholders. --- examples/graph-coloring.lp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/examples/graph-coloring.lp b/examples/graph-coloring.lp index 8b7487c..de5d382 100644 --- a/examples/graph-coloring.lp +++ b/examples/graph-coloring.lp @@ -1,12 +1,9 @@ -colored(V, red) :- vertex(V), not colored(V, green), not colored(V, blue). -colored(V, green) :- vertex(V), not colored(V, red), not colored(V, blue). -colored(V, blue) :- vertex(V), not colored(V, red), not colored(V, green). +#external color(1). +#external edge(2). +#external vertex(1). +#show color/2. -:- edge(V1, V2), colored(V1, C), colored(V2, C). - -vertex(a). -vertex(b). -vertex(c). - -edge(a, b). -edge(a, c). +{color(V,C)} :- vertex(V), color(C). +covered(V) :- color(V, _). +:- vertex(V), not covered(V). +:- color(V1,C), color(V2,C), edge(V1,V2).