How to calculate the distance between two
cities more than one city away from each other (by direct
connection).
distance(brisbane, sydney, 1000).
distance(sydney, canberra, 400).
distance(canberra, toowoomba, 1200).
distance(toowoomba, brisbane, 200).
for example:
one city away form each other.
oad(X, Y, D) :-
distance(X, Z, D1),
distance(Z, Y, D2),
D is D1+D2.
cities more than one city away from each other (by direct
connection).
distance(brisbane, sydney, 1000).
distance(sydney, canberra, 400).
distance(canberra, toowoomba, 1200).
distance(toowoomba, brisbane, 200).
for example:
one city away form each other.
oad(X, Y, D) :-
distance(X, Z, D1),
distance(Z, Y, D2),
D is D1+D2.