My count_rect_paht/3 calls directly count_udg_path, and
the latter is for general undirected graphs, in particular, does not assume planarity like the rectangular grid graph.
This query is for path counting in complete graph K(n). n=13 seems max for test. It is well-known that complete graph K(n) with n nodes is not planar for n >= 5.
% ?- time((between(2, 13, N), findall(I-J, (between(1, N, I), K is I + 1, between(K, N, J)), E),
% udg_path_count(1-N, E, C), writeln(count_path_of_K(N)=C), fail)).
%@ count_path_of_K(2)=1
%@ count_path_of_K(3)=2
%@ count_path_of_K(4)=5
%@ count_path_of_K(5)=16
%@ count_path_of_K(6)=65
%@ count_path_of_K(7)=326
%@ count_path_of_K(8)=1957
%@ count_path_of_K(9)=13700
%@ count_path_of_K(10)=109601
%@ count_path_of_K(11)=986410
%@ count_path_of_K(12)=9864101
%@ count_path_of_K(13)=108505112
%@ % 1,364,231,392 inferences, 61.385 CPU in 63.662 seconds (96% CPU, 22224211 Lips)
%@ false.