Emulate tree structure

Hi,

I have a guide tree which suffered a simple transformation: from a simple list (single branch) to a multi-branch tree were each branch groups consecutive values from the original list that are equal.

What I would like to do is NOT to implement the same procedure to my other lists BUT make them follow the exact same arranging strategy that the first list suffered:

My .gh file attached. Thanks!

Emulate tree structure.gh (14.3 KB)

In this way?

1 Like

Hi there – if I’m understanding you correctly: you could use “Partition List” with a pattern consisting of the tree branch lengths (use “List Length” to get each branch’s length).

I’ll admit I’m a bit unsure about what you want. So if you aren’t getting the help you’re looking for, you could try rephrasing the question using concrete examples of your before and after condition.

1 Like

Thanks! List Length + Partition totally works!

even if List Length + Partition List for sure works well in this simple case, please note List Length does not know about paths

I’d instead suggest to use the dedicated component called “Unflatten”, which is the opposite operation of Flattening, performed using a guide data tree as reference, from which paths addresses are also taken

Emulate tree structure_Unflatten.gh (12.4 KB)

2 Likes

Hi @inno thanks a lot for the tip! It’s probably wiser to use unflatten instead then, to avoid path miscommunication.

Anyway, I’ve encountered a problem. Please take a look at both my original panels, items 510, 511, 512:

However, my output is not matching up:

I’m unsure whether the mistake is coming from:

  1. Create Set > Member Index > Repeat Data to group my data in a rational way
    OR
  2. Unflatten operation to match the tree structure (as stated, List Length + Partition also works, but Unflatten is safer)

Emulate tree structure Solution Testing.gh (21.8 KB)

I think I misinterpreted your question

using Unflatten is fine as long as you just want to divide a list of n items into branches following a reference data tree with the same total number of items n

regarding the thing that items are also shuffled/sorted, it means you have to go through a List Item to rebuild that particular structure

so, in this case -if now I have understood correctly- you use the Member index on the set of the first tree, then List item to partition that list, and if you want to follow the same partitioning rule → you can just use the very same List Item on a different list of same number of items, like:

Emulate tree structure Solution Testing_Re.gh (15.1 KB)

Unflatten is useful just if the only one operation you want to do is partitioning the list into a data tree, keeping untouched the initial sorting order of its items

2 Likes

Thanks a lot for the clear explanation of Member index + Unflatten vs List item. It’s working successfully!