Matching random trees automatically based on specific values

Hi everybody!

I am trying to solve a situation where I have a list of names+values (i.e. L2.2-H = 20, L2.2-V = 40, etc), and in the other hand I have a specific tree structure with the same values only (15, 20, 30, 40, etc) with different tree structure I would like to keep. Basically, I would like to transfer/match the values from the first list to replace the values of the second list accordingly of their same values. Any ideas? Thanks in advance!


matching.gh (6.8 KB)

Hi Rickson,

Yes I am aware about this, I am trying to automatically find these index values from the input data. Thanks!

But its like you said, its kinda random. There are lots of ways to do this, most depending on how the trees are generated but given the data as is its more of a manual alignment. No way to create/replace sets.

Hi Rickson,
If we know the values from both list (L2.2-H = 20, its value is 20), so matching these sets of the first list with the second list will give us the index in the correct order automatically, so we can reorganize the first list as per the second one.

But L6.2-H=20 is the same value as L2.2-H = 20. If your branched data was smarter it would be easier, hence the need for context.

That’s true, for instance, if we can replace the values of 20’s in the list 2 with the ones that has the same values from the list 1 its ok, the order of L6.2-H or L2.2-H (which one comes first) its not relevant, as long they match with the same values between the items in the list 2, that’s the goal.

I would like to automatically replace the values from list 2 with the ones from list 1, but keeping the data structure from the list 2.

The values in the “data treeto match” are duplicated. Is it important that the first occurrence of 15 on the right is matched up with the first 15 value in the other list?

Reason I ask is because Sort does not guarantee that ordering is retained for identical values. The usual solution to that is to add increasing but tiny amounts to all the sorting keys, cementing the order.

This is all very difficult since you’re dealing with different tree topologies. I’d recommend flattening your data-to-match tree, solving the problem with just lists, then ultimately unflattening the penultimate list using your original data as a guide.

1 Like

Hi David!
Thanks for your quick reply, in regards your question, no, is not relevant the order on how the data it’s been organized at the treetop, as long their values matches with the order listed from the referenced data (List 2). The goal it’s to have the data from List 1 ordered as per the data from List 2, they both have the same values.

Would you have some ideas how to get there? Many thanks!

Per your other post this is all user data, why not keep it structured??

If you post a actual file this would be much easier.