use of edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.datastructure.ICCEdges 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.datastructure.ICCEdges in project clusterMaker2 by RBVI.
the class PP_RearrangeAndMergeBest method mergeBest.
protected void mergeBest(ArrayList<ArrayList<Integer>> clusterObject) throws InvalidInputFileException {
// System.out.println("start merging");
ICCEdges cc2d = TaskConfig.ccEdgesEnum.createCCEdges(clusterObject.size());
String[] ids = new String[clusterObject.size()];
for (int i = 0; i < ids.length; i++) {
ids[i] = i + "";
for (int j = i + 1; j < ids.length; j++) {
cc2d.setEdgeCost(i, j, -(float) calculateCostChange(clusterObject.get(i), clusterObject.get(j)));
// System.out.println(i + "\t" + j + "\t" + cc2d.getEdgeCost(i, j));
}
}
ConnectedComponent cc2 = new ConnectedComponent(cc2d, ids, null, false);
ClusteringManager cm = new ClusteringManager(null);
// cm.runClusteringForOneConnectedComponent(cc2, null, null, null, System.currentTimeMillis());
new GreedyClusterer(cc2);
// long dummy = TaskConfig.fpMaxTimeMillis;
// TaskConfig.fpMaxTimeMillis = Long.MAX_VALUE;
// FixedParameterClusterer dc = new FixedParameterClusterer(cc2,cc2.getClusteringScore());
// TaskConfig.fpMaxTimeMillis = dummy;
// if(cc2.getClusteringScore() != this.bestScore){
// PP_DivideAndRecluster pp = new PP_DivideAndRecluster();
// pp.initPostProcessing(cc2);
// pp.run();
// }
ArrayList<ArrayList<Integer>> clusterObjectNew = new ArrayList<ArrayList<Integer>>();
for (int i = 0; i < cc2.getNumberOfClusters(); i++) {
ArrayList<Integer> v = new ArrayList<Integer>();
clusterObjectNew.add(v);
}
int[] clustering = cc2.getClusters();
for (int i = 0; i < clustering.length; i++) {
clusterObjectNew.get(clustering[i]).addAll(clusterObject.get(i));
}
clusterObject = clusterObjectNew;
this.bestScore = cc2.calculateClusteringScore(clustering);
// System.out.println("end merging");
}
use of edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.datastructure.ICCEdges in project clusterMaker2 by RBVI.
the class GreedyClusterer method generateSortedList.
private void generateSortedList(boolean[] already2) {
ICCEdges icce = this.cc.getCCEdges();
double[] costs = new double[cc.getNodeNumber()];
for (int i = 0; i < cc.getNodeNumber(); i++) {
if (already2[i]) {
costs[i] = Double.POSITIVE_INFINITY;
continue;
}
double cost = 0;
for (int j = 0; j < cc.getNodeNumber(); j++) {
if (i == j)
continue;
if (already2[j])
continue;
cost += icce.getEdgeCost(i, j);
}
costs[i] = cost;
}
double[] costsClone = Arrays.copyOf(costs, costs.length);
Arrays.sort(costs);
boolean[] already = new boolean[costs.length];
for (int i = costs.length - 1; i >= 0; i--) {
int position = 0;
for (int j = 0; j < costsClone.length; j++) {
if (costs[i] != costsClone[j] || already[j])
continue;
position = j;
already[j] = true;
break;
}
this.listOfElementsSortedByCosts[costs.length - 1 - i] = position;
}
}
use of edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.datastructure.ICCEdges in project clusterMaker2 by RBVI.
the class GreedyClusterer method generateSortedList.
private void generateSortedList() {
ICCEdges icce = this.cc.getCCEdges();
double[] costs = new double[cc.getNodeNumber()];
for (int i = 0; i < cc.getNodeNumber(); i++) {
double cost = 0;
for (int j = 0; j < cc.getNodeNumber(); j++) {
if (i == j)
continue;
cost += icce.getEdgeCost(i, j);
}
costs[i] = cost;
}
double[] costsClone = Arrays.copyOf(costs, costs.length);
Arrays.sort(costs);
boolean[] already = new boolean[costs.length];
for (int i = costs.length - 1; i >= 0; i--) {
int position = 0;
for (int j = 0; j < costsClone.length; j++) {
if (costs[i] != costsClone[j] || already[j])
continue;
position = j;
already[j] = true;
break;
}
this.listOfElementsSortedByCosts[costs.length - 1 - i] = position;
}
}
use of edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.datastructure.ICCEdges in project clusterMaker2 by RBVI.
the class CopyOfGreedyClusterer method generateSortedList.
private void generateSortedList() {
ICCEdges icce = this.cc.getCCEdges();
double[] costs = new double[cc.getNodeNumber()];
for (int i = 0; i < cc.getNodeNumber(); i++) {
double cost = 0;
for (int j = 0; j < cc.getNodeNumber(); j++) {
if (i == j)
continue;
cost += icce.getEdgeCost(i, j);
}
costs[i] = cost;
}
double[] costsClone = Arrays.copyOf(costs, costs.length);
Arrays.sort(costs);
boolean[] already = new boolean[costs.length];
for (int i = costs.length - 1; i >= 0; i--) {
int position = 0;
for (int j = 0; j < costsClone.length; j++) {
if (costs[i] != costsClone[j] || already[j])
continue;
position = j;
already[j] = true;
break;
}
this.listOfElementsSortedByCosts[costs.length - 1 - i] = position;
}
}
Aggregations