View source with formatted comments or as raw
    7path(A,A,0). % :-
    8%       edge(A,B,D).
    9
   10path(A,B,D) :-
   11    D .=. D1 + D2,
   12    edge(A,Z,D1),
   13    path(Z,B,D2).
   14
   15edge(a,b,1).
   16edge(a,b,2).
   17edge(a,c,2).
   18edge(a,b,0).
   19edge(c,d,3).
   20edge(d,g,1).
   21edge(a,g,2).
   22
   23min_edge(A,B,D) :-
   24    edge(A,B,D),
   25    not neg_min_edge(A,B,D).
   26
   27neg_min_edge(A,B,D) :-
   28    D1 .<. D,
   29    edge(A,B,D1).
   30
   31
   32min_path(A,B,D) :-
   33    edge(A,B,D),
   34    not neg_min_path(A,B,D).
   35min_path(A,B,D) :-
   36    edge(A,Z,D1),
   37    D .=. D1 + D2,
   38    min_path(Z,B,D2),
   39    not neg_min_path(A,B,D).
   40
   41neg_min_path(A,B,D) :-
   42    D1