// Test of closest pair algorithms // David Eppstein, UC Irvine, 19 Apr 1997 // // Programmer interface for points and distances #ifndef DISTANCES_H #define DISTANCES_H #include // a special flag value for distances, larger than any other possible distance // value. ClosestPairs are allowed to ignore pairs at this distance apart // (and produce an error rather than return a pair at this distance). // #define MAX_DISTANCE DBL_MAX // All points are black boxes to us, interpreted only by the distance fn. // We represent them as integers rather than e.g. void *, so that our // data structures can use them as array indices without e.g. having // to go through an extra layer of hashing. // typedef unsigned long point; // For instrumentation purposes, we keep track of the // number of times a distance function is called throughout the program. // extern unsigned long gDistances; // Distance function object. // // A distance function is defined to be something that takes a pair of // point arguments and returns a (floating point) distance. // We assume distances are symmetric (d(a,b)=d(b,a)) but do not require // the triangle inequality, nonnegativity, or other assumptions. // // This is a class rather than a function so it can keep track of any // global information necessary to interpret the point arguments it is given. // class Distance { public: virtual double operator () (point, point) { gDistances++; return 0.0; } }; #endif