I apologize if this has been answered elsewhere, but I have yet to find it using my limited algorithmic terminology. ;)
My situation is this - I have a variable number of data elements, each of which has been tested against each other data element to determine compatibility. The compatibilities are stored in the equivalent to a 2-dimensional array (truth table?). My goal is to generate all possible combinations of these data elements, where every element within the combination is compatible with each other element.
For example, if element 1 (of 4) was compatible with elements 2 and 4, and element 2 was compatible with 1, 3 and 4, element 3 was compatible with 2 and element 4 was compatible with 1 and 2, my truth table would look something like:
1) {1,1,0,1}
2) {1,1,1,1}
3) {0,1,1,0}
4) {1,1,0,1}
The combinations that I want from this would be:
1,2,4
1,2
1,4
1
2,3
2,4
2
3
4
My approach works well in many situations, but is sometimes bogged down badly when the number of elements exceeds 5000, depending on the data sets. My secondary challenge is to determine the pattern that brings execution time up from 5 seconds to 3 hours...
Just from looking at the boolean array, I just feel like there MUST be an easier solution out there - an algorithm named after somebody, maybe. As you might infer from the above, I don't necessarily know how to ask the question. ;)
Thanks for your time!