Selecting (n) items from each branch of a tree

Hello fellow hoppers! Question here. I have fairly simple question. I want to make random selection of (n) numbers from each branch of data tree. How can I achieve that? I’m guessing there is a known method but I could not figure it out on my own other than the way in the attached file, which is ugly. Came here to seek some help, thanks in advance.

selectfromTree.gh (26.5 KB)

Here is a way with Random Reduce logic.


RandReduce.gh (17.7 KB)

Thanks Mike, but I need to keep the same number of branches and remove (or select) a constant number from each branch. Something like this, just maybe a little nicer and scale-able…selectfromTree2.gh (19.7 KB)

Blah… The branch count was my stupid mistake not paying attention, here is that fixed.


RandReduce.gh (16.2 KB)

remove (or select) a constant number from each branch.

That is a lot easier, just be aware of your branch lengths, if they vary you may hit zero on some.


RandReduceConstant.gh (13.1 KB)

and if you want to remove a different pre-defined amount from each branch just use a list of values grafted into Random Reduces R input.

1 Like

You’re the boss, @Michael_Pryor, thought I was going crazy for a sec… will watch for those branch lengths, thanks again!

Hi
I have a question which I think it’s related to this topic.
I wanna dived list “A” to the values of the list “B” and I need to repeat values of list “A” in each branch according the attached pic.

Already answered to your same question in another post…

2 Likes

And here’s another way using Stack Data.

4 Likes

thanks, it’s clear