Created
July 28, 2012 17:28
-
-
Save okram/3194114 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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