I apologize, I did not realize that this is the Beginners Forum, since your task is not what I would call a beginners assignment.
I just made a very simplified demo version, to see if it worked and how I could do justice to Mike's remarks. I'll give some code to illustrate what I mean, but a bit reluctantly, since this is an assignment. But I hope you get some ideas to implement in your own code.
For instance, to create the Map I was talking about, I have this:
and I have a Map creator like:
and I have a method to get the bits set in a long:
The process is then: starting with bitCount 1, traverse the List<Long>, determine the bits of each long, and add the corresponding sets as I described before, testing for the size of the result. Currently, I do an O(n) operation for each long, to get an idea of the speed, but that should be O(n*n).
Well, it took 2 minutes to calculate 5 of the 14 keys so far, so the real thing would take a complete holiday, I guess. I can think of some optimizations, but at the cost of making the whole thing even more complicated. It is certainly more complicated than I thought at first.
Anyway, I hope it is clear what I am talking about. But I would certainly start with a graph of only a few elements, to test whatever you have.