scala - Connecting the first two nodes with an edge from two RDDs in GraphX -


i using graphx first time , want build graph incrementally. need connect first 2 nodes edge knowing have 2 rdds (each 1 has single value):

firstrdd: rdd[((int, array[int]), ((vertexid, array[int]), int))] secondrdd: rdd[((int, array[int]), ((vertexid, array[int]), int))]   

i want connect first vertexid second one. appreciate help

basically, use map , case statements pick out vertexids, then, use rdd.zip stitch them together, map create final edgerdd:

firstrdd.map{    case ((junk1,junk2), ((vertex1, junk3), junk4)) => vertex1 }.zip(   secondrdd.map{     case ((junk1,junk2), ((vertex2, junk3), junk4)) => vertex2    } ).map{ case(vertex1, vertex2) => edge(vertex1, vertex2, 0) } 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -