predicates
pathdistance(symbol,symbol,integer).
solve(symbol,symbol,integer).
clauses
pathdistance(a,b,10).
pathdistance(b,c,20).
pathdistance(c,d,5).
pathdistance(d,e,15).
pathdistance(a,d,5).
pathdistance(c,e,10).
solve(X,Z,C):-
pathdistance(X,Z,C).
solve(X,Z,C):-
pathdistance(X,Y,Cost),
solve(Y,Z,C),
Cost is Cost+C.
goal
solve(a,d,Cost).
The answer I wanted for the Cost is the sum of all the C's (total distance) between a and d.The above code is not working, it is not allowing me to take a new variable, Can please somebody do the changes in the above code so that i can get the total distance in Cost.Please keep in mind that I am new to prolog,Thanks!