Question: Write a Prolog program that describes bus routes between cities. Use the predicate connect / 2 to describe the cities between which the bus runs,

Write a Prolog program that describes bus routes between cities. Use the predicate connect/2 to describe the cities between which the bus runs, e.g. connect(saldus,skrunda) and the predicate connect/2, which finds possible connections between two cities, including those that require a transfer. Note. The program may not include inverted routes, e.g. if you have connect(saldus, skrunda) and connect(skrunda, liep\bar (a) ja), then the predicate route(saldus, liep\bar (a) ja) must find connections saldus-skrunda-liep\bar (a) ja and print out the full route the traveler must have, but route(liep\bar (a) ja, saldus) may not find the route. You need to make a logic that will not allow the traveler to visit each city more than one time

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!