882 karma · joined January 4, 2015
Shortwave: https://shortwave.com Personal: https://jwn.gr
[1] https://github.com/jwngr/sdow/blob/master/website/src/resour...
[1] https://github.com/jwngr/sdow/blob/f39398d112fecf7b993c64bd4... [2] https://github.com/jwngr/sdow#data-source
> I was expecting the site to tell me how to start at page X and get to page Y with the min number of clicks.
Yup, this is exactly what the site does, and a bi-directional BFS is an efficient way to do it. The special thing about my bi-directional BFS is that I follow outgoing links when searching from the source page while following incoming links when searching from the target page[1].
> I did notice that someone pointed out that they get different results by swapping the order of X and Y. This seems pretty surprising?
This is expected, because it is a directed graph, with the links on Wikipedia being in one direction. Just because page A links to page B doesn't mean page B links to page A.
[1] https://github.com/jwngr/sdow/blob/master/sdow/breadth_first...
[1] https://github.com/jwngr/sdow/blob/master/website/src/compon...
[1] https://github.com/jwngr/sdow/blob/f0b5a9ebe47ea0eca49d8220a...
[1] https://www.sixdegreesofwikipedia.com/?source=Facebook&targe... [2] https://www.sixdegreesofwikipedia.com/?source=Narcissism&tar...
[1] https://github.com/jwngr/sdow/commit/b9164b4455661d7775aeb78...
[1] https://github.com/jwngr/sdow/commit/6e42e06488a592784e5d3d2...
[1] https://github.com/jwngr/sdow/commit/6e42e06488a592784e5d3d2...
[1] https://github.com/jwngr/sdow/commit/6e42e06488a592784e5d3d2...
So, the website files are hosted on Firebase while the backend is hosted on GCE. The database is actually not hosted; it's just a SQLite file stored on my GCE instance.
[1] https://github.com/jwngr/sdow#database-creation-process [2] https://lists.debian.org/debian-kernel/2017/12/msg00265.html
Every time a query is made, a bi-directional breadth-first search[3] is run which uses the |-separated incoming and outgoing links and runs a fairly standard BFS algorithm. A lot of the hard work was precomputed, which minimizes the number of required database queries and makes each search respond fairly quickly.
[1] https://github.com/jwngr/sdow/blob/master/database/buildData... [2] https://github.com/jwngr/sdow#database-creation-process [3] https://github.com/jwngr/sdow/blob/master/sdow/breadth_first...
[1] https://github.com/jwngr/sdow/blob/a2699dc95d884ec64a4641630... [2] https://github.com/jwngr/sdow/blob/a2699dc95d884ec64a4641630...
And yes, the graph is not connected (there are both nodes with no outgoing links and with no incoming links), but over 99% of the pages are connected, so the answer would still be interesting and worthwhile.