hama-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edwardy...@apache.org
Subject svn commit: r1574739 - in /hama/trunk: examples/src/test/java/org/apache/hama/examples/ examples/src/test/resources/ ml/src/main/java/org/apache/hama/ml/semiclustering/
Date Thu, 06 Mar 2014 01:29:39 GMT
Author: edwardyoon
Date: Thu Mar  6 01:29:39 2014
New Revision: 1574739

URL: http://svn.apache.org/r1574739
Log:
HAMA-885: Semi-Clustering Algorithm implementation is not producing expected output

Added:
    hama/trunk/examples/src/test/resources/semiclustering.txt
Modified:
    hama/trunk/examples/src/test/java/org/apache/hama/examples/SemiClusterMatchingTest.java
    hama/trunk/ml/src/main/java/org/apache/hama/ml/semiclustering/SemiClusterDetails.java
    hama/trunk/ml/src/main/java/org/apache/hama/ml/semiclustering/SemiClusterMessage.java
    hama/trunk/ml/src/main/java/org/apache/hama/ml/semiclustering/SemiClusteringVertex.java

Modified: hama/trunk/examples/src/test/java/org/apache/hama/examples/SemiClusterMatchingTest.java
URL: http://svn.apache.org/viewvc/hama/trunk/examples/src/test/java/org/apache/hama/examples/SemiClusterMatchingTest.java?rev=1574739&r1=1574738&r2=1574739&view=diff
==============================================================================
--- hama/trunk/examples/src/test/java/org/apache/hama/examples/SemiClusterMatchingTest.java
(original)
+++ hama/trunk/examples/src/test/java/org/apache/hama/examples/SemiClusterMatchingTest.java
Thu Mar  6 01:29:39 2014
@@ -55,7 +55,7 @@ import org.junit.Test;
 
 @SuppressWarnings("unused")
 public class SemiClusterMatchingTest extends TestCase {
-  private static String INPUT = "/tmp/graph.txt";
+  private static String INPUT = "src/test/resources/semiclustering.txt";
   private static String OUTPUT = "/tmp/graph-semiCluster";
   private static final String semiClusterMaximumVertexCount = "semicluster.max.vertex.count";
   private static final String graphJobMessageSentCount = "semicluster.max.message.sent.count";
@@ -69,40 +69,6 @@ public class SemiClusterMatchingTest ext
     fs = FileSystem.get(conf);
   }
 
-  private void generateTestData() throws IOException {
-    int vertexNameStart = 0, vertexNameEnd = 300, vertexEdgeMin = 30, vertexEdgeMax = 40;
-    BufferedWriter bw = new BufferedWriter(new FileWriter(INPUT));
-    for (int i = vertexNameStart; i < vertexNameEnd; i++) {
-      StringBuilder sb = new StringBuilder();
-      int numberOfEdges = 10;
-      Map<Integer, Integer> mp = new HashMap<Integer, Integer>();
-      int mapSize = 0, min = i - (i % 10), max = i + (10 - (i % 10) - 1);
-      while (mapSize < numberOfEdges) {
-        int edgeVal = randomInRange(min, max);
-        if (mp.containsKey(edgeVal)) {
-          int val = mp.get(edgeVal);
-          mp.put(edgeVal, val++);
-        } else
-          mp.put(edgeVal, 1);
-        mapSize = mp.size();
-      }
-      Iterator<Integer> itr = mp.keySet().iterator();
-      sb.append(i + "\t");
-      for (int j = 0; j < numberOfEdges; j++) {
-        int key = itr.next();
-        if (j != numberOfEdges - 1)
-          sb.append(key + "-" + (float) mp.get(key) / (float) numberOfEdges
-              + ",");
-        else
-          sb.append(key + "-" + (float) mp.get(key) / (float) numberOfEdges);
-      }
-      bw.write(sb.toString());
-      if (i < vertexNameEnd)
-        bw.write("\n");
-    }
-    bw.close();
-  }
-
   public static int random(int max) {
     return (new Random().nextInt(max));
   }
@@ -185,9 +151,11 @@ public class SemiClusterMatchingTest ext
     Map<String, List<String>> mpOutPutCluser = outputClusterLoader();
     Iterator it = mpOutPutCluser.entrySet().iterator();
     while (it.hasNext()) {
-      System.out.println(it.next());
       flag = true;
-      Map.Entry pairs = (Map.Entry) it.next();
+      Map.Entry<String, List<String>> pairs = (Map.Entry<String, List<String>>)
it
+          .next();
+      System.out.println(pairs.getKey() + " = " + pairs.getValue());
+      assertEquals(pairs.getValue().size(), 10);
       List<String> valFromMap = new ArrayList<String>();
       List<String> val2 = (List<String>) pairs.getValue();
       int size = val2.size();
@@ -202,13 +170,11 @@ public class SemiClusterMatchingTest ext
         count++;
       }
     }
-    assertEquals("Semi Cluster Test Successful", 30, count);
+    assertEquals("Semi Cluster Test Successful", 10, count);
   }
 
   private void deleteTempDirs() {
     try {
-      if (fs.exists(new Path(INPUT)))
-        fs.delete(new Path(INPUT), true);
       if (fs.exists(new Path(OUTPUT)))
         fs.delete(new Path(OUTPUT), true);
       if (fs.exists(new Path("/tmp/partitions")))
@@ -221,7 +187,6 @@ public class SemiClusterMatchingTest ext
   @Test
   public void testSemiClustering() throws IOException, InterruptedException,
       ClassNotFoundException {
-    generateTestData();
     try {
 
       HamaConfiguration conf = new HamaConfiguration();
@@ -230,10 +195,10 @@ public class SemiClusterMatchingTest ext
       conf.setInt(graphJobVertexMaxClusterCount, 1);
       GraphJob semiClusterJob = new GraphJob(conf, SemiClusterJobDriver.class);
       semiClusterJob.setMaxIteration(15);
-      
+
       semiClusterJob.setCompressionCodec(SnappyCompressor.class);
       semiClusterJob.setCompressionThreshold(10);
-      
+
       semiClusterJob
           .setVertexOutputWriterClass(SemiClusterVertexOutputWriter.class);
       semiClusterJob.setJobName("SemiClusterJob");

Added: hama/trunk/examples/src/test/resources/semiclustering.txt
URL: http://svn.apache.org/viewvc/hama/trunk/examples/src/test/resources/semiclustering.txt?rev=1574739&view=auto
==============================================================================
--- hama/trunk/examples/src/test/resources/semiclustering.txt (added)
+++ hama/trunk/examples/src/test/resources/semiclustering.txt Thu Mar  6 01:29:39 2014
@@ -0,0 +1,100 @@
+0	0-0.1,1-0.1,2-0.1,3-0.1,4-0.1,5-0.1,6-0.1,7-0.1,8-0.1,9-0.1
+1	0-0.1,1-0.1,2-0.1,3-0.1,4-0.1,5-0.1,6-0.1,7-0.1,8-0.1,9-0.1
+2	0-0.1,1-0.1,2-0.1,3-0.1,4-0.1,5-0.1,6-0.1,7-0.1,8-0.1,9-0.1
+3	0-0.1,1-0.1,2-0.1,3-0.1,4-0.1,5-0.1,6-0.1,7-0.1,8-0.1,9-0.1
+4	0-0.1,1-0.1,2-0.1,3-0.1,4-0.1,5-0.1,6-0.1,7-0.1,8-0.1,9-0.1
+5	0-0.1,1-0.1,2-0.1,3-0.1,4-0.1,5-0.1,6-0.1,7-0.1,8-0.1,9-0.1
+6	0-0.1,1-0.1,2-0.1,3-0.1,4-0.1,5-0.1,6-0.1,7-0.1,8-0.1,9-0.1
+7	0-0.1,1-0.1,2-0.1,3-0.1,4-0.1,5-0.1,6-0.1,7-0.1,8-0.1,9-0.1
+8	0-0.1,1-0.1,2-0.1,3-0.1,4-0.1,5-0.1,6-0.1,7-0.1,8-0.1,9-0.1
+9	0-0.1,1-0.1,2-0.1,3-0.1,4-0.1,5-0.1,6-0.1,7-0.1,8-0.1,9-0.1
+10	17-0.1,16-0.1,19-0.1,18-0.1,10-0.1,11-0.1,12-0.1,13-0.1,14-0.1,15-0.1
+11	17-0.1,16-0.1,19-0.1,18-0.1,10-0.1,11-0.1,12-0.1,13-0.1,14-0.1,15-0.1
+12	17-0.1,16-0.1,19-0.1,18-0.1,10-0.1,11-0.1,12-0.1,13-0.1,14-0.1,15-0.1
+13	17-0.1,16-0.1,19-0.1,18-0.1,10-0.1,11-0.1,12-0.1,13-0.1,14-0.1,15-0.1
+14	17-0.1,16-0.1,19-0.1,18-0.1,10-0.1,11-0.1,12-0.1,13-0.1,14-0.1,15-0.1
+15	17-0.1,16-0.1,19-0.1,18-0.1,10-0.1,11-0.1,12-0.1,13-0.1,14-0.1,15-0.1
+16	17-0.1,16-0.1,19-0.1,18-0.1,10-0.1,11-0.1,12-0.1,13-0.1,14-0.1,15-0.1
+17	17-0.1,16-0.1,19-0.1,18-0.1,10-0.1,11-0.1,12-0.1,13-0.1,14-0.1,15-0.1
+18	17-0.1,16-0.1,19-0.1,18-0.1,10-0.1,11-0.1,12-0.1,13-0.1,14-0.1,15-0.1
+19	17-0.1,16-0.1,19-0.1,18-0.1,10-0.1,11-0.1,12-0.1,13-0.1,14-0.1,15-0.1
+20	21-0.1,20-0.1,23-0.1,22-0.1,25-0.1,24-0.1,27-0.1,26-0.1,29-0.1,28-0.1
+21	21-0.1,20-0.1,23-0.1,22-0.1,25-0.1,24-0.1,27-0.1,26-0.1,29-0.1,28-0.1
+22	21-0.1,20-0.1,23-0.1,22-0.1,25-0.1,24-0.1,27-0.1,26-0.1,29-0.1,28-0.1
+23	21-0.1,20-0.1,23-0.1,22-0.1,25-0.1,24-0.1,27-0.1,26-0.1,29-0.1,28-0.1
+24	21-0.1,20-0.1,23-0.1,22-0.1,25-0.1,24-0.1,27-0.1,26-0.1,29-0.1,28-0.1
+25	21-0.1,20-0.1,23-0.1,22-0.1,25-0.1,24-0.1,27-0.1,26-0.1,29-0.1,28-0.1
+26	21-0.1,20-0.1,23-0.1,22-0.1,25-0.1,24-0.1,27-0.1,26-0.1,29-0.1,28-0.1
+27	21-0.1,20-0.1,23-0.1,22-0.1,25-0.1,24-0.1,27-0.1,26-0.1,29-0.1,28-0.1
+28	21-0.1,20-0.1,23-0.1,22-0.1,25-0.1,24-0.1,27-0.1,26-0.1,29-0.1,28-0.1
+29	21-0.1,20-0.1,23-0.1,22-0.1,25-0.1,24-0.1,27-0.1,26-0.1,29-0.1,28-0.1
+30	34-0.1,35-0.1,32-0.1,33-0.1,38-0.1,39-0.1,36-0.1,37-0.1,31-0.1,30-0.1
+31	34-0.1,35-0.1,32-0.1,33-0.1,38-0.1,39-0.1,36-0.1,37-0.1,31-0.1,30-0.1
+32	34-0.1,35-0.1,32-0.1,33-0.1,38-0.1,39-0.1,36-0.1,37-0.1,31-0.1,30-0.1
+33	34-0.1,35-0.1,32-0.1,33-0.1,38-0.1,39-0.1,36-0.1,37-0.1,31-0.1,30-0.1
+34	34-0.1,35-0.1,32-0.1,33-0.1,38-0.1,39-0.1,36-0.1,37-0.1,31-0.1,30-0.1
+35	34-0.1,35-0.1,32-0.1,33-0.1,38-0.1,39-0.1,36-0.1,37-0.1,31-0.1,30-0.1
+36	34-0.1,35-0.1,32-0.1,33-0.1,38-0.1,39-0.1,36-0.1,37-0.1,31-0.1,30-0.1
+37	34-0.1,35-0.1,32-0.1,33-0.1,38-0.1,39-0.1,36-0.1,37-0.1,31-0.1,30-0.1
+38	34-0.1,35-0.1,32-0.1,33-0.1,38-0.1,39-0.1,36-0.1,37-0.1,31-0.1,30-0.1
+39	34-0.1,35-0.1,32-0.1,33-0.1,38-0.1,39-0.1,36-0.1,37-0.1,31-0.1,30-0.1
+40	49-0.1,48-0.1,42-0.1,43-0.1,40-0.1,41-0.1,46-0.1,47-0.1,44-0.1,45-0.1
+41	49-0.1,48-0.1,42-0.1,43-0.1,40-0.1,41-0.1,46-0.1,47-0.1,44-0.1,45-0.1
+42	49-0.1,48-0.1,42-0.1,43-0.1,40-0.1,41-0.1,46-0.1,47-0.1,44-0.1,45-0.1
+43	49-0.1,48-0.1,42-0.1,43-0.1,40-0.1,41-0.1,46-0.1,47-0.1,44-0.1,45-0.1
+44	49-0.1,48-0.1,42-0.1,43-0.1,40-0.1,41-0.1,46-0.1,47-0.1,44-0.1,45-0.1
+45	49-0.1,48-0.1,42-0.1,43-0.1,40-0.1,41-0.1,46-0.1,47-0.1,44-0.1,45-0.1
+46	49-0.1,48-0.1,42-0.1,43-0.1,40-0.1,41-0.1,46-0.1,47-0.1,44-0.1,45-0.1
+47	49-0.1,48-0.1,42-0.1,43-0.1,40-0.1,41-0.1,46-0.1,47-0.1,44-0.1,45-0.1
+48	49-0.1,48-0.1,42-0.1,43-0.1,40-0.1,41-0.1,46-0.1,47-0.1,44-0.1,45-0.1
+49	49-0.1,48-0.1,42-0.1,43-0.1,40-0.1,41-0.1,46-0.1,47-0.1,44-0.1,45-0.1
+50	51-0.1,50-0.1,55-0.1,54-0.1,53-0.1,52-0.1,59-0.1,58-0.1,57-0.1,56-0.1
+51	51-0.1,50-0.1,55-0.1,54-0.1,53-0.1,52-0.1,59-0.1,58-0.1,57-0.1,56-0.1
+52	51-0.1,50-0.1,55-0.1,54-0.1,53-0.1,52-0.1,59-0.1,58-0.1,57-0.1,56-0.1
+53	51-0.1,50-0.1,55-0.1,54-0.1,53-0.1,52-0.1,59-0.1,58-0.1,57-0.1,56-0.1
+54	51-0.1,50-0.1,55-0.1,54-0.1,53-0.1,52-0.1,59-0.1,58-0.1,57-0.1,56-0.1
+55	51-0.1,50-0.1,55-0.1,54-0.1,53-0.1,52-0.1,59-0.1,58-0.1,57-0.1,56-0.1
+56	51-0.1,50-0.1,55-0.1,54-0.1,53-0.1,52-0.1,59-0.1,58-0.1,57-0.1,56-0.1
+57	51-0.1,50-0.1,55-0.1,54-0.1,53-0.1,52-0.1,59-0.1,58-0.1,57-0.1,56-0.1
+58	51-0.1,50-0.1,55-0.1,54-0.1,53-0.1,52-0.1,59-0.1,58-0.1,57-0.1,56-0.1
+59	51-0.1,50-0.1,55-0.1,54-0.1,53-0.1,52-0.1,59-0.1,58-0.1,57-0.1,56-0.1
+60	68-0.1,69-0.1,64-0.1,65-0.1,66-0.1,67-0.1,63-0.1,62-0.1,61-0.1,60-0.1
+61	68-0.1,69-0.1,64-0.1,65-0.1,66-0.1,67-0.1,63-0.1,62-0.1,61-0.1,60-0.1
+62	68-0.1,69-0.1,64-0.1,65-0.1,66-0.1,67-0.1,63-0.1,62-0.1,61-0.1,60-0.1
+63	68-0.1,69-0.1,64-0.1,65-0.1,66-0.1,67-0.1,63-0.1,62-0.1,61-0.1,60-0.1
+64	68-0.1,69-0.1,64-0.1,65-0.1,66-0.1,67-0.1,63-0.1,62-0.1,61-0.1,60-0.1
+65	68-0.1,69-0.1,64-0.1,65-0.1,66-0.1,67-0.1,63-0.1,62-0.1,61-0.1,60-0.1
+66	68-0.1,69-0.1,64-0.1,65-0.1,66-0.1,67-0.1,63-0.1,62-0.1,61-0.1,60-0.1
+67	68-0.1,69-0.1,64-0.1,65-0.1,66-0.1,67-0.1,63-0.1,62-0.1,61-0.1,60-0.1
+68	68-0.1,69-0.1,64-0.1,65-0.1,66-0.1,67-0.1,63-0.1,62-0.1,61-0.1,60-0.1
+69	68-0.1,69-0.1,64-0.1,65-0.1,66-0.1,67-0.1,63-0.1,62-0.1,61-0.1,60-0.1
+70	70-0.1,71-0.1,76-0.1,77-0.1,78-0.1,79-0.1,72-0.1,73-0.1,74-0.1,75-0.1
+71	70-0.1,71-0.1,76-0.1,77-0.1,78-0.1,79-0.1,72-0.1,73-0.1,74-0.1,75-0.1
+72	70-0.1,71-0.1,76-0.1,77-0.1,78-0.1,79-0.1,72-0.1,73-0.1,74-0.1,75-0.1
+73	70-0.1,71-0.1,76-0.1,77-0.1,78-0.1,79-0.1,72-0.1,73-0.1,74-0.1,75-0.1
+74	70-0.1,71-0.1,76-0.1,77-0.1,78-0.1,79-0.1,72-0.1,73-0.1,74-0.1,75-0.1
+75	70-0.1,71-0.1,76-0.1,77-0.1,78-0.1,79-0.1,72-0.1,73-0.1,74-0.1,75-0.1
+76	70-0.1,71-0.1,76-0.1,77-0.1,78-0.1,79-0.1,72-0.1,73-0.1,74-0.1,75-0.1
+77	70-0.1,71-0.1,76-0.1,77-0.1,78-0.1,79-0.1,72-0.1,73-0.1,74-0.1,75-0.1
+78	70-0.1,71-0.1,76-0.1,77-0.1,78-0.1,79-0.1,72-0.1,73-0.1,74-0.1,75-0.1
+79	70-0.1,71-0.1,76-0.1,77-0.1,78-0.1,79-0.1,72-0.1,73-0.1,74-0.1,75-0.1
+80	85-0.1,84-0.1,87-0.1,86-0.1,81-0.1,80-0.1,83-0.1,82-0.1,89-0.1,88-0.1
+81	85-0.1,84-0.1,87-0.1,86-0.1,81-0.1,80-0.1,83-0.1,82-0.1,89-0.1,88-0.1
+82	85-0.1,84-0.1,87-0.1,86-0.1,81-0.1,80-0.1,83-0.1,82-0.1,89-0.1,88-0.1
+83	85-0.1,84-0.1,87-0.1,86-0.1,81-0.1,80-0.1,83-0.1,82-0.1,89-0.1,88-0.1
+84	85-0.1,84-0.1,87-0.1,86-0.1,81-0.1,80-0.1,83-0.1,82-0.1,89-0.1,88-0.1
+85	85-0.1,84-0.1,87-0.1,86-0.1,81-0.1,80-0.1,83-0.1,82-0.1,89-0.1,88-0.1
+86	85-0.1,84-0.1,87-0.1,86-0.1,81-0.1,80-0.1,83-0.1,82-0.1,89-0.1,88-0.1
+87	85-0.1,84-0.1,87-0.1,86-0.1,81-0.1,80-0.1,83-0.1,82-0.1,89-0.1,88-0.1
+88	85-0.1,84-0.1,87-0.1,86-0.1,81-0.1,80-0.1,83-0.1,82-0.1,89-0.1,88-0.1
+89	85-0.1,84-0.1,87-0.1,86-0.1,81-0.1,80-0.1,83-0.1,82-0.1,89-0.1,88-0.1
+90	98-0.1,99-0.1,96-0.1,97-0.1,93-0.1,92-0.1,95-0.1,94-0.1,91-0.1,90-0.1
+91	98-0.1,99-0.1,96-0.1,97-0.1,93-0.1,92-0.1,95-0.1,94-0.1,91-0.1,90-0.1
+92	98-0.1,99-0.1,96-0.1,97-0.1,93-0.1,92-0.1,95-0.1,94-0.1,91-0.1,90-0.1
+93	98-0.1,99-0.1,96-0.1,97-0.1,93-0.1,92-0.1,95-0.1,94-0.1,91-0.1,90-0.1
+94	98-0.1,99-0.1,96-0.1,97-0.1,93-0.1,92-0.1,95-0.1,94-0.1,91-0.1,90-0.1
+95	98-0.1,99-0.1,96-0.1,97-0.1,93-0.1,92-0.1,95-0.1,94-0.1,91-0.1,90-0.1
+96	98-0.1,99-0.1,96-0.1,97-0.1,93-0.1,92-0.1,95-0.1,94-0.1,91-0.1,90-0.1
+97	98-0.1,99-0.1,96-0.1,97-0.1,93-0.1,92-0.1,95-0.1,94-0.1,91-0.1,90-0.1
+98	98-0.1,99-0.1,96-0.1,97-0.1,93-0.1,92-0.1,95-0.1,94-0.1,91-0.1,90-0.1
+99	98-0.1,99-0.1,96-0.1,97-0.1,93-0.1,92-0.1,95-0.1,94-0.1,91-0.1,90-0.1
\ No newline at end of file

Modified: hama/trunk/ml/src/main/java/org/apache/hama/ml/semiclustering/SemiClusterDetails.java
URL: http://svn.apache.org/viewvc/hama/trunk/ml/src/main/java/org/apache/hama/ml/semiclustering/SemiClusterDetails.java?rev=1574739&r1=1574738&r2=1574739&view=diff
==============================================================================
--- hama/trunk/ml/src/main/java/org/apache/hama/ml/semiclustering/SemiClusterDetails.java
(original)
+++ hama/trunk/ml/src/main/java/org/apache/hama/ml/semiclustering/SemiClusterDetails.java
Thu Mar  6 01:29:39 2014
@@ -113,5 +113,7 @@ public class SemiClusterDetails implemen
   @Override
   public int compareTo(SemiClusterDetails sc) {
     return (this.getSemiClusterId().compareTo(sc.getSemiClusterId()));
+    //return (this.getSemiClusterScore() == sc.getSemiClusterScore() ? 0
+    //    : this.getSemiClusterScore() < sc.getSemiClusterScore() ? -1 : 1);
   }
 }

Modified: hama/trunk/ml/src/main/java/org/apache/hama/ml/semiclustering/SemiClusterMessage.java
URL: http://svn.apache.org/viewvc/hama/trunk/ml/src/main/java/org/apache/hama/ml/semiclustering/SemiClusterMessage.java?rev=1574739&r1=1574738&r2=1574739&view=diff
==============================================================================
--- hama/trunk/ml/src/main/java/org/apache/hama/ml/semiclustering/SemiClusterMessage.java
(original)
+++ hama/trunk/ml/src/main/java/org/apache/hama/ml/semiclustering/SemiClusterMessage.java
Thu Mar  6 01:29:39 2014
@@ -153,8 +153,7 @@ public class SemiClusterMessage implemen
     return semiClusterContainThis;
   }
 
-  public void setSemiClusterContainThis(
-      List<SemiClusterDetails> semiClusterContainThis,
+  public void sortByScore(Set<SemiClusterDetails> semiClusterContainThis,
       int graphJobVertexMaxClusterCount) {
     int clusterCountToBeRemoved = 0;
     NavigableSet<SemiClusterDetails> setSort = new TreeSet<SemiClusterDetails>(
@@ -176,7 +175,6 @@ public class SemiClusterMessage implemen
       clusterCountToBeRemoved--;
     }
     this.semiClusterContainThis = setSort;
-
   }
 
   public int compareTo(SemiClusterMessage m) {

Modified: hama/trunk/ml/src/main/java/org/apache/hama/ml/semiclustering/SemiClusteringVertex.java
URL: http://svn.apache.org/viewvc/hama/trunk/ml/src/main/java/org/apache/hama/ml/semiclustering/SemiClusteringVertex.java?rev=1574739&r1=1574738&r2=1574739&view=diff
==============================================================================
--- hama/trunk/ml/src/main/java/org/apache/hama/ml/semiclustering/SemiClusteringVertex.java
(original)
+++ hama/trunk/ml/src/main/java/org/apache/hama/ml/semiclustering/SemiClusteringVertex.java
Thu Mar  6 01:29:39 2014
@@ -47,8 +47,10 @@ public class SemiClusteringVertex extend
 
   @Override
   public void setup(HamaConfiguration conf) {
-    semiClusterMaximumVertexCount = conf.getInt("semicluster.max.vertex.count", 10);
-    graphJobMessageSentCount = conf.getInt("semicluster.max.message.sent.count", 10);
+    semiClusterMaximumVertexCount = conf.getInt("semicluster.max.vertex.count",
+        10);
+    graphJobMessageSentCount = conf.getInt(
+        "semicluster.max.message.sent.count", 10);
     graphJobVertexMaxClusterCount = conf.getInt("vertex.max.cluster.count", 10);
   }
 
@@ -80,7 +82,8 @@ public class SemiClusteringVertex extend
         }
       }
 
-      Iterator<SemiClusterMessage> bestCandidates = candidates.descendingIterator();
+      Iterator<SemiClusterMessage> bestCandidates = candidates
+          .descendingIterator();
       int count = 0;
 
       while (bestCandidates.hasNext() && count < graphJobMessageSentCount) {
@@ -96,10 +99,12 @@ public class SemiClusteringVertex extend
         if (clusters.size() > graphJobVertexMaxClusterCount) {
           break;
         } else {
-          clusters.add(new SemiClusterDetails(msg.getSemiClusterId(), msg.getScore()));
+          clusters.add(new SemiClusterDetails(msg.getSemiClusterId(), msg
+              .getScore()));
         }
       }
 
+      value.sortByScore(clusters, graphJobVertexMaxClusterCount);
       this.setValue(value);
     }
   }



Mime
View raw message