Advertisement
Guest User

Untitled

a guest
May 19th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.71 KB | None | 0 0
  1. // Load and initialize the graph
  2. val graph = Graph.load(’hdfs://webgraph.tsv’)
  3.  
  4. // Initialize the graph for dynamic PageRank by
  5. // storing the degree and the old and new PageRank
  6. var prGraph = graph.updateV(graph.degrees(OutEdges),
  7.         (v,deg) => (v.id, (deg, 1.0, 1.0))
  8.  
  9. // Execute PageRank
  10. prGraph = PowerGraph(prGraph,
  11.                      gatherf = e => e.src.rank / e.src.deg,
  12.                      sumf = (a,b) => a + b,
  13.                      applyf = // Update rank and save previous rank
  14.                         (v, a) => (v.deg, 0.15 + 0.85*a, v.rank)
  15.                     scatterf = // Activate neighbors on big change
  16.                         e => abs(e.src.rank - e.srd.oldRank) > eps,
  17.                     10) // Run 10 iterations
  18.  
  19. // Display the maximum PageRank
  20. print(prGraph.vertices.map(v=>v.rank).max)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement