Tree structure

Hi everyone,

In the routine I’ve attached, my starting point is a tree where some branches share identical elements. My target is to obtain a tree where each branch contains the elements that are common across its sub-branches (see attached image). To achieve this, I created an ID for each branch (x_y), but I’m struggling to get the sorting right. Can anyone help me with this?

Thank you very much!

Forum6.gh (10.1 KB)

Forum6.gh (16.0 KB)

I would have done it almost like you did, except for some flatten/graft difference at the end (replace path component is for trees, but the path lists in SEARCH and REPLACE inputs are usually lists, not trees)

You can achieve it with Tree Statistics + Replace Paths


ReplacePaths.gh (11.6 KB)

A simpler approach without using replace paths -


Forum6_solved.gh (15.2 KB)

Also, your path number for A_B is {0;0;1} and {0;0;2} which is incorrect as counting starts from 0. It should be {0;0;0} and {0;0;1} unless you have a specific reason for use the former method

Thank you very much for your response. It works perfectly for this case. I don’t usually use the Explode Tree component because it requires manually entering the number of branches.

Thank you very much. The routine works perfectly as long as they are single-character strings (or texts). Thanks again!

If they are just strings.

i would try this for general case of strings and not just single charachters

use @ or whatever you like, just make sure it doesn’t appear anywhere else on your original strings