September 2015
Intermediate to advanced
148 pages
3h 20m
English
We have already seen that GraphX has a PageRank API. In the following, let us see how this famous web search algorithmic can be easily implemented using Pregel. Since we already explained in the previous chapter how PageRank works, we will now simply explain its Pregel implementation:
First of all, we need to initialize the ranking graph with each edge attribute set to 1, divided by the out-degree, and each vertex attribute to set 1.0:
val rankGraph: Graph[(Double, Double), Double] =
// Associate the degree with each vertex
graph.outerJoinVertices(graph.outDegrees) {
(vid, vdata, deg) => deg.getOrElse(0)
}.mapTriplets( e => 1.0 / e.srcAttr )
.mapVertices( (id, attr) => (0.0, 0.0) )Following the Pregel abstraction, ...
Read now
Unlock full access