Cross-referencing the Branches of a Data Tree

I want to “interlace” multiple lists into a single multi-level tree and then “flatten” the tree into a single level.
After the first step, I want to have a tree that on branch {i, j, …, k} has a list with element i of the first list, element j of the second list, …, element k of the last list.

To better explain, lets say i have tree lists:
A, B, C

1, 2, 3, 4

a, b

I want a tree with:

A1a on branch {1,1,1}, A1b on branch {1,1,2}, …, B3b on branch {2,3,2}, … C4b on branch {3,4,2}
For a total of 3*4*2 = 12 branches.

Lastly I want to flatten everything into a single level tree with the lists on branches {1}, {2}, …, {12}.

I managed to do this with a python script (see the screenshot)

, but I’m surprised you can’y do the same with basic components. Is there a way I’m missing?

Of course you can do this with basic components.


You mean:

{0;0;0}
[0] A
[1] 1
[2] a

{0;0;1}
[0] A
[1] 1
[2] b

{2;3;1}
[0] C
[1] 4
[2] b

?

24 branches.

A very manual method:

which, if you don’t care about the intemediary steps:

Your screenshot is useless, it does not show the script.

It would have been better to share the definition.

BE IMPRESSED!!!

Cross-referencing Branches of a Tree VR1.gh (16.9 KB)

No? Okay. Well I am impressed with myself. :blush: Iterationless, on the basis of mixed‑radix combinatorial indexing.

This is the best solution imho. Not too complex and it reaches the goal. Thank you very much.

Now excuse me but I have to go burning my Engineering PhD after 2*3*4=12

I’m a bit impressed by how difficult this is with basic components. But also a bit impressed by your solution, I admit it

Iteration is just not a thing in GH1. There is a reason why Anemone has popularity. In the GH2 it will be able to be done in clusters.

Honestly the goal was to show the results and I think the screenshot did exactly that. I did not need to debug my scripts and reverse engineering them looked like a more complex alternative than just looking at the screenshot.

Exactly. At the end of the day this was just

out = []
for a in A:
  for b in B:
    for c in C:
      out.append([a,b,c])
      #or
      my_function(a,b,c)

If I am not wrong you can also do a weave like this

Yes.

No.

Yes!

:sweat_smile:

Unfortunately it doesn’t work and you can see it in your screenshot: the lists do not “start over”.
The output of your version is (copied directly from GH):

{0;0;0;0}
A
1
!
{0;0;0;1}
A
1
?
{0;0;0;2}
A
2
?
{0;0;0;3}
A
2
?
{0;0;0;4}
A
3
?
{0;0;0;5}
A
3
?
{0;0;0;6}
A
4
?
{0;0;0;7}
A
4
?
{0;1;0;0}
B
4
?
{0;1;0;1}
B
4
?
{0;1;0;2}
B
4
?
{0;1;0;3}
B
4
?
{0;1;0;4}
B
4
?
{0;1;0;5}
B
4
?
{0;1;0;6}
B
4
?
{0;1;0;7}
B
4
?
{0;2;0;0}
C
4
?
{0;2;0;1}
C
4
?
{0;2;0;2}
C
4
?
{0;2;0;3}
C
4
?
{0;2;0;4}
C
4
?
{0;2;0;5}
C
4
?
{0;2;0;6}
C
4
?
{0;2;0;7}
C
4
?

So you have “!” in the first item, then “?” in all the following ones (e.g. you have “A2?” twice, but no “A2!”).
Same for the second list: you have two "1"s, two "2"s, two "3"s and then they are all "4"s

Oh shoot, didn’t notice that. Here I python returns =True for identical.


Alternative.gh (17.9 KB)

You could have just checked if Set Difference (S) produced an empty tree, but yes! with the Repeat Data component, it now works. :+1: