Finding the Number of Sub-branches in Each Branch in a Tree

Hi Everyone,

I have a tree that consists of branches. In the figure below for example, Branch {0} has 6 sub-branches (if we may call it like this): {0;0} … {0,5}. So whole tree has sub-branches and the branches don’t have the same number of sub-branches in real situation.

I have uploaded a copy of this GH file and internalized the values.

Tree_With_Branches_&_Sub-branches.gh (16.7 KB)

Is there a way I can know how many sub-branches each branch has? In other words, I need to extract the highest value of B in A in the path {A;B}. Thank you so much for your support…

Hi @Sam24,

what about something like this? The result gives you the number of the branch and the number of sub-branches included in it. I tested with other variations and it seems to work, but it may depend on your original tree structure.

Sub-branches.gh (10.7 KB)

1 Like

Hi @fcegnam ,

This exactly what I need. Thank you so much and much appreciated!

1 Like

if you want to save some components, you can use Deconstruct Path instead of this group:

and if data in the branch is “groupable”, you can shortcut the whole thing in 3 components (you can even just List Item instead of Group, just to keep the branch “alive”, because it’s not the number of items in a branch but just if the branch exists or not :+1: )

Sub-branches_Re.gh (20.0 KB)

2 Likes

Hi @inno,

I did not know about the grouping option… :sweat_smile:, it is definitely faster!