From ddb65903e891064f58d55d2449d7039fdc804c82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20=C5=BBok?= Date: Thu, 25 Oct 2018 15:00:34 +0200 Subject: [PATCH] Cluster and visualize only for more than 2 structures --- .../java/pl/poznan/put/mcq/cli/Global.java | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/mcq-cli/src/main/java/pl/poznan/put/mcq/cli/Global.java b/mcq-cli/src/main/java/pl/poznan/put/mcq/cli/Global.java index c21a9aea..6e7613c5 100644 --- a/mcq-cli/src/main/java/pl/poznan/put/mcq/cli/Global.java +++ b/mcq-cli/src/main/java/pl/poznan/put/mcq/cli/Global.java @@ -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; } @@ -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");