Flight Schedule Algorithm

I have a list of all direct flights. From this I want to get flights from A to B using connections. What would be the appropriate algorithm or data structure for this problem? Thank.

+3
source share
3 answers

Basically, it is a matter of passing the graph, where each departure or arrival will be a node, and each flight will be an edge. You usually apply costs around the edges - depending on the user's preferences, the β€œcost” may be the cost of the ticket (to get the lowest price) or flight time (to get the shortest flight time). Arrivals and departures at the same airport will be connected by an edge whose cost is downtime (and from the point of view of price, this edge will usually cost zero).

+6
source

. - . , , , . A B , , . .

(.. node, , ); NxN- ( N ) (i, j) node node j.

. , node A node B. , , .

+2

Classic problem The shortest path problem . If you look at the algorithms, there are several options listed on the Wikipedia page, otherwise there are algorithms such as ACO are parameters, but it depends on the use case and the way the solution is provided.

For clarity, note that this is a variation of the traveling salesman problem , and the result is NP-complete .

+1
source

Source: https://habr.com/ru/post/1728221/


All Articles