number of pairs that are member of a class of one of the given partitions

53 Views Asked by At

Suppose I am given a set of S partition of universal set A, define pair as (a,b) iff elements a,b are members of one of set in at least one partition. I want to know how many pairs in S.
Example: $$A = \{1,2,3,4,5\}$$ $$S = \{ s_1=\{\{1,2\},\{3,4,5\}\}, s_2=\{\{1\},\{2,3,4,5\}\}, s_3=\{\{1\},\{2\},\{3\},\{4,5\}\} \}$$ Pairs: (1,2) (2,3) (2,4) (2,5) (3,4) (3,5) (4,5) Number of pairs = 7
Is there an algorithm that takes less than $O(n^2)$, $n=|A|$ or correct keywords or name of this problem?