pageRank.setConf(conf);
pageRank.run(new String[] { "--vertices", verticesFile.getAbsolutePath(), "--edges", edgesFile.getAbsolutePath(),
"--output", outputDir.getAbsolutePath(), "--numIterations", "3", "--stayingProbability", "0.8",
"--tempDir", tempDir.getAbsolutePath() });
Matrix expectedAdjacencyMatrix = new DenseMatrix(new double[][] {
{ 0, 1, 1, 1 },
{ 1, 0, 0, 1 },
{ 0, 0, 1, 0 },
{ 0, 1, 1, 0 } });
int numVertices = HadoopUtil.readInt(new Path(tempDir.getAbsolutePath(), AdjacencyMatrixJob.NUM_VERTICES), conf);
assertEquals(4, numVertices);
Matrix actualAdjacencyMatrix = MathHelper.readMatrix(conf, new Path(tempDir.getAbsolutePath(),
AdjacencyMatrixJob.ADJACENCY_MATRIX + "/part-r-00000"), numVertices, numVertices);
StringBuilder info = new StringBuilder();
info.append("\nexpected adjacency matrix\n\n");
info.append(MathHelper.nice(expectedAdjacencyMatrix));
info.append("\nactual adjacency matrix \n\n");
info.append(MathHelper.nice(actualAdjacencyMatrix));
info.append('\n');
log.info(info.toString());
Matrix expectedTransitionMatrix = new DenseMatrix(new double[][] {
{ 0.0, 0.4, 0.0, 0.0 },
{ 0.266666667, 0.0, 0.0, 0.4 },
{ 0.266666667, 0.0, 0.8, 0.4 },
{ 0.266666667, 0.4, 0.0, 0.0 } });
Matrix actualTransitionMatrix = MathHelper.readMatrix(conf, new Path(tempDir.getAbsolutePath(),
"transitionMatrix/part-r-00000"), numVertices, numVertices);
info = new StringBuilder();
info.append("\nexpected transition matrix\n\n");
info.append(MathHelper.nice(expectedTransitionMatrix));