Comparing Nested Lists Against Themselves but not Other Nested Lists?

Good afternoon all,

I’m having some trouble trying to compare nested lists against themselves, but not against the other nested lists.
(please note screenshot does not contain working graph)

For example I have lists of curves. I want to find the largest distance between curves for each list.

I hope this makes sense, please let me know if I need to explain something further.

Thank you in advance!

Not an easy problem to solve through Dynamo alone, but I think I’m pretty close. The native cross product lacing didn’t seem to achieve what I thought it was going to, so I instead created progressively smaller slices of the data:

If you have curves [C1, C2, C3, C4] You need to compare them like this:

Distance from C1 to each of [C2, C3, C4]
Distance from C2 to each of [C3, C4]
Distance from C3 to each of [C4]

This is achieved by using List.TakeItems (to get C1, C2, C3) and ListRestOfItems (to get C2, C3, C4). After we have these, we use a decreasing range to get progressively smaller slices of the List.RestOfItems lists. So, it may initially be like this:

[C2, C3, C4]
[C2, C3, C4]
[C2, C3, C4]

but by using List.TakeItems with the range [3, 2, 1] as our input, we’re left with this:

[C2, C3, C4]
[C3, C4]

This is much easier to do if all of the lists are the same sizes, but if they are different you just have to use a List.Count node and create different ranges for each.

In the below example, I am showing that the largest distance was found in each of the first tests for each group, pointing to curve C1 as being the farthest from one of the other curves.

Here are the distances from curve C1 to C2, C3, and C4:


By this logic, we can conclude that C1 and C2 are the most separate curves.

This graph is unfinished, as it doesn’t actually return the curves farthest from each other, but the logic is mostly there.

dist.dyn (42.4 KB)


The levels get a bit tricky (it’s probably easier using Python), but here’s another way which uses cross product, although on reflection @cgartland’s solution is more elegant. Assuming you want the pair of curves from within each nested list that have the greatest DistanceTo:

The three colours show different nested groups and the longest line is linking the two lines farthest apart

42309_Max.dyn (69.5 KB)

1 Like

Thank you both for your feedback! Very clever use of the OOTB nodes.

I attempted to get my result with Python and achieved my desired result. Please see screenshots below for solution:

Dynamo Graph:


Thank you both again for your time. Have a great day!

1 Like