Advertisement
Guest User

Untitled

a guest
May 18th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.59 KB | None | 0 0
  1. def Pregel(graph: Graph[V,E],
  2.            initialMsg: M
  3.            vprogf: ((Id,V), M) => V,
  4.            sendMsgf: Edge[V,E] => Option[M],
  5.            combinef: (M,M) => M,
  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