Question: Complete this PROLOG program to find a path on the map in Figure 3.2 between any pair of cities. Be sure the path you find

Complete this PROLOG program to find a path on the map in Figure 3.2 between any pair of cities. Be sure the path you find is acyclic, i.e., has no loops like [a,s,r,p,c,s,r,b]. adjacent(a,t). adjacent(a,s). adjacent(a,z). adjacent(s,o). adjacent(s,f). adjacent(s,r). adjacent(o,a). adjacent(f,b). adjacent(r,p). adjacent(p,b). %path(P,Start,Goal) means P is a path from Start to Goal path([X,Y],X,Y):-adjacent(X,Y). path([X,Y],X,Y):-adjacent(Y,X). path([Goal],Goal,Goal). path([Start|[Head|Tail]],Start,Goal):-adjacent(Start,Head),path([Head|Tail],Head,Goal). Name your program PATH.pl. Hint: PROLOG checks predicates in order, so choose the order carefully.

Complete this PROLOG program to find a path on the map in

Oradea Neamt 87 Zerind 151 75 Iasi Arad 140 92 Sibiu Fagaras 118 Vaslui 80 Rimnicu Vilcea Timisoara 142 211 Pitesti Lugoj 97 70 98 Hirsova Mehadia 146 101 85 Urziceni 86 75 138 Bucharest Drobeta 120 90 Craiova Eforie Giurgiu Figure 3.2 A simplified road map of part of Romania Oradea Neamt 87 Zerind 151 75 Iasi Arad 140 92 Sibiu Fagaras 118 Vaslui 80 Rimnicu Vilcea Timisoara 142 211 Pitesti Lugoj 97 70 98 Hirsova Mehadia 146 101 85 Urziceni 86 75 138 Bucharest Drobeta 120 90 Craiova Eforie Giurgiu Figure 3.2 A simplified road map of part of Romania

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 Databases Questions!