Original Post
I have a list of integer pairs, such as (2,3) (4,1) (1,2) (9,5) (6,7) (5,6) and I want to place these pairs into buckets, such that two pairs have at least one integer in common, but not all pairs in the bucket have to have a common integer: bucket 1: (2,3) (4,1) (1,2) bucket 2: (9,5) (6,7) (5,6) etc... What would be an efficient way to create these buckets? I was thinking maybe I would have to do something like a recursive merge? Because if I added (2,3) to a new bucket in a linear fashion, then checked to see if (4,1) would fit, I wouldn't be able to add it at that point, because (1,2) hasn't been added yet.