Created
March 9, 2014 04:05
-
-
Save jordanhudgens/9442783 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sorts | |
#nodes=1..4. | |
#colors={red,green,blue}. | |
predicates | |
node(#nodes). | |
edge(#nodes,#nodes). | |
has_color(#nodes,#colors). | |
rules | |
edge(1,2). | |
edge(2,3). | |
edge(3,4). | |
edge(4,1). | |
edge(2,1). | |
edge(3,2). | |
edge(4,3). | |
edge(1,4). | |
edge(X,Y) :- edge(Y,X). | |
% utilizes disjunction to assign a color to all nodes | |
has_color(N, red) | has_color(N, green) | has_color(N, blue). | |
% this rule states that it is impossible that two neighboring nodes can have the same color | |
:- edge(N1, N2), has_color(N1, C), has_color(N2, C), N1 != N2. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can you write a program in lisp to obtain a graph with M countries such that no adjacent countries has same color using some search trchnique