diff options
Diffstat (limited to 'geometry')
| -rw-r--r-- | geometry/closestPair.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/geometry/closestPair.cpp b/geometry/closestPair.cpp index 10c9291..92b4551 100644 --- a/geometry/closestPair.cpp +++ b/geometry/closestPair.cpp @@ -1,15 +1,13 @@ double squaredDist(point a, point b) { - return (a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second); + return (a.first-b.first) * (a.first-b.first) + (a.second-b.second) * (a.second-b.second); } bool compY(point a, point b) { - if (a.second == b.second) { - return a.first < b.first; - } + if (a.second == b.second) return a.first < b.first; return a.second < b.second; } -void shortestDist(vector<point> &points) { +double shortestDist(vector<point> &points) { //check that points.size() > 1 and that ALL POINTS ARE DIFFERENT set<point, bool(*)(point, point)> status(compY); sort(points.begin(), points.end()); @@ -33,5 +31,6 @@ void shortestDist(vector<point> &points) { } status.insert(*(right++)); } - } // closest distance in sqrtOpt + } + return sqrtOpt; } |
