How to compute the sum of degree of two vertexs in each edge in graphx

Viewed 397

I have a graph like this:

val vertexArray = Array(
      (1L, ("Alice", 28)),
      (2L, ("Bob", 27)),
      (3L, ("Charlie", 65)),
      (4L, ("David", 42)),
      (5L, ("Ed", 55)))                               
val edges = sc.parallelize(Array(
                 Edge(1L, 2L, ""), 
                 Edge(1L, 3L, ""), 
                 Edge(2L, 4L, ""),
                 Edge(3L, 5L, ""),
                 Edge(2L, 3L, "")))
val graph = Graph(vertexArray, edges)

I want to get the sum of degrees of two vertices in each edge. For example, the node 1L has 2 neighbors and node 2L has 3 neighbors, then the result which i want to get is "1L, 2L, 5".The whole result is:

"1L, 2L, 5"
"1L, 3L, 5"
"2L, 4L, 4"
"3L, 5L, 4",
"2L, 3L, 6"

How can I implement it in GraphX?

1 Answers
Related