Flipping tree in a special way

Hi Guys
How to rebuild this tree so the current path index becomes the item index and the item value becomes the new path?


tree.gh (6.7 KB)

is this the right description of the structure you’re looking for?

this is the only thing that came to my mind :slight_smile:

the_weirdest_structure.gh (11.0 KB)

[edit: I think I got these two columns inverted .___. ]

Hi inno
I’m not sure of your intensions, maybe it is better to explain on the example:
image
Branch {12} has three items {12;0} with value 36, {12;1} with value 4 and {12;2} with value 5.
I need them to become {36;12}, {4;12} and {5;12} respectively.
The following branch {13} has three items {13;0} with value 37, {13;1} with value 38 and {13;2} with value 12. I need them to become {37;13}, {38;13} and {12;13} and so on.
In short: the branch becomes an item, the value becomes branch.
The new structure, in this case, would have a forty-something branches with max ca. 11 items (it may vary from 0 to 11).

I think this reflects what you asked in the example:

the_weirdest_structure_Re.gh (14.3 KB)

I actually don’t know if is there a way to reference the Value of an item in Path Mapper, otherwise things would become MUCH easier :slight_smile:


but please note that the second value in the paths, for instance the 12 in the path {5;12} is not the index of the item itself

in the following image:

if you want to refer to first item in branch {12}, it will be {12}(0), not {12;0}
to make it work like in your description, we need to graft the tree in such a way the index of each item is translated as a new sub-branch

it looks like a silly distinction, but it makes a big difference in case like the following, where you can’t expect the trimmed branch to be maintained as index of the items, and that is also the reason why I wasn’t understanding at all what you meant in your first post :slight_smile:

Unfortunately, we are still away from solution. I keep scratching my head.
As I said, the valid tree would have 40+ branches with 0-11 items each.
This is nowhere close:
image
I agree that inserting Value in path Mapper would be piece of cake.

that is the fruit of the following :slight_smile:

so we go back to the previous question :slight_smile:
because to have an item at index n you need the list to have at least n-1 existing items, are those going to be Null-s ?

Yeah, there will ne nulls, for sure.

I have managed to get what I wanted using different methods, involving sets toolbar.
It was an exercise to extract specific data from the database. Thanks for trying.

if you don’t mind sharing the solution process, I’d be happy to learn!

I did not find the tree solution. It was weird task, as you described it.
I found the way to avoid the problem I created.

2 Likes