
Ryanair, Hamiltonian Cycles, and using graph theory to find cheap flights - jonluca
https://blog.jonlu.ca/posts/ryan-air
======
smartbit
Hacking PNR
[https://media.ccc.de/v/33c3-7964-where_in_the_world_is_carme...](https://media.ccc.de/v/33c3-7964-where_in_the_world_is_carmen_sandiego)
_at time of the talk_ (2 years ago) used/discussed these sites:

[https://matrix.itasoftware.com/](https://matrix.itasoftware.com/) to get
detailed fare rules & restrictions

[https://www.expertflyer.com](https://www.expertflyer.com) &
[https://itunes.apple.com/us/app/seat-
alerts/id533533342](https://itunes.apple.com/us/app/seat-alerts/id533533342)

[https://www.checkmytrip.com/](https://www.checkmytrip.com/) allows entering
name & booking-reference and gives all detail

[https://www.viewtrip.com/](https://www.viewtrip.com/)

[https://tripcase.com](https://tripcase.com) will use name + booking-reference
to get detailed PNR information including the first name

[https://www.fly.kiev.ua](https://www.fly.kiev.ua) can make a flight
reservation without a payment, still gives an 6char booking-reference

~~~
zerowellies
What is the purpose of making a flight reservation without payment?

~~~
candasunal
I am a Turkish citizen, and we need a visa to visit EU member countries. You
are not 100% sure if you will get the visa, so may want to make a flight and
hotel reservation first, and then buy them if you get the visa. So reserving
the tickets is preferred.

~~~
m00dy
I hope this imperative requirement will be revoked anytime soon.

~~~
latchkey
Maybe, but other countries still have it. Vietnamese have one of the worst
passports on the planet. Their govt. won't let them leave without proof that
they will come back, usually in the form of a job, cash in the bank, spouse
and tour or reservation based trips.

------
jd20
Looks cool! The problem of enumerating the best routes between two given
airports is indeed an interesting problem. My favorite discussion of the
problem is from Carl de Marcken:
[http://www.ai.mit.edu/courses/6.034f/psets/ps1/airtravel.pdf](http://www.ai.mit.edu/courses/6.034f/psets/ps1/airtravel.pdf)

I've been involved in solving a similar problem, on the award flight search
side. There are about 12,000 direct commercial routes offering award
redemption, and the airline websites have different limitations: some only let
you search one-way or only round-trip, or only one cabin at a time, or only
give hints about available quantities. So you have to formulate the minimal
set of queries that will give you complete information. And then given an
origin and destination, figure out the valid routings, like you've discovered.

The other really interesting challenge with many of the airline websites are
the extreme measures they go to, to block you from crawling their data. My
favorite is British Airways, which runs 800 different tests to fingerprint
your browser, from generating audio files to drawing to an off-screen canvas,
all inside a custom VM with encrypted byte code. (Similar to how I've seen
Google obfuscate the ReCaptcha code base.) Surprising to hear that Ryanair
makes it so easy to access prices in comparison!

~~~
toast0
Many moons ago, I worked in the travel industry. Most airlines aren't running
their own technology stack -- they are paying someone else $/search to drive
their webpage. In a market of razor thin margins, paying per search for you to
crawl their flight catalog is a big problem -- thus the arms race. The only
way to win at this is to own the catalog, this is why Google bought ITA.

Ryanair is the kind of airline that I would suspect might run their own stack,
and therefore not have the same cost structure.

~~~
namdnay
The only airlines I know of running their own PSS are Emirates and Turkish.
Ryanair are using Navitaire (Amadeus' low-cost subsidiary). To be honest, the
cost structure is the same whether you're running it yourself or outsourcing -
you don't want an absurdly high look to book ratio, or else you're just
wasting server costs

~~~
m00dy
I tried once Turkish Airlines. It was amazing.

~~~
namdnay
I've flown with them a couple of times for leisure and once for work. Honestly
find their economy food is better than most airlines' business food. The
business seats weren't very good though, they're a few years behind the others

------
crikli
Off-topic but related:
[https://scottscheapflights.com](https://scottscheapflights.com) is _amazing_.
The Premium sub is worth every penny...my wife and I will be doing a ton more
overseas travel in 2019 purely because of the deals this site finds.

~~~
micahgoulart
I got into churning airline miles then manufactured spending (generating spend
on credit card to earn miles) and now have over 10 million miles. I also heard
one of the biggest groups of manufactured spend are developers within Google.

I belong to a private slack with over 80 folks doing this as a hobby so we can
do first class/business class international travel and hotel stays for free.

If anyone is into it as as well and would like to join a private Slack and
contribute, hit me up. A big majority of the group are engineers.

NOTE: this group is for advanced folks only who have been doing this for a
while. Think "r/churning level 2"

~~~
barbadosmercury
Hey,

i'd be interested as well. could you add me to the slack? thank you

barbadosmercury@protonmail.com

------
SmellyGeekBoy
If nothing else, at least I learned from the comments here that most of HN
seem to be working on their own competing flight search engines ;)

~~~
yosito
If you want something done right, you have to do it yourself. I spent several
hours last night trying to find cheap routes starting from Rio in January and
ending up in the Carribean in February. I don't mind stopping a few places in
between and spending some time there, I just want the cheapest flights
available. Turns out that information is really hard to find without computing
it yourself.

------
abhisuri97
As a CS student, I agree it is really refreshing to see basic graph algorithms
to be used in a practical, non academic/industry context. I never really see
these basic algorithms used in small side projects, so thank you for this!

------
whazor
We (me and friend) are working on the same problem, however we are stuck at
the next step. Namely the user interface: how do you let the user search
through all the possibilities.

We created some data structures that allow almost instant searching of such
routes and we have scrapers running regularly on Ryanair, easyJet, wizzair,
and Transavia. You can query the algorithm here:
[https://algo.tripchemy.com/routes/TSF?year=2019&month=02&day...](https://algo.tripchemy.com/routes/TSF?year=2019&month=02&day=10&length=20)

Where you want to have a trip of 20 days (4 lovatons, 5 flights) from 10 Feb.
Starting and returning to TSF. We also added some scoring for niceness of
airports.

~~~
seszett
What I've been missing is not so much finding the best routes between two
airports, but finding the best (ie. least expensive) route from a bunch of
departure airports to a number of destination airports.

If I'm in Antwerp, I really don't care much if I have to depart from/return to
Brussels Zaventem, Charleroi or Eindhoven, it just doesn't matter. And if the
fare is sufficiently cheaper, then Amsterdam, Düsseldorf, Beauvais or Paris is
fine too. And I don't have to return to the airport I left from. Typically
it's the same for my destination in the case of holidays.

But I still haven't found websites which allowed to do that easily, apart from
Google Flights maybe.

~~~
older
azair.eu does it.

~~~
ljcn
This looks perfect!

------
warp_factor
back when I was a student, I would sometimes spend hours on Ryanair's website
to find that type of deals.

My base was Paris and I wanted to go to Stockholm for example. The direct
Ryanair flight from Paris to Stockholm was expensive (Let's say 150 euros). I
would manage to find two cheap flights that go for example from Paris to Rome
and another one from Rome to Stockholm, both of those for 10 Euros each. The
key is to use the big Ryanair hubs as gateway (Milan and Brussels would work
really well back in the days)

I would basically lose my whole day traveling to save 80 euros. Sometimes it
backfires though, and when it backfires you are on your own. Once my first
flight got super delayed, and I got stuck in Milan for the night. I managed to
have Ryanair rebook my second flight for the day.

I think Ryanair wants to be able to propose high prices for direct flights and
prevent people from finding those cheaper indirect flights. That's why they
don't make it easy to find them.

~~~
fyfy18
Most comparison sites will show you these routes, for example Kiwi lets me
search indirect flights from where I am in a remote part of Spain to where I
live the other side of Europe. There's no direct routes, but it gives me the
option of connecting in Barcelona, Stansted or Hahn, or cheaper options if I
want more that one stop. It also lets me search a whole month to find the
cheapest flights in a given time period, and will provide options with
different low-cost airlines if that's cheaper.

However if you book direct through these sites you are going to get the lowest
ticketing class. With Ryanair that means you can't take anything more than a
small bag onboard (since November you need to pay for a 10kg cabin bag, you
can't drop it at the gate for free), and if you are in a group you will not be
sitting next to each other, so it may be best to book directly through the
airline's site.

The simple reason why Ryanair don't let you book multi-leg flights directly is
because they don't want to be responsible for you missing a connection. It's
ironic though, as compared to national European airlines I find their
punctuality a lot better.

~~~
namdnay
There are several other reasons for not wanting to handle connections,
including complexity of IT systems, negotiations with airports (bag transfer
is more complicated), and general airline processes. I imagine they will end
up doing it, Easyjet have started to act as feeders for global airlines - it's
a clever idea

------
mtrovo
I use [https://airwander.com/](https://airwander.com/) when flying overseas, I
don't know how well it works for low cost airlines though.

It's a flight search engine that let you filter what connections there are
between the cities you want to travel and help you book a single flight that
is going to stay there as a stopover. Sometimes it finds some weird flights
that doesn't make any sense if you're just trying to reach your destination
but if you're just traveling it's quite nice.

Last time I used it I found a overseas flight that stopped in Lisbon but on
the way back made a connection in Bologna that was +200 cheaper then the
normal flight.

~~~
jayalpha
Airwanderer would be something I have been looking for a long time but it does
not seem to work so well. Also, is it just my browser or why is it so
difficult to see the layovers? I have to click on "fight details" to see this.
Why?

[http://www.cleverlayover.com](http://www.cleverlayover.com) also never worked
for me. Good idea, bad executed.

Regarding travel websites, you may want to check out:

[https://www.kiwi.com](https://www.kiwi.com) Sometimes finds insane travel
routes.

[http://www.vayama.com](http://www.vayama.com) Lets me sometimes stay in
Ethiopia for free a day when I fly from Asia to Europe. Does not show up on
any other website I consult.

I have also had luck at times with

[http://www.opodo.com](http://www.opodo.com)

[http://www.expedia.com](http://www.expedia.com) (yes, sometimes an old dog
still does the trick)

------
shoyer
This article misses the most obvious way to visualize this graph: put it on a
map!

~~~
jonluca
I actually wanted to do that but thought the cost/benefit wasn't high enough -
I'd pretty much need to manually place all the airports information on the map
if I wanted to use the library I was using (Cytoscape).

Visualizing the DFS at the last step was good enough :) Maybe in the future!

~~~
ddalex
you don't need to do that - just download
[https://openflights.org/data.html](https://openflights.org/data.html), and
plot airport x/y to airport lat/lon directly. Since you're doing only Europe,
you don't need to do the sin/cos math do get an accurate projection

------
catchmeifyoucan
Great work, this is really cool!

For multi city flights, I've found Google flights does things really well from
a UX standpoint, and I believe they support Ryanair.

~~~
jnurmine
Google Flights is generally fine. But sometimes it figures out quite fringe
stuff like Stockholm-Dublin roundtrip with a 17 hour layover in Dubai. It was
not cheap either. Sounded like something like a global minima.

~~~
bogomipz
>"Google Flights is generally fine. But sometimes it figures out quite fringe
stuff like Stockholm-Dublin roundtrip with a 17 hour layover in Dubai."

Honestly I regularly see these type of ridiculous options on all of the major
travel sights as well as stuff like 3 and 4 layovers. Do you have any insight
on why this happens or what such absurd results are even presented? I
regularly see things like 54 hour travel time for for international flights.

------
kasparsklavins
Why is there no interface that allows searching for flights without specifying
_exact_ dates? All I want to do is fly from A to B to A. Maybe stay a week,
maybe two. I'm flexible - it doesnt have to be exactly N days starting on the
M'th.

Even services that "allegedly" advertise they have that, still require
manually clicking every day combination.

I'd fly more often _if it was easy_. The few times I tried, it would be just
faster to drive than go through all possible 900+ day combinations.

~~~
crazygringo
Have you seen a site that does that really well, UX-wise?

I'd assume it's two reasons: first that it's hard to get the UX right. There
are going to wind up being so many combinations of possibilities that I'm not
sure how you'd even sort them in a meaningful way. (E.g. it's unlikely price
from lowest to highest will be the most meaningful, the lowest price alone
might wind up having 100 different date combinations, so figuring out how to
present the options in a meaningful way might just be something we haven't
figured out yet.)

But second, it might just be too computationally expensive. You see how slow
sites already are just for searching a single date, because there are so many
possible combinations of connections to consider, and so many fare rules to
calculate prices out of. Now a 2-week range for both start and end results in
taking almost 200 times longer. It just might not be feasible, or worth the
programming effort. I remember a blog post a long time ago from Kayak (I
think?) talking about the insane effort that was required to cache flight
fares just so show simple fare comparisons across a few days... and it only
worked for the flights that were more commonly searched for.

~~~
RussianCow
adioso.com (no longer maintained as far as I can tell, but still online) does
a really great job of this, UX-wise. It lets you create searches like
"departing anywhere between February 10 and March 20 for about 2 weeks", and
allows you to filter destinations by continent/region, which gives you a ton
of flexibility. They then allow you to choose a destination (showing what I
assume is the lowest price found per destination), and then let you sort the
actual flights by cheapest, fastest, and "best" (a combination of price,
duration, and number of stops).

I think the computational cost is a far bigger problem for these kinds of
services than the UX.

------
thomasahle
Finding a cycle of a given length can actually be done in time `O(e^k n^2.3)`
where `k` is the length of the cycle, using the cool technique of color
coding.

Basically, to find a cycle of length 6, you repeatedly color every node in one
of 6 colors at random. Then you look for a cycle with all different colored
nodes, which can be done efficiently using dynamic programming.

You succeed in finding a particular 6 cycle exactly if each node in it has
gotten a different color, but the chance of this is not bad. In the case of
the OP it's even better, since there are probably many such cycles to find.

------
frakkingcylons
Somewhat off-topic and shameless plug, I'm working on a meta flight-search
engine that finds the cheapest flights from multiple origins to the same
destination (i.e. me and some friends who live in another city want to fly to
Hong Kong with no particular date in mind, just want the cheapest flights and
with overlapping departure/return dates). Does anyone else have a similar need
or know of anything that can do this?

------
blackdogie
A nice handy tool. It would be great if the airline added this themselves for
finding route. Great work

------
vool
@jonluca

If you are looking to take this further, you can find some more info on
Ryanair API endpoints here:

[https://gist.github.com/vool/bbd64eeee313d27a82ab](https://gist.github.com/vool/bbd64eeee313d27a82ab)

------
rexarex
That’s awesome

------
jaycolson
ryan air weekend flight search ... pretty handy

[https://github.com/cloudsquall/flightsearch](https://github.com/cloudsquall/flightsearch)

------
zabaki
Now i just gotta figure out all the airport abbreviations D:

------
maa5444
it's cheap maybe it's not a fake the fact they spray the sky

