Skip to content

Instantly share code, notes, and snippets.

@okram
Created July 28, 2012 17:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save okram/3194114 to your computer and use it in GitHub Desktop.
Save okram/3194114 to your computer and use it in GitHub Desktop.
public static class Map extends Mapper<NullWritable, LongWritable, NullWritable, NullWritable> {
private TitanGraph graph;
@Override
public void setup(final Mapper.Context context) throws IOException, InterruptedException {
this.graph = TitanFactory.open(context.get("titanConfiguration"));
}
@Override
public void map(final NullWritable key, final LongWritable value, final Mapper<NullWritable, LongWritable, NullWritable, NullWritable>.Context context) throws IOException, InterruptedException {
Vertex vertex = this.graph.getVertex(value.get());
double pageRank = vertex.getProperty("pageRank");
pageRank = pageRank / vertex.query().direction(OUT).count()
for(Vertex neighbor : vertex.getVertices(OUT)) {
double temp = neighbor.getProperty("pageRank");
neighbor.setProperty("pageRank", temp+pageRank)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment