algorithm - how to sum edge weights with graphx -


i have graph[int, int], each edge has weight value. want is, each user, collect in-edges , sum weight associated each of them.

say data like:

    import org.apache.spark.graphx._     val sc: sparkcontext         // create rdd vertices         val users: rdd[(vertexid, (string, string))] =               sc.parallelize(array((3l, ("rxin", "student")),                                    (7l,("jgonzal", "postdoc")),                                   (5l, ("franklin", "prof")),                                    (2l, ("istoica", "prof"))))     // create rdd edges     val relationships: rdd[edge[int]] =          sc.parallelize(array(edge(3l, 7l, 12),                               edge(5l, 3l, 1),                               edge(2l, 5l, 3),                                edge(5l, 7l, 5)))      // define default user in case there relationship missing user     val defaultuser = ("john doe", "missing")      // build initial graph     val graph = graph(users, relationships, defaultuser) 

my ideal outcome data frame vertices ids , summed weight value... weighted in-degree measure...

id    value 3l    1 5l    3 7l    17 2l    0 

val temp = graph.aggregatemessages[int](triplet => {triplet.sendtodst(triplet.attr)},_ + _, tripletfields.edgeonly).todf("id","value")  temp.show() 

Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -