Renumber tree by regrouping similar items


I need to renumber a tree as follows :

Well, please look at my attachments.
For now i made it with VB code. But i’d like to developp it with GH components, such as Path Mapper.

Thanks in advance


renumber (10.7 KB)

I don’t cleary know what you want from that picture. So I think you want that the marked number of the Output = marked number of Input. If that’s what you want, may have a look at this.

renumber (17.0 KB)

In fact the output tree I want is exactly what is shown in the screenshot.
The VB component does the job well… but i don’t want VB component.

Like this?

renumber (15.8 KB)

1 Like

Wow! That’s it :slight_smile:

I was working on a similar logic to HS_Kim, using sets but as all your branches in the original tree are the same length i think it can be shorted to this. If they are various lengths in a larger code and mixed up your would just need to add a Member Index and an item to sort the path lengths before the partition component

renumber tree (9.9 KB)

Ok I see where i was wrong, Updated and even simpler as you can use the numbers to set the paths directly. :grinning:

renumber tree components (13.7 KB)


Indeed, it’s shorter.
And much faster also (i tested your code with some big tree).
Thank you!

Oh ok sorry, than I got you wrong
Even when there is a really great and short solution, here’s another :smiley:

renumber (14.2 KB)

Thanks, Tim

Metahopper and Treefrog provide a rich toolset for expressing these kinds of dynamic path assignment operations:

renumber (8.8 KB)

1 Like