Downloadable ContentDownload PDF
This work is an implementation of the Christofides Algorithm for the travelling salesman problem in an application. Consider, a person running errands. If they go about it in an intuitive manner, it may happen that the person may find themselves going back to the same part of town unnecessarily, missing out on certain high priority tasks or taking too long. This application will assist with the job of planning by generating an efficient path to follow. Considering the locations to visit as nodes and the paths between them as weighted edges, we create a graph for the Christofides algorithm to process. It uses Google API Google Distance Matrix to get the distances and durations between the nodes, i.e. the weights of the edges. OkHttp library is used to send and receive the HTTP network requests to the Google Distance Matrix API. GSON, Google's JSON processing library is used to process the JSON response obtained from the API. The Christofides algorithm processes this graph and generates a sequence of errands for the user to follow. The sequence is passed to the Google Maps Directions API and is shown on a Google map. The main purpose of the application is to generate an efficient sequence of errands for the user. The application will also display the total time of the trip. The total distance travelled will also be shown. The user will be able to input estimated time at each business and also a priority order for each node. If the estimated time of the trip is too long for the user, the application may suggest some low priority locations and/or errands that will require more time than the others. The user may elect to then drop some tasks and run the application again. A choice of mode of transport i.e. driving, walking, bicycling is offered to the user. The user may specify restrictions such as avoid tolls or highways and these may be considered by the Google Distance Matrix API while calculating the distance between the nodes. The path to be followed is highlighted on the map as are the roads to be followed to get from one node to the next. The addresses of each node as resolved by the geocode are displayed as labels of the map marker and also in the EditText field where the user has originally entered the query.