go:- statistics(runtime,_), top, statistics(runtime,[_,Y]), write('time : '), write(Y), nl. top:- graph( Nodes, Edges), length(Nodes,N), hc(N,Edges). make_domains([],_,_,_). make_domains([X|Y],Node,Edges,N) :- findall(Z, member([Node,Z],Edges),L1), sort(L1,List), make_variable_domain(X,List,N), Node1 is Node+1, make_domains(Y,Node1,Edges,N). make_variable_domain(Var,Successors,Size) :- Var in 1..Size, make_full_list(Size,Full), remove_elements(Successors,Full,Left), remove_constraints(Left,Var). make_full_list(0,[]). make_full_list(N,[N|Rest]) :- N > 0, N1 is N-1, make_full_list(N1,Rest). remove_elements([],R,R). remove_elements([A|B],Current,Left) :- delete(Current,A,Current1), remove_elements(B,Current1,Left). remove_constraints([],_). remove_constraints([A|B],Var) :- Var #\= A, remove_constraints(B,Var). hc( N, Edges ) :- length(Path, N), domain( Path, 1, N), make_domains(Path,1, Edges,N), circuit( Path ), labeling([ff], Path), % labeling_ff_count_backtrack(Path), !, write(Path),nl. delete([],X,[]). delete([X|Xs],X,Xs):-!. delete([X|Xs],Y,[X|Ys]):- delete(Xs,Y,Ys). graph([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60], [[1, 5], [1, 11], [1, 12], [1, 17], [1, 22], [1, 24], [1, 30], [2, 3], [2, 7], [2, 13], [2, 15], [3, 2], [3, 6], [3, 7], [3, 8], [3, 15], [3, 26], [4, 13], [4, 14], [4, 18], [4, 22], [4, 24], [4, 27], [5, 1], [5, 18], [5, 19], [5, 22], [5, 23], [6, 3], [6, 9], [6, 10], [6, 15], [6, 18], [6, 21], [6, 26], [7, 2], [7, 3], [7, 8], [7, 13], [7, 25], [7, 29], [7, 51], [8, 3], [8, 7], [8, 10], [8, 26], [8, 29], [9, 6], [9, 18], [9, 20], [9, 21], [9, 23], [10, 6], [10, 8], [10, 20], [10, 21], [10, 26], [10, 28], [10, 29], [11, 1], [11, 12], [11, 13], [11, 25], [11, 28], [12, 1], [12, 11], [12, 13], [12, 14], [12, 17], [13, 2], [13, 4], [13, 7], [13, 11], [13, 12], [13, 14], [13, 15], [13, 18], [13, 25], [14, 4], [14, 12], [14, 13], [14, 17], [14, 27], [14, 30], [15, 2], [15, 3], [15, 6], [15, 13], [15, 18], [16, 19], [16, 20], [16, 23], [17, 1], [17, 12], [17, 14], [17, 30], [18, 4], [18, 5], [18, 6], [18, 9], [18, 13], [18, 15], [18, 22], [18, 23], [19, 5], [19, 16], [19, 23], [20, 9], [20, 10], [20, 16], [20, 21], [20, 23], [21, 6], [21, 9], [21, 10], [21, 20], [22, 1], [22, 4], [22, 5], [22, 18], [22, 24], [23, 5], [23, 9], [23, 16], [23, 18], [23, 19], [23, 20], [24, 1], [24, 4], [24, 22], [24, 27], [24, 30], [25, 7], [25, 11], [25, 13], [25, 28], [25, 29], [26, 3], [26, 6], [26, 8], [26, 10], [27, 4], [27, 14], [27, 24], [27, 30], [28, 10], [28, 11], [28, 25], [28, 29], [29, 7], [29, 8], [29, 10], [29, 25], [29, 28], [30, 1], [30, 14], [30, 17], [30, 24], [30, 27], [31, 35], [31, 41], [31, 42], [31, 47], [31, 52], [31, 54], [31, 60], [32, 33], [32, 37], [32, 43], [32, 45], [33, 32], [33, 36], [33, 37], [33, 38], [33, 45], [33, 56], [34, 43], [34, 44], [34, 48], [34, 52], [34, 54], [34, 57], [35, 31], [35, 48], [35, 49], [35, 52], [35, 53], [36, 33], [36, 39], [36, 40], [36, 45], [36, 48], [36, 51], [36, 56], [37, 32], [37, 33], [37, 38], [37, 43], [37, 55], [37, 59], [38, 33], [38, 37], [38, 40], [38, 56], [38, 59], [39, 36], [39, 48], [39, 50], [39, 51], [39, 53], [40, 36], [40, 38], [40, 50], [40, 51], [40, 56], [40, 58], [40, 59], [41, 31], [41, 42], [41, 43], [41, 55], [41, 58], [42, 31], [42, 41], [42, 43], [42, 44], [42, 47], [43, 32], [43, 34], [43, 37], [43, 41], [43, 42], [43, 44], [43, 45], [43, 48], [43, 55], [44, 34], [44, 42], [44, 43], [44, 47], [44, 57], [44, 60], [45, 32], [45, 33], [45, 36], [45, 43], [45, 48], [46, 6], [46, 49], [46, 50], [46, 53], [47, 31], [47, 42], [47, 44], [47, 60], [48, 34], [48, 35], [48, 36], [48, 39], [48, 43], [48, 45], [48, 52], [48, 53], [49, 35], [49, 46], [49, 53], [50, 39], [50, 40], [50, 46], [50, 51], [50, 53], [51, 36], [51, 39], [51, 40], [51, 50], [52, 31], [52, 34], [52, 35], [52, 48], [52, 54], [53, 35], [53, 39], [53, 46], [53, 48], [53, 49], [53, 50], [54, 31], [54, 34], [54, 52], [54, 57], [54, 60], [55, 37], [55, 41], [55, 43], [55, 58], [55, 59], [56, 33], [56, 36], [56, 38], [56, 40], [57, 34], [57, 44], [57, 54], [57, 60], [58, 40], [58, 41], [58, 55], [58, 59], [59, 37], [59, 38], [59, 40], [59, 55], [59, 58], [60, 31], [60, 44], [60, 47], [60, 54], [60, 57]]).