Advertisement
Guest User

Untitled

a guest
May 18th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.68 KB | None | 0 0
  1. def Pregel(graph: Graph[V,E], //graph
  2.            initialMsg: M //initial messsage
  3.            vprogf: ((Id,V), M) => V, // vertex program
  4.            sendMsgf: Edge[V,E] => Option[M], // computes msg for each egde
  5.            combinef: (M,M) => M, // combiner
  6.            numIter: Long): Graph[V,E] = {
  7.    
  8.     // Initialize the messages to all vertices
  9.     var msgs: RDD[(Vid, A)] = graph.vertices.map(v => (v.id, initialMsg))
  10.    
  11.     // Loop while their are messages
  12.     var i = 0
  13.     while (msgs.count > 0 && i < maxIter) {
  14.         // Receive the message sums on each vertex
  15.         graph = graph.updateVertices(msgs, vprogf)
  16.         // Compute and combine new messages
  17.         msgs = graph.aggregateNeighbors(sendMsgf, combinef)
  18.         i = i + 1
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement