Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Algorithm Optimization - Shortest Route Between Multiple Points

Tags:

People also ask

Which algorithm will you use to determine the shortest path between?

Dijkstra's algorithm (/ˈdaɪkstrəz/ DYKE-strəz) is an algorithm for finding the shortest paths between nodes in a graph, which may represent, for example, road networks. It was conceived by computer scientist Edsger W. Dijkstra in 1956 and published three years later.

How do you find the shortest path between two points?

Look at all nodes directly adjacent to the starting node. The values carried by the edges connecting the start and these adjacent nodes are the shortest distances to each respective node.

Which of the following algorithms should he use to determine the shortest path with an aim to minimize the mileage?

Dijkstra's Algorithm finds the shortest path between a given node (which is called the "source node") and all other nodes in a graph.


Problem: I have a large collection of points. Each of these points has a list with references to other points with the distance between them already calculated and stored. I need to determine the shortest route that begins from an origin and passes through a specific number of points to any destination.

Ex: I'm on vacation and I'm staying in a specific city. I'm making a ONE WAY trip to see ANY four cities and I want to travel the least distance possible. I cannot visit the same city more than once.

Current solution: Right now I'm just iterating through every possibility manually and storing the shortest path. This works but feels inefficient. Also, this problem will eventually be expanded to include searching from multiple origin points to multiple destination points, so I think that might explode the search space.

What is the better way to search for the shortest route?