File graphFile = new File(baseFilename);
/** Use local drunkard mob companion. You can also pass a remote reference
* by using Naming.lookup("rmi://my-companion")
*/
RemoteDrunkardCompanion companion;
if (companionUrl.equals("local")) {
companion = new IntDrunkardCompanion(4, Runtime.getRuntime().maxMemory() / 3);
} else {
companion = (RemoteDrunkardCompanion) Naming.lookup(companionUrl);
}
/* Configure walk sources. Note, GraphChi's internal ids are used. */
DrunkardJob drunkardJob = this.drunkardMobEngine.addJob("personalizedPageRank",
EdgeDirection.OUT_EDGES, this, companion);
drunkardJob.configureSourceRangeInternalIds(firstSource, numSources, numWalksPerSource);
drunkardMobEngine.run(numIters);
/* Ask companion to dump the results to file */
int nTop = 100;
companion.outputDistributions(baseFilename + "_ppr_" + firstSource + "_"
+ (firstSource + numSources - 1) + ".top" + nTop, nTop);
/* For debug */
VertexIdTranslate vertexIdTranslate = this.drunkardMobEngine.getVertexIdTranslate();
IdCount[] topForFirst = companion.getTop(firstSource, 10);
System.out.println("Top visits from source vertex " + vertexIdTranslate.forward(firstSource) + " (internal id=" + firstSource + ")");
for(IdCount idc : topForFirst) {
System.out.println(vertexIdTranslate.backward(idc.id) + ": " + idc.count);
}