1

Given a set of integer intervals SI = {I1,I2,...,In}, I need to find the smallest partition of SI such that all the intervals of a subset of the partition are intersecting.

That is find the smallest P = {Pi : Pi⊂SI } where Pi∩Pj=∅

and such that ∀Ia,Ib∊Pi, Ia∩Ib≠∅

For example :

Given, SI = {[0,7],[0,6],[1,2],[4,10],[5,10],[9,10]}

The output should be, P*={{[0,7],[0,6],[1,2]},{[4,10],[5,10],[9,10]}} where |P*|=2

What is the name of this problem in literature ? Can anyone hint an efficient optimal algorithm ?

My current solution is a greedy one where I iteratively find the maximum overlapping intervals (using a O(nlogn) time complexity subroutine). For the given example, this outputs a partition P={{[0,7],[0,6],[4,10],[5,10]},{[1,2]},{[9,10]}} of size 3.

enter image description here

J. M. Aziz
  • 29
  • 4
  • Try instead asking on [Computer Science Stack Exchange](https://cs.stackexchange.com/). – Lover of Structure Jun 10 '23 at 12:11
  • I would call this problem "[clique](https://en.wikipedia.org/wiki/Clique_(graph_theory)) partition": the I_i are vertices in a graph, and you're looking to partition the graph into cliques. Also, it's an [interval graph](https://en.wikipedia.org/wiki/Interval_graph), which makes the problem much easier. – Stef Jun 10 '23 at 13:01

2 Answers2

2
  1. Find the interval with the smallest endpoint. Some subset must include this interval
  2. Make a subset with the selected interval and all the intervals that start before that smallest endpoint. They all intersect with each other, since they all include an interval just before that smallest endpoint. Furthermore, any interval that starts later does not overlap the selected one and can't be included in the same subset.
  3. Repeat until you're out of intervals.

Usually, you would begin by sorting the intervals by end point, which makes all of this fast and easy.

Matt Timmermans
  • 53,709
  • 3
  • 46
  • 87
1

The I_i form a graph. This graph is an interval graph, which means it is easy to find a perfect elimination ordering of its vertices.

Take the leftmost interval I, ie the interval [a, b] with the smallest b. Convince yourself that for any two other intervals J and K, if J and K both intersect I, then J and K also intersect eachother. Thus, the set consisting of I as well as every interval that intersects I is a clique, and can be the first set of your partition.

Remove the intervals that are in this first set, then repeat the procedure to get the other sets.

Stef
  • 13,242
  • 2
  • 17
  • 28
  • Thanks for the terminology and references. I like the "clique partition". I agree with the property you affirm for I,J,K belonging to a same clique P_i. – J. M. Aziz Jun 10 '23 at 15:27
  • If I understand well. What you propose is a greedy solution like the one I proposed but adopting the perfect elimination ordering allows for an O(n) subroutine. – J. M. Aziz Jun 10 '23 at 15:28
  • @J.M.Aziz Yes, it's "greedy but in the correct order" so it actually returns the optimal solution. Actually, lots of problems can be solved like that, for graphs that have a perfect elimination order. – Stef Jun 10 '23 at 17:48
  • @J.M.Aziz Note that MattTimmermans and I are describing the exact same algorithm, just with different words. – Stef Jun 10 '23 at 17:51
  • 1
    Actually, I looked at yours before writing, but you say "take the interval [a,b] with the smallest a", whereas I say take the one with the smallest b. Taking the smallest a makes your next sentence incorrect, e.g., [ [ ] [ ] ] I guess this was a small mistake, but it wasn't clear that what you had in mind was correct overall. – Matt Timmermans Jun 11 '23 at 01:31
  • yes, it should have been the smallest b. I thought you were prooving that every partition is a clique in the interval graph. Didnot see that you were proposing the same algo as Matt :/ – J. M. Aziz Jun 11 '23 at 10:48
  • Indeed! Smallest b. – Stef Jun 12 '23 at 10:45