Reputation: 33093
Consider a set A of n finite sets, whose members are not necessarily disjoint. Let P={P[1], P[2], ..., P[m]} be a partition of A, and for each i in 1..m, let U[i] be the union of all of the elements of P[i]. So U={U[1], U[2], ..., U[m]}. I would like an algorithm to a find a P such that the corresponding U is a partition, and such that the difference in cardinality (i.e. size) between the smallest and largest elements of U is minimised.
Characteristics of the data:
Upvotes: 2
Views: 1911
Reputation: 1597
I'd start with the intersection graph of A, which has nodes elements of A and edges when the two nodes have a non-empty intersection. Each connected component of this graph has to be contained in a single P(i) for some i.
let C(1),...,C(k) be the connected components of the graph. Let
size(j)=|union(a in C(j))|
Now you can rewrite the problem in terms of the size(i) values, with i=1...k. Namely, given positive integer values s(1),..,s(k). For a subset P of [1,..k] we define s(P)=sum(j in P) s(j).
We want to find a partition P'=(P'(1),...,P'(m)) of [1,..,k] with the condition that it minimizes the value:
max s(P'(j)) - min s(P'(j))
Therefore, we really need to know not the likely sizes of the elements of A, but the likely sizes of the connected components of the graph to come up with a "best" algorithm.
Upvotes: 0
Reputation: 33093
My necklace analogy in the question comments suggests this solution:
I'd be interested to know if there is a more efficient solution. In particular, I have a hunch that the repeated use of the bin-packing algorithm in step 4 is not sensible.
Upvotes: 1