Advertisement
Guest User

Untitled

a guest
May 19th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.57 KB | None | 0 0
  1. // Load and initialize the graph
  2. val graph = Graph.load('hdfs://webgraph.tsv')
  3. var prGraph = graph.updateV(graph.degrees(OutEdges),
  4.                             (v,deg) => (v.id,(deg, 1.0)) // Initial rank=1
  5. // Execute PageRank
  6. prGraph = Pregel(prGraph,
  7.                 1.0, // Initial message is 1.0
  8.                 vprogf = // Update Rank
  9.                     (v, msg) => (v.deg, 0.15 + 0.85 * msg),
  10.                 sendMsgf = // Compute Msg
  11.                     e => e.src.rank/e.src.deg,
  12.                 combinef = // Combine msg
  13.                     (m1, m2) => m1 + m2,
  14.                 10) // Run 10 iterations
  15.  
  16. // Display the maximum PageRank
  17. print(prGraph.vertices.map(v=>v.rank).max)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement