}
public Graph doKTails() {
boolean go = true;
int iter = 0;
DOTWriter writer = new DOTWriter();
int startSize = nodes.size();
long startTime = System.currentTimeMillis();
g = getGraph();
dump(String.format("iter%d.dot", iter), writer.getRepresentation(g));
long start = System.currentTimeMillis();
int oldSize = nodes.size();
while (go) {
iter++;
go = doStep();
pruneNodes();
double time = (System.currentTimeMillis() - start) / 1000;
if (time > 5) {
int size = nodes.size();
int delta = oldSize - size;
oldSize = size;
double rate = (delta / (0.000001 + time));
System.err.println(
String.format(
"[doKTails] %d merges have been made in %.2fs [%.2f/sec], machine has %d nodes.", delta, time, rate, size));
start = System.currentTimeMillis();
}
}
g = getGraph();
double time = (System.currentTimeMillis() - startTime) / 1000.0;
long delta = startSize - nodes.size();
double rate = delta / (0.000001 + time);
System.err.println(
String.format(
"%d merges have been made in %.2fs [%.2f/sec], machine has %d nodes.", delta, time, rate, nodes.size()));
dump("final.dot", writer.getRepresentation(g));
return g;
}