Skip to content

Instantly share code, notes, and snippets.

@jordanhudgens
Created March 9, 2014 04:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jordanhudgens/9442783 to your computer and use it in GitHub Desktop.
Save jordanhudgens/9442783 to your computer and use it in GitHub Desktop.
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.
@kesh12340
Copy link

kesh12340 commented May 12, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment