2

I have the below tree structure where 1,2,3,4,5,6 are some ids and in bracket we have the values.

                                             ----------- 1(20)
                                            |
                        ------- 3(50)<------
                       |                    |
6 (30) <--- 5(15) <----                      ----------- 2 (10)
                       |
                        ------ 4(10)

I want to get the cumulative sum of all child nodes plus the value of root node at the root level. In this example, my output should be 6(root) => 135 (sum of all nodes). Any idea how do I implement this in Spark Graphx or Graphframe?

zero323
  • 322,348
  • 103
  • 959
  • 935
Anirban
  • 23
  • 4
  • Is your tree structure already stored in a graphx/graphframes graph? Also, should this also include "queries" for sub-levels, or is it always run against a full tree (meaning you want only the total sum of the tree) – dennlinger Mar 15 '17 at 11:27
  • Yes, tree structure is stored in graphx. I want the total sum of each connected roots(at level 0). – Anirban Apr 27 '17 at 02:07
  • I would refer you to the Pregel API in Spark [found here](http://spark.apache.org/docs/latest/api/scala/index.html#org.apache.spark.graphx.Pregel$), for which you can find exemplary uses via Google. The solution would be to send the current weight to the neighboring node (your diagram suggests direction from child to father), and set them to inactive. Repeat until everything is inactive, and you will have the sum of all values below at the root node. – dennlinger Apr 27 '17 at 13:05

0 Answers0