28 return a.centroid().E() > b.centroid().E();
31 void cluster(
double seed_threshold,
double cutoff) {
32 int ncluster = clusters_.size();
33 double minwgt = cutoff;
35 std::sort(clusters_.begin(), clusters_.end(), compClusters);
43 for (
size_t i = 0; i < clusters_.size(); i++) {
44 if (clusters_[i].empty())
continue;
46 bool iseed = (clusters_[i].centroid().E() >= seed_threshold);
55 for (
size_t j = i + 1; j < clusters_.size(); j++) {
56 if (clusters_[j].empty() ||
57 (!iseed && clusters_[j].centroid().E() <
60 double wgt = wgt_(clusters_[i], clusters_[j]);
61 if (!any || wgt < minwgt) {
71 transition_weights_.insert(std::pair<int, double>(ncluster, minwgt));
73 if (any && minwgt < cutoff) {
75 if (clusters_[mi].centroid().E() < clusters_[mj].centroid().E()) {
79 clusters_[mi].add(clusters_[mj]);
80 clusters_[mj].clear();
85 }
while (minwgt < cutoff && ncluster > 1);
87 for (
const auto& cl : clusters_) {
88 if (!cl.empty() && cl.centroid().E() >= seed_threshold)
89 final_clusters_.push_back(cl);
90 else if (cl.centroid().E() < seed_threshold)
95 double getYMax()
const {
return finalwgt_; }
97 int getNSeeds()
const {
return nseeds_; }
99 int getNLoops()
const {
return loops_; }
101 std::map<int, double> getWeights()
const {
return transition_weights_; }
103 std::vector<IntermediateCluster> getClusters()
const {
104 return final_clusters_;
112 std::map<int, double> transition_weights_;
113 std::vector<IntermediateCluster> clusters_;
114 std::vector<IntermediateCluster> final_clusters_;