I have an array of java.awt.Rectangle
s. For those who are not familiar with this class, the important piece of information is that they provid
Connected components.
Alternatively, because you only have rectangles you may be able to design an very efficient sweep line algorithm.
I would expect the best algorithm to take at least O( n^2 )
time because given n
rectangles there are O( n^2 )
possible intersections, and any algorithm to compute what you want would need to consider all intersections at some point.