How to group numbers based on their similarity?

how to group numbers by there difference.gh (5.2 KB)

By saying similarity I mean the numeric distance between them.
For example, 1,2,3 has a distance of 1, 7,9,10 has 2 in maximum, but between 1,2,3 and 7,8,9 is 4.
So if I say I like to group the numbers by distance 4, they will be added into different tree branches which first branch is 1,2,3 and the second branch is 7,9,10.


group numbers by distance_2023Jun16a…gh (10.5 KB)

You didn’t say if the numbers are always in sequence or not? If not, Absolute (Abs, yellow group) should be used. Otherwise, negative numbers can appear which are always less than ‘Distance’.

This version uses random REAL numbers instead of integers, sorted or not.


group numbers by distance_2023Jun16b…gh (14.1 KB)

Have you tried using Point Groups?

-Brian

1 Like

Thank you very much!

This is brilliant, never thought it can be solved this way!