I have a set of sets : {1,2,3...}, and I want to find all pairs (, ) such that ∩≠∅.
The only way I could come up with was repeating condition check Σ time.
If I can represent this with a python-ish pseudo code:
from copy import deepcopy
setA = {A1, A2, A3, A4....}
setACopy = deepcopy(setA)
intersectingPairs = set()
for Ai in setA:
for Aj in setACopy:
if isIntersect(Ai, Aj):
intersectingPairs.add((Ai, Aj))
setACopy.remove(Ai)
I expect this to be very time consuming as the size of setA increases.
Is there a better algorithm that I can refer to?