Skip to content

Commit

Permalink
Cluster and visualize only for more than 2 structures
Browse files Browse the repository at this point in the history
  • Loading branch information
tzok committed Oct 25, 2018
1 parent 163327f commit ddb6590
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions mcq-cli/src/main/java/pl/poznan/put/mcq/cli/Global.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private Global() {
private static final class Listener implements ParallelGlobalComparator.ProgressListener {
private final ProgressBar progressBar;

public Listener(final ProgressBar progressBar) {
private Listener(final ProgressBar progressBar) {
super();
this.progressBar = progressBar;
}
Expand All @@ -80,20 +80,25 @@ public void setProgress(final int progress) {

@Override
public void complete(final GlobalMatrix matrix) {
progressBar.close();

final PrototypeBasedClusterer clusterer = new KMedoids();
final double[][] rawMatrix = matrix.getDistanceMatrix().getMatrix();
final ScoredClusteringResult clustering =
KScanner.parallelScan(clusterer, rawMatrix, PAM.getInstance());
final PartitionalClustering partitionalClustering =
new PartitionalClustering(matrix.getDistanceMatrix(), clustering);

try {
progressBar.close();

final File directory = ExecHelper.createRandomDirectory();
Listener.exportResults(directory, matrix);
Listener.exportDrawing(directory, partitionalClustering);
Listener.exportClustering(directory, partitionalClustering);

final double[][] rawMatrix = matrix.getDistanceMatrix().getMatrix();

if (rawMatrix.length > 2) {
final PrototypeBasedClusterer clusterer = new KMedoids();
final ScoredClusteringResult clustering =
KScanner.parallelScan(clusterer, rawMatrix, PAM.getInstance());
final PartitionalClustering partitionalClustering =
new PartitionalClustering(matrix.getDistanceMatrix(), clustering);

Listener.exportDrawing(directory, partitionalClustering);
Listener.exportClustering(directory, partitionalClustering);
}

System.out.println("Results available in: " + directory);
} catch (final IOException e) {
System.err.println("Failed to store results");
Expand Down

0 comments on commit ddb6590

Please sign in to comment.