/* Global constraint clique in SWI Prolog From Globals constraint catalogue: http://www.emn.fr/x-info/sdemasse/gccat/sec4.49.html """ Consider a digraph G described by the NODES collection: to the ith item of the NODES collection corresponds the ith vertex of G; To each value j of the ith succ variable corresponds an arc from the ith vertex to the jth vertex. Select a subset S of the vertices of G that forms a clique of size SIZE_CLIQUE (i.e., there is an arc between each pair of distinct vertices of S). Example [The graph is 1 -> 2,4 2 -> 1,3,5 3 -> 2,5 4 -> 1,5 5 -> 2,3,4 ] (3,​< index-1 succ-{},​ index-2 succ-{3,​5},​ index-3 succ-{2,​5},​ index-4 succ-{},​ index-5 succ-{2,​3}​ > ) The clique constraint holds since the NODES collection depicts a clique involving 3 vertices (namely vertices 2, 3 and 5) and since its first argument SIZE_CLIQUE is set to the number of vertices of this clique. """ Model created by Hakan Kjellerstrand, hakank@gmail.com See also my SWI Prolog page: http://www.hakank.org/swi_prolog/ */ :- use_module(library(clpfd)). :- use_module(hakank_utils). %% %% Test the problem instances and find all or just the maximum cliques. %% It also generates a random graph. %% go :- writeln("Find all cliques"), find_all_cliques(1), find_all_cliques(2), find_all_cliques(3), writeln("\nFind just the largest cliques"), find_all_largest_cliques(1), find_all_largest_cliques(2), find_all_largest_cliques(3), %% now try a random problem N = 70, format("\nTry a random problem of size ~d~n",[N]), generate_problem(N,G), time(clique(G,Clique,Card,_)), writeln(clique=Clique), writeln(cardinality=Card), nl. %% %% Problem instance #4 is a 100x100 matrix and will take some %% time to calculate. %% %% Find just the largest cliques %% %% Problem 4 %% numNodes=100 %% [[33,43,59,78,86,94],6] %% numNodes=100 %% [[33,43,59,78,86,94],[42,43,59,85,86,94],[42,43,59,78,86,94],[33,39,43,78,86,94]] %% % 403,391,440 inferences, 27.535 CPU in 27.535 seconds (100% CPU, 14650359 Lips) %% go2 :- N = 4, writeln("\nFind just the largest cliques"), time(once(find_all_largest_cliques(N))), nl. %% %% Generate a graph of size N and find all the largest cliques %% go3 :- N = 60, format("Generate a random graph of size ~d and find all largest cliques~n", [N]), generate_problem(N,G), writeln("Graph generated."), once(clique(G, Clique,Card,max)), writeln([Clique,Card]), writeln("\nFind all cliques of this size"), time(findall(Clique2, clique(G, Clique2,Card,_), L)), length(L,Len), writeln(L), format("The graph has ~d clique(s) of size ~d\n", [Len,Card]). %% %% This is slow... %% go4 :- writeln("Find all cliques"), find_all_cliques(4), nl. %% %% This is experimental: %% Given a clique, generate a graph with this clique. %% Note: It just handles one clique per call to clique/4, but as we %% see, calling more times with a other cliques seems to work. %% %% Note: The generated graph is probably not unique due to the %% the nature of how cliques works. I.e. there might be %% some random connections in the graph that is not in %% in a clique. %% %% The recreation of problem #2 yield this graph: %% [0,1,1,0,0,0,0,0,0,0] %% [1,0,1,0,0,0,0,0,0,0] %% [1,1,0,0,0,0,0,0,0,0] %% [0,0,0,0,1,1,0,0,0,0] %% [0,0,0,1,0,1,0,0,0,0] %% [0,0,0,1,1,0,1,1,1,1] %% [0,0,0,0,0,1,0,1,1,1] %% [0,0,0,0,0,1,1,0,1,1] %% [0,0,0,0,0,1,1,1,0,1] %% [0,0,0,0,0,1,1,1,1,0] %% %% This is essentially the same as graph #2. %% go5 :- writeln("Recreate a graph with a clique [1,2,3]"), new_matrix(4,4,0..1,G1), Clique1 = [1,2,3], %% length(Clique1,Card), clique(G1,Clique1,Card1,_), flatten([G1,Card1],Vars1), labeling([],Vars1), maplist(writeln,G1), %% Trying to recreate problem #2 with 3 cliques writeln("\nRecreate problem 2"), new_matrix(10,10,0..1,G2), Clique2 = [6,7,8,9,10], Clique2b = [1,2,3], Clique2c = [4,5,6], clique(G2,Clique2,_,_), clique(G2,Clique2b,_,_), clique(G2,Clique2c,_,_), flatten(G2,Vars2), labeling([],Vars2), maplist(writeln,G2), %% And then we check that we got back the same %% cliques (and some more sub cliques). writeln("And then we check it. It should be about 45 cliques"), findall(Clique3,clique(G2,Clique3,_,_),All3), length(All3,All3Len), writeln(All3), format("It was ~d cliques~n",[All3Len]), nl. %% %% First get for the cardinality of the largest clique, %% then get all clique of this cardinality. %% find_all_largest_cliques(Problem) :- format("~nProblem ~d~n", [Problem]), %% get the graph for the problem problem(Problem, G), clique(G, Clique,Card,_), writeln([Clique,Card]), findall(Clique2, clique(G, Clique2,Card,_), L1), writeln(L1). %% %% find all cliques for a problem %% find_all_cliques(Problem) :- format("~nProblem ~d~n", [Problem]), %% get the graph for the problem problem(Problem, G), findall(Clique, clique(G,Clique,_Card,max), L), length(L, Len), writeln(length=Len), ( Len < 46 -> writeln(L) ; format("Length ~d is too large to show~d",[Len]) ), nl. %% %% generate a problem of size N. %% generate_problem(N, Matrix) :- numlist(1,N,Is), maplist(generate_problem_(N),Is,Matrix). generate_problem_(N, _, Row) :- findall(R, (between(1,N,_), random_between(0,1,R) ), Row). %% %% clique(G, Clique, Card, Type) %% %% Find a clique in graph G with cardinality Card. %% Type: - 'all': yield any solution %% - ground(Card): yield a solution with cardinality Card %% - else: optimize Card (max Cardinality) %% %% As we see in go5/0, clique/4 is reversible (at least kind of). %% clique(G, Clique, Card, Type) :- length(G,NumNodes), %% The found clique (as 0..1) %% This will be converted to a node list after solve. length(CliqueBool, NumNodes), CliqueBool ins 0..1, %% cardinality of the clique sum(CliqueBool,#=,Card), Card in 1..NumNodes, %% If there is a connection between nodes I and J (I \= J) then %% there should be a node from I to J. numlist(1,NumNodes,Is), numlist(1,NumNodes,Js), maplist(connection_nodes(G,CliqueBool,Js),Is), %% What we do depends on the modes of the call: %% If Type = all or Card is ground (i.e. the cardinality is instantiated) %% then we show all cliques (of this cardinality). %% Else we search for the largest clique. flatten([CliqueBool,Card], Vars), ( (Type == all ; ground(Card)) -> labeling([ffc,down],Vars) ; labeling([ffc,down,bisect,max(Card)], Vars) ), %% Translate boolean -> numbers findall(I, (between(1,NumNodes,I), nth1(I,CliqueBool,1) ), Clique). %% %% This is kind of backward logic but it is the whole thing, %% and it works: %% If there is a connection between nodes I and J (I \= J) then %% there should be a node from I to J. %% connection_nodes(G,Clique,Js,I) :- nth1(I,Clique,CI), maplist(connection_nodes_(G,Clique,I,CI),Js). connection_nodes_(G,Clique,I,CI,J) :- (I #\= J -> matrix_element5(G,I,J,GIJ), nth1(J,Clique,CJ), (CI + CJ #= 2) #==> (GIJ #> 0) ; true ). %% %% Data %% % % Two cliques: (1,2,4) and (3, 5) % problem(1, M) :- M = [[1, 1, 0, 1, 0], [1, 1, 0, 1, 0], [0, 0, 1, 0, 1], [1, 1, 0, 1, 0], [0, 0, 1, 0, 1]]. % % A larger graph % The cliques are % 1,2,3 % 4,5,6 % 6,7,8,9,10 % (and their sub cliques) % problem(2, M) :- M = [[1, 1, 1, 0, 0, 0, 0, 1, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 1, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 1], [0, 1, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 1, 1, 1, 1], [0, 0, 1, 0, 0, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1, 1, 1, 1, 1], [0, 0, 0, 0, 1, 1, 1, 1, 1, 1], [0, 1, 0, 0, 0, 1, 1, 1, 1, 1]]. % The graph from the Global Constraint catalogue (the example above) % % 1 -> 2,4 % 2 -> 1,3,5 % 3 -> 2,5 % 4 -> 1,5 % 5 -> 2,3,4 % % The found clique (N=3) is {2,3,5}. % problem(3,M) :- M = [[1,1,0,1,0], [1,1,1,0,1], [0,1,1,0,1], [1,0,0,1,1], [0,1,1,1,1]]. % % A random graph of size 100 (generated by another program). % There are 3515 clique of size >= 3 (including sub cliques], % and four of size 6. % problem(4, M) :- M = [[0,0,1,0,1,0,1,0,0,1,0,1,0,1,1,1,1,0,1,0,0,1,0,1,1,0,1,0,0,0,1,0,1,1,0,1,1,1,0,0,0,1,0,1,1,0,1,0,1,1,0,1,1,0,0,1,0,1,1,1,1,1,1,0,1,0,0,1,1,0,1,1,1,1,1,0,0,1,0,0,0,1,1,1,1,1,1,0,0,1,1,1,0,0,0,1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