26 return a.centroid().E() > b.centroid().E();
29 void cluster(
double seed_threshold,
double cutoff) {
30 int ncluster = clusters_.size();
31 double minwgt = cutoff;
33 std::sort(clusters_.begin(), clusters_.end(), compClusters);
40 for (
size_t i = 0; i < clusters_.size(); i++) {
41 if (clusters_[i].empty())
continue;
43 bool iseed = (clusters_[i].centroid().E() >= seed_threshold);
52 for (
size_t j = i + 1; j < clusters_.size(); j++) {
53 if (clusters_[j].empty() ||
54 (!iseed && clusters_[j].centroid().E() < seed_threshold))
56 double wgt = wgt_(clusters_[i], clusters_[j]);
57 if (!any || wgt < minwgt) {
67 transitionWeights_.insert(std::pair<int, double>(ncluster, minwgt));
69 if (any && minwgt < cutoff) {
71 if (clusters_[mi].centroid().E() < clusters_[mj].centroid().E()) {
75 clusters_[mi].add(clusters_[mj]);
76 clusters_[mj].clear();
81 }
while (minwgt < cutoff && ncluster > 1);
85 double getYMax()
const {
return finalwgt_; }
87 int getNSeeds()
const {
return nseeds_; }
89 std::map<int, double> getWeights()
const {
return transitionWeights_; }
91 std::vector<WorkingCluster> getClusters()
const {
return clusters_; }
97 std::map<int, double> transitionWeights_;
98 std::vector<WorkingCluster> clusters_;