How can anyone get married in Hong Kong Science Park?

The other day, I was going to pick up my lunch at the Science Park Fairwood when I saw a woman in nuptial attire holding a bouquet of flowers in a fancy restaurant. While the decor of the restaurant was stylish and elegant and looked pretty weddingish, I was still amazed to see a wedding reception actually taking place in the Science Park. Well, below I shall demonstrate how to go from science to wedding in four steps, though there’s some devilry and a bit of sport involved.

First, grab a thesaurus. Then for each headword listed, union it with each of its related words (with a union-find data structure). Now let’s test if find(‘science’) equals find(‘wedding’). If it does, congratulations! You’ve just jumped to wedding from science. If not, you might want to try a different thesaurus.

Well, in my case, it does. Not only is science connected to wedding, though, ‘desk’ is also found to be connected to ‘deference.’ How can this be? OK, I counted the number of components in the graph and guess what? There were only eight! So, perhaps it’s not that hard to get married in the Science Park after all.

But wait, I know I can get there, but how? Union-find is a good start, but I need to find the shortest path. So, we need to build an undirected graph and search for it. I’ll leave this as an exercise for the reader.

You can take your time digging through your library trying to find your dusty old algorithms textbook. I have had some code prepared. Turns out the fastest way to accomplish this amazing feat is to exercise foul ‘devilry’ to play a ‘sport’ well enough to go to a ‘match,’ whom you can then marry in a ‘wedding’ ceremony. That’s it! Just four vertices away.