D(a, b) Min= 1 :- G(a, b); # Connected by an edge => distance 1.
D(a, c) Min= D(a, b) + D(b, c); # Triangle inequality.
It will be much harder to read with SQL CTE.
It can also computed over weighted graphs, which is impossible or extremely hard with SQL. @AttachDatabase("db_prefix", "your_file.db");
# Then you can query from it:
Q(..r) :- db_prefix.YourTable(..r);
You can query multiple columns of course. Feel free to start threads in Discussions of the repo with whatever questions you have!