use of edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.fixedparameterclustering.FixedParameterTreeNode in project clusterMaker2 by RBVI.
the class ConnectedComponent method reduceCC.
private boolean reduceCC(ConnectedComponent cc, float clusteringScore2) {
FixedParameterTreeNode fptn = initFirstTreeNode(cc, clusteringScore2);
if (fptn.size == cc.getNodeNumber())
return false;
ICCEdges ccedges = TaskConfig.ccEdgesEnum.createCCEdges(fptn.size);
for (int i = 0; i < fptn.size; i++) {
for (int j = i + 1; j < fptn.size; j++) {
ccedges.setEdgeCost(i, j, fptn.edgeCosts[i][j]);
}
}
String[] objectIds = new String[fptn.size];
for (int i = 0; i < objectIds.length; i++) {
String id = "";
for (int j = 0; j < fptn.clusters[i].length; j++) {
if (fptn.clusters[i][j]) {
id += cc.getObjectID(j) + ";";
}
}
objectIds[i] = id;
}
cc.setNodeNumber(fptn.size);
cc.setCCEdges(ccedges);
cc.setObjectIDs(objectIds);
cc.setClusters(new int[fptn.size]);
cc.setReductionCost(fptn.costs);
return true;
}
use of edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.fixedparameterclustering.FixedParameterTreeNode in project clusterMaker2 by RBVI.
the class ConnectedComponent method initFirstTreeNode.
public static FixedParameterTreeNode initFirstTreeNode(ConnectedComponent cc, double maxK) {
FixedParameterTreeNode fptn = new FixedParameterTreeNode(cc.getNodeNumber(), 0, cc.getNodeNumber());
for (int i = 0; i < fptn.size; i++) {
fptn.clusters[i][i] = true;
for (int j = i + 1; j < fptn.size; j++) {
fptn.edgeCosts[i][j] = fptn.edgeCosts[j][i] = cc.getCCEdges().getEdgeCost(i, j);
}
}
fptn = reductionicf(fptn, maxK, cc);
return fptn;
}
use of edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.fixedparameterclustering.FixedParameterTreeNode in project clusterMaker2 by RBVI.
the class ConnectedComponent method mergeNodes.
public static FixedParameterTreeNode mergeNodes(FixedParameterTreeNode fptn, int node_i, int node_j, float costsForMerging, ConnectedComponent cc) {
FixedParameterTreeNode fptnNew = new FixedParameterTreeNode(fptn.size - 1, fptn.costs, cc.getNodeNumber());
fptnNew.costs = (fptn.costs + costsForMerging);
int[] mappingOld2New = new int[fptn.size];
for (int i = 0, j = 0; i < fptn.size; i++) {
if (i == node_i || i == node_j)
continue;
mappingOld2New[i] = j;
fptnNew.clusters[j] = fptn.clusters[i];
j++;
}
for (int i = 0; i < mappingOld2New.length; i++) {
if (i == node_i || i == node_j)
continue;
for (int j = i + 1; j < mappingOld2New.length; j++) {
if (j == node_i || j == node_j)
continue;
fptnNew.edgeCosts[mappingOld2New[i]][mappingOld2New[j]] = fptnNew.edgeCosts[mappingOld2New[j]][mappingOld2New[i]] = fptn.edgeCosts[i][j];
}
}
for (int i = 0; i < cc.getNodeNumber(); i++) {
fptnNew.clusters[fptnNew.size - 1][i] = (fptn.clusters[node_i][i] || fptn.clusters[node_j][i]);
}
for (int i = 0; i < fptn.size; i++) {
if (i == node_i || i == node_j)
continue;
fptnNew.edgeCosts[mappingOld2New[i]][fptnNew.size - 1] = fptnNew.edgeCosts[fptnNew.size - 1][mappingOld2New[i]] = fptn.edgeCosts[i][node_i] + fptn.edgeCosts[i][node_j];
}
return fptnNew;
}
use of edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.fixedparameterclustering.FixedParameterTreeNode in project clusterMaker2 by RBVI.
the class ConnectedComponent method reductionicf.
public static FixedParameterTreeNode reductionicf(FixedParameterTreeNode fptnNew, double maxK, ConnectedComponent cc) {
for (int i = 0; i < fptnNew.size; i++) {
for (int j = i + 1; j < fptnNew.size; j++) {
float sumIcf = calculateCostsForSetForbidden(fptnNew, i, j);
if (sumIcf + fptnNew.costs > maxK) {
float costsForMerging = calculateCostsForMerging(fptnNew, i, j);
FixedParameterTreeNode fptnNew2 = mergeNodes(fptnNew, i, j, costsForMerging, cc);
fptnNew2 = reductionicf(fptnNew2, maxK, cc);
return fptnNew2;
}
}
}
return fptnNew;
}
Aggregations