Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def Pregel(graph: Graph[V,E], //graph
- initialMsg: M //initial messsage
- vprogf: ((Id,V), M) => V, // vertex program
- sendMsgf: Edge[V,E] => Option[M], // computes msg for each egde
- combinef: (M,M) => M, // combiner
- numIter: Long): Graph[V,E] = {
- // Initialize the messages to all vertices
- var msgs: RDD[(Vid, A)] = graph.vertices.map(v => (v.id, initialMsg))
- // Loop while their are messages
- var i = 0
- while (msgs.count > 0 && i < maxIter) {
- // Receive the message sums on each vertex
- graph = graph.updateVertices(msgs, vprogf)
- // Compute and combine new messages
- msgs = graph.aggregateNeighbors(sendMsgf, combinef)
- i = i + 1
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement