Skip to main content
1 of 5

Rather than reverse engineering the code, also check for references.

Even Wikipedia has this equation, known as Lance Williams equations: https://en.wikipedia.org/wiki/Ward%27s_method

If I'm not mistaken, a subtle difference is that it works on the squared distances.