incubator-hama-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Hama Wiki] Update of "PageRank" by udanax
Date Wed, 13 Aug 2008 11:24:10 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Hama Wiki" for change notification.

The following page has been changed by udanax:
http://wiki.apache.org/hama/PageRank

------------------------------------------------------------------------------
- Describe PageRank here.
+ {{{
+ public class PageRank {
  
+   public static void main(String[] argv) {
+     int[][] data = { 
+       { 2, 3, 4, 5, 7 }, 
+       { 1 }, 
+       { 1, 2 }, 
+       { 2, 3, 5 },
+       { 1, 3, 4, 6 },
+       { 1, 5 }, 
+       { 5 } 
+     };
+ 
+     double[][] a = new double[data.length][data.length];
+     for (int i = 0; i < data.length; i++) {
+       for (int j = 0; j < data[i].length; j++) {
+         a[data[i][j] - 1][i] = 1.0 / data[i].length;
+       }
+     }
+     double[] eigVector = new Matrix(a).eigenDecomposition().getV().transpose().getArray()[0];
+     double norm1 = new Matrix(eigVector , eigVector .length).norm1();
+     for (int i = 0; i < eigVector.length; i++)
+       System.out.println(eigVector[i] / norm1);
+   }
+ }
+ }}}
+ 

Mime
View raw message