Summation of mutual item in branches with the same first branch index

Hi,
I am trying to make a summation of some data.
the data tree looks like this:
image
all branches have 12 items. There are 2 types of branches in this data tree, some starts with 0 let’s call it group A : [(0,0), (0,1), (0,2) and (0,3)] and others start with 1 let’s call it group B: [ (1.0) and (1,1)]

what I am trying to do is to get summation between the “all first items” of “all branches in group A” together then continue this process to the last one
Meaning the summation result I’m looking for is a list that the first item of the first group, is the summation of all first items in branches of group A.
the same process happens for group B.

Example:

(0,0)
1
2
(0,1)
3
4
(0,2)
5
6
(1,0)
7
8
(1,1)
1
2

becomes:

(0)
9
12
(1)
8
10

result test.gh (4.9 KB)

I tried few ways like flip matrix, it gives error and I am not sure what code should I write in Path Mapper

@Mahdiyar if you had time would be appreciated to take a look plz

thanks
-Azin

The addition in your example does not make sense but I think what you’re looking for is Split Tree

split_tree.gh (8.3 KB)

1 Like

Well … if you are familiar with coding (if not recycle it) that’s rather very simple: it’s just a GroupBy LINQ query and then some iteration on items.

DataTrees_GroupByIndices_AndSum.gh (114.9 KB)

2 Likes