Reputation: 11
I have a Java project to make, where I must code a program that will ask the user for the origin and the destination coordinates, then my program should use a .txt file that contains the database for all bus and train stops coordinates in Chicago. Can anyone please help me find the algorithm to create the method that is supposed to decide how many transfers should happen and how to decide which line to take?
Upvotes: 1
Views: 379
Reputation: 4075
This is not a trivial problem at all.
One method you might find useful is pre-processing the data so that it can be represented in the form of a directed graph. You then assign appropriate costs to each leg depending on the desirability of taking that path from the point of view of the user (eg. how much does it cost to travel on the path in terms of dollars, time, distance, etc.) Having done this, you can apply algorithms such as Dijkstra's Algorithm to determine the best path for the user to take.
Upvotes: 2