Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shortest path between two subway stations in Paris!?

Status
Not open for further replies.

Superi0r1

Programmer
Nov 30, 2010
1
0
0
MK
Hi,

I am quite new to PROLOG and I need to write this program, but I have no ideas. I would be very grateful for any help!

Assignment:
Write predicates in PROLOG to solve the folowing problem:

"To find the shortest path between two subway stations in Paris."

Here is the text file (nodes.txt), where his contents is:
* stationFrom - name of the station from where it starts;
* lineFrom - number of metro line from where it starts;
* stationTo - name of the station to where it will arrived;
* lineTo - number of metro line to where it will arrived;

The specified file should be used to generate facts based on
knowledge. There should be a predicate:

solve(StartStation,EndStation,Path).

Who within the arguments StartStation and EndStation are input and refer to the names of the initial and final station respectively, while Path argument is an output argument and a list of names stations that need to pass to get from home to the final station (in shortest way).

Note: The distances between any two stations that have direct connections are equal.
 
So you should really combine a path-search algorithm that will return a list of nodes with the 'length' predicate that computes the length of a list and voila: you have an algorithm that computes paths.

Path-search algorithms are a very common topic here, if you do a manual search in the last 30 topics, you'll find at least two threads referring to path-searching. You should adapt them to your particular needs described in the file you attached
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top