+ m->errorOut(e, "Cluster", "clusterNames");
+ exit(1);
+ }
+}
+/***********************************************************************/
+void Cluster::update(double& cutOFF){
+ try {
+ smallCol = dMatrix->getSmallestCell(smallRow);
+ nColCells = dMatrix->seqVec[smallCol].size();
+ nRowCells = dMatrix->seqVec[smallRow].size();
+
+ vector<int> foundCol(nColCells, 0);
+ //cout << dMatrix->getNNodes() << " small cell: " << smallRow << '\t' << smallCol << endl;
+ int search;
+ bool changed;
+
+ for (int i=nRowCells-1;i>=0;i--) {
+ if (m->control_pressed) { break; }
+
+ //if you are not the smallCell
+ if (dMatrix->seqVec[smallRow][i].index != smallCol) {
+ search = dMatrix->seqVec[smallRow][i].index;
+
+ bool merged = false;
+ for (int j=0;j<nColCells;j++) {
+
+ if (dMatrix->seqVec[smallCol][j].index != smallRow) { //if you are not the smallest distance
+ if (dMatrix->seqVec[smallCol][j].index == search) {
+ foundCol[j] = 1;
+ merged = true;
+ changed = updateDistance(dMatrix->seqVec[smallCol][j], dMatrix->seqVec[smallRow][i]);
+ dMatrix->updateCellCompliment(smallCol, j);
+ break;
+ }else if (dMatrix->seqVec[smallCol][j].index < search) { //we don't have a distance for this cell
+ if (adjust != -1.0) { //adjust
+ merged = true;
+ PDistCell value(search, adjust); //create a distance for the missing value
+ int location = dMatrix->addCellSorted(smallCol, value);
+ changed = updateDistance(dMatrix->seqVec[smallCol][location], dMatrix->seqVec[smallRow][i]);
+ dMatrix->updateCellCompliment(smallCol, location);
+ nColCells++;
+ foundCol.push_back(0); //add a new found column
+ //adjust value
+ for (int k = foundCol.size()-1; k > location; k--) { foundCol[k] = foundCol[k-1]; }
+ foundCol[location] = 1;
+ }
+ j+=nColCells;
+ }
+ }
+ }
+ //if not merged it you need it for warning
+ if ((!merged) && (method == "average" || method == "weighted")) {
+ if (cutOFF > dMatrix->seqVec[smallRow][i].dist) {
+ cutOFF = dMatrix->seqVec[smallRow][i].dist;
+ //cout << "changing cutoff to " << cutOFF << endl;
+ }
+
+ }
+ dMatrix->rmCell(smallRow, i);
+ }
+ }
+ clusterBins();
+ clusterNames();
+
+ // Special handling for singlelinkage case, not sure whether this
+ // could be avoided
+ for (int i=nColCells-1;i>=0;i--) {
+ if (foundCol[i] == 0) {
+ if (adjust != -1.0) { //adjust
+ PDistCell value(smallCol, adjust); //create a distance for the missing value
+ changed = updateDistance(dMatrix->seqVec[smallCol][i], value);
+ dMatrix->updateCellCompliment(smallCol, i);
+ }else {
+ if (method == "average" || method == "weighted") {
+ if (dMatrix->seqVec[smallCol][i].index != smallRow) { //if you are not hte smallest distance
+ if (cutOFF > dMatrix->seqVec[smallCol][i].dist) {
+ cutOFF = dMatrix->seqVec[smallCol][i].dist;
+ }
+ }
+ }
+ }
+ dMatrix->rmCell(smallCol, i);
+ }
+ }
+
+ }
+ catch(exception& e) {
+ m->errorOut(e, "Cluster", "update");