Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Load and initialize the graph
- val graph = Graph.load(’hdfs://webgraph.tsv’)
- // Initialize the graph for dynamic PageRank by
- // storing the degree and the old and new PageRank
- var prGraph = graph.updateV(graph.degrees(OutEdges),
- (v,deg) => (v.id, (deg, 1.0, 1.0))
- // Execute PageRank
- prGraph = PowerGraph(prGraph,
- gatherf = e => e.src.rank / e.src.deg,
- sumf = (a,b) => a + b,
- applyf = // Update rank and save previous rank
- (v, a) => (v.deg, 0.15 + 0.85*a, v.rank)
- scatterf = // Activate neighbors on big change
- e => abs(e.src.rank - e.srd.oldRank) > eps,
- 10) // Run 10 iterations
- // Display the maximum PageRank
- print(prGraph.vertices.map(v=>v.rank).max)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement