FlyerTalk Forums - View Single Post - Reverse Google Flights
View Single Post
Old Feb 20, 2023 | 9:20 pm
  #15  
beamerbenzbentli
30 Countries Visited
1M
60 Nights
5 Years on Site
 
Join Date: May 2020
Location: USA
Programs: Tribe 54 Sweat Lodge 12
Posts: 128
Originally Posted by Ragnarok
For technical side of things -
A One-to-Many relationship is easier to cache than a Many-to-Many relationship. (Airfares varies by point of sale for the same trip)
Obviously, it is doable. Just that it is more costly computationally.
OP isn't asking for many-to-many; he said 1 destination airport from any origin, which is still one-to-many, or many-to-one inversely, so the difficulty isn't due to exponential edges complexity.

The real reason why it's harder is because airplane routes are a digraph. It's much easier to traverse in search of child nodes than it is to be given a child node and asked for its parent. Short of using DP, you'd have to traverse the ancestor-descendant path twice per ancestor node. If you were to visualize it, it'd look like the mythical world tree with countless roots turning each tip into yet another mirrored world tree until it refinds the starting descendant.

Easy example for other laymen:
A____B___C
^\\v ^||v v//^
_____D
  • If I start from B as the origin, and I want to find all the possible destinations, I traverse to D, then from D to A & C. This is enough to prove that A, D, and C are destinations from B.
  • If I start from B as the destination, and I want to find all the possible origins, I go to D. I can confirm D is an origin because I take the directed path back to B, which proves this is an origin-destination relationship of D->B. I now go from D to A. To prove that A is an origin (A->B), I must traverse, WLOG, from A back to D back to B. The same goes for C.

Last edited by beamerbenzbentli; Feb 20, 2023 at 9:39 pm
beamerbenzbentli is offline