i have connections between cities like
connection(London,Sziget).
connection(Sziget,Kairo).
so i want to create a predicate to find if there is a possible route between two cities even passing through other cities first.
Input example: route(London,Kairo).
result: true
Up to this point i have created this recursive code that works.
route(W,Z):-connection(W,Z).
route(W,Z):-connection(W,Y),route(Y,Z).
But i also want to calculate the total cost of the route if the cost between two cities is 100 and for every other city passing is 50 more.
Input example: route(London,Kairo).
result: true 150
Any help appreciated.