I'm struggling to figure out a formula that identifies the number of unique ways a group of geometries can be selected so that they form a continuous whole.
In the example below, there are 6 geometries. A valid selection could be a group of anywhere between 1 and 6, so long as they are contiguous. E.g. [A,B] works, as does [F,A,B], however, [E,A] is not valid, nor is [D,B].
Similarly, order does not matter: [A,B] and [B,A] should only be counted once.
My approach was to count the number of immediate neighbours that each geometry has, take the sum of these values, and subtract 1. This seems to hold true in a number of cases, but definitely not all.
The example here, according to my calculation should be groupable in 287 distinct ways (3*2*2*4*2*3-1=287).
This formula does not work when there are geometries with only a single neighbour. 2 rectangles, rectangle A and rectangle B, side-by-side for example. The formula would yield 1*1-1=0, whereas they could be grouped as [A], , or [A,B], ie 3 possible groupings.
I've spent so much time with this, and searched all over. Maybe I'm just not using the right terms, but I can't figure it out.
Thanks!
In the example below, there are 6 geometries. A valid selection could be a group of anywhere between 1 and 6, so long as they are contiguous. E.g. [A,B] works, as does [F,A,B], however, [E,A] is not valid, nor is [D,B].
Similarly, order does not matter: [A,B] and [B,A] should only be counted once.
My approach was to count the number of immediate neighbours that each geometry has, take the sum of these values, and subtract 1. This seems to hold true in a number of cases, but definitely not all.
Name | Neighbours |
A | 3 |
B | 2 |
C | 2 |
D | 4 |
E | 2 |
F | 3 |
The example here, according to my calculation should be groupable in 287 distinct ways (3*2*2*4*2*3-1=287).
This formula does not work when there are geometries with only a single neighbour. 2 rectangles, rectangle A and rectangle B, side-by-side for example. The formula would yield 1*1-1=0, whereas they could be grouped as [A], , or [A,B], ie 3 possible groupings.
I've spent so much time with this, and searched all over. Maybe I'm just not using the right terms, but I can't figure it out.
Thanks!