void DualTreeBoruvka<MetricType, TreeType>::CleanupHelper(TreeType* tree) { // Reset the statistic information. tree->Stat().MaxNeighborDistance() = DBL_MAX; tree->Stat().MinNeighborDistance() = DBL_MAX; tree->Stat().Bound() = DBL_MAX; // Recurse into all children. for (size_t i = 0; i < tree->NumChildren(); ++i) CleanupHelper(&tree->Child(i)); // Get the component of the first child or point. Then we will check to see // if all other components of children and points are the same. const int component = (tree->NumChildren() != 0) ? tree->Child(0).Stat().ComponentMembership() : connections.Find(tree->Point(0)); // Check components of children. for (size_t i = 0; i < tree->NumChildren(); ++i) if (tree->Child(i).Stat().ComponentMembership() != component) return; // Check components of points. for (size_t i = 0; i < tree->NumPoints(); ++i) if (connections.Find(tree->Point(i)) != size_t(component)) return; // If we made it this far, all components are the same. tree->Stat().ComponentMembership() = component; }
void DualTreeBoruvka<MetricType, TreeType>::Cleanup() { for (size_t i = 0; i < data.n_cols; i++) neighborsDistances[i] = DBL_MAX; if (!naive) CleanupHelper(tree); }
BOOL Cleanup(HANDLE *hArray, DWORD dwIndex) { BOOL bCRet; BOOL bCHRet; while (--dwIndex > 0) { bCHRet = CleanupHelper(&hArray[0], dwIndex); } bCRet = CloseHandle(hArray[0]); if (!bCRet) { Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) during " "clean up.\nGetLastError returned '%u'.\n", hArray[dwIndex], GetLastError()); } return (bCRet&&bCHRet); }