Faster Algorithms for the Minimum Red-Blue-Purple Spanning Graph Problem

Consider a set of n points in the plane, each one of which is colored either red, blue, or purple. A red-blue-purple spanning graph (RBP spanning graph) is a graph whose vertices are the points and whose edges connect the points such that the subgraph induced by the red and purple points is connected, and the subgraph induced by the blue and purple points is connected. The minimum RBP spanning graph problem is to find an RBP spanning graph with minimum total edge length. First we consider this problem for the case when the points are located on a circle. We present an algorithm that solves this problem in O(n) time, improving upon the previous algorithm by a factor of Θ(n). Also, for the general case we present an algorithm that runs in O(n) time, improving upon the previous algorithm by a factor of Θ(n). Submitted: August 2016 Reviewed: January 2017 Revised: January 2017 Accepted: February 2017 Final: February 2017 Published: April 2017 Article type: Regular paper Communicated by: S. Kobourov A. Biniaz, P. Bose, A. Maheshwari, and M. Smid are supported by NSERC. I. van Duijn is supported in part by DNRF84. E-mail addresses: ahmad.biniaz@gmail.com (Ahmad Biniaz) jit@scs.carleton.ca (Prosenjit Bose) ivd@cs.au.dk (Ingo van Duijn) anil@scs.carleton.ca (Anil Maheshwari) michiel@scs.carleton.ca (Michiel Smid) 528 Biniaz et al. Minimum Red-Blue-Purple Spanning Graphs


Introduction
Let S be a set of n points in the plane that is partitioned into three subsets {R, B, P }.The points of R are colored red, the points of B are colored blue, and the points of P are colored purple.A red-blue-purple spanning graph (RBP spanning graph) on S is a graph whose vertices are the points of S and whose edges connect the points such that each of the subgraphs induced by R ∪ P and by B ∪ P are connected.In other words, if we remove the red points then the resulting subgraph is connected, and if we remove the blue points then the resulting subgraph is connected.One may think of the purple points belonging to both the red set and the blue set.The minimum RBP spanning graph problem is to compute an RBP spanning graph that has minimum weight (total edge length).
The study of the RBP spanning graph problem is motivated by set visualization methods that attempt to reduce the amount of ink necessary to connect all elements of a set by Tufte's rule [19].In our case, we have a finite number of points in the plane, where each point belongs to one or two sets, namely the red set and the blue set.Since these two sets share points, one can reduce the amount of ink that is necessary to connect all elements of each set by computing the minimum RBP spanning graph of the whole point set.See the state-of-the-art report by Alsallakh et al. [4] for more information on visualizing sets and their elements.Euler diagrams are an alternative way to depict sets and their relationships.The problem of drawing Euler diagrams has been studied recently for both cases when the locations of the elements can be freely chosen (see e.g.[17,18]) and when the elements have to be drawn at fixed positions (see e.g.[3,8,9,10,15]).Drawings of sets that are defined over points in the plane have also been studied extensively (see e.g.[6,7,13]).
In this paper we study the minimum RBP spanning graph problem.When the points of S are located on a line and given in sorted order, this problem can be solved in O(n) time (see [11,12]).If the points of S are located on a circle and given in circularly sorted order this problem can be solved in O(n 3 ) time; specifically, it can be solved in O(k 3 + n) time, where k is the number of purple points (see [11,12]).For points on a circle, in Sections 3 and 4, we show how to improve the running time to O(k 2 + n).In [11] it is claimed that the general case of this problem is NP-hard; this claim is based on a reduction from planar 3-SAT.They also presented an O(n log n)-time (1 + ρ 2 )-approximation algorithm for this problem, where ρ is the Steiner ratio.However, in [12] it is claimed that the NP-hardness reduction of [11] is incorrect, and an O(n 6 )-time exact algorithm for this problem is presented.This algorithm uses weighted matroid intersection.In Section 5 we show how to modify this algorithm to run in O(n 5 ) time.Conclusions and open problems are presented in Section 6.
The input to the RBP spanning graph problem can be interpreted as a set of points in the plane and two primary color classes (red and blue in our case) such that each point belongs to one or more color classes (in our case the purple points belong to two classes).Recently, Akitaya et al. [2] considered this problem with more than two primary color classes; they showed that this version of the problem is NP-hard.For the case where the number of color classes is three, they presented a polynomial-time (2 − 1 3+2ρ )-approximation algorithm.

Properties of Minimum RBP Spanning Graphs
In this section we review some properties of minimum RBP spanning graphs.Given a graph G with vertex set S, and a set S ⊆ S, we denote by G[S ] the subgraph of G that is induced by S .
For three sets R, B, and P of red, blue, and purple points, respectively, we denote by G * (R, B, P ) a minimum RBP spanning graph on R ∪ B ∪ P ; this is denoted by G * when the triple (R, B, P ) is clear from the context.As in [11,12] we classify the edges of G * into red, blue, and purple.An edge is red if it connects two red points, or a red point and a purple point.An edge is blue if it connects two blue points, or a blue point and a purple point.An edge is purple if it connects two purple points.Note that G * does not contain any edge between a red point and a blue point.The subgraph G * [P ] that is induced by the purple points is acyclic, because otherwise we could remove a purple edge from a cycle and reduce the weight of G * without destroying the connectivity of ) is a spanning tree because otherwise we could remove a red edge (resp.blue edge) from a cycle without affecting the connectivity of G * [B ∪ P ] (resp.G * [R ∪ P ]).We refer to G * [R ∪ P ] as the red tree and to G * [B ∪ P ] as the blue tree.
Every red edge in G * is also an edge of a minimum spanning tree of R∪P , because otherwise we could replace it by another red or purple edge of smaller weight.The corresponding statement holds for the blue edges.Thus, the red edges of G * do not cross each other, and the blue edges of G * do not cross each other.The corresponding statements do not hold for purple edges.There can be purple edges in G * that are not present in any minimum spanning tree of the purple points.Moreover, a purple edge in G * can cross Θ(|P |) other purple edges [11,12].In [11,12] it is shown that the maximum degree of a purple point in G * is at most 18 and the maximum degree of a red point or a blue point is at most 6.Moreover, any optimal graph can be transformed to another optimal graph in which the degree of every purple point is at most 15 and the degree of every red point or blue point is at most 5.The proofs for these degree constraints inherited from the proofs of degree constraints of minimum spanning trees of a point set in the plane.

The Algorithm for Points on a Circle
Let S be a set of n points on a circle C that are colored red, blue, or purple.Let R, B, and P denote the set of red, blue, and purple points of S, respectively.Let k denote the number of purple points, i.e., k = |P |.The problem is to compute a minimum RBP spanning graph for S.Although for points in the plane, and even for points in convex position, a purple edge can be crossed by other purple edges, for points on a circle, purple edges cannot be crossed by other purple edges.Based on this, Hurtado et al. [11,12] presented a dynamic programming algorithm that solves this problem in O(k 3 + n) time.We use a similar dynamic programming approach and improve the running time to O(k 2 + n).First we review some crucial results from [11,12].
Lemma 1 (see [11,12]).Let S be a set of points on a circle, each one of which is colored either red, blue, or purple.Let G * be a minimum RBP spanning graph for S. Then the following statements hold.3.For any purple point p in S, let p be the point on the circle diametrically opposite to p, and let SC be any of the two closed semicircles containing both p and p .Then in G * , p has at most one purple neighbor in SC, and thus at most two purple neighbors in total.

The Dynamic Programming Algorithm
In this section we give an overview of the dynamic programming algorithm presented in [11,12].Assume that the points of S are circularly sorted.Let p 1 , . . ., p k be the purple points in clockwise order.For any 1 i k, let S i be the set of red and blue points between p i and p i+1 .Assume that all indices are taken modulo k.Let G * be a minimum RBP spanning graph for S. By Lemma 1 no edge of G * that is incident to a point in S i can cross segment p i p i+1 (p i p i+1 is not necessarily an edge of G * ).Thus, a solution for each set S i can be computed independently.Moreover, this is analogous to the case when the points are on a line, and thus, it can be solved in linear time for all sets S i .
For any two purple points p i and p j , Lemma 1 guarantees that if p i p j is an edge in G * then it cannot be crossed by any other edge of G * .This introduces two independent subproblems, one to the left of the oriented segment p i p j , and one to the right.Each subproblem has four different types P C, RC, BC, and N C.In the P C-type, p i and p j are connected in both red and blue subgraphs.In the RC-type, p i and p j are connected in the red subgraph but disconnected in the blue subgraph; any solution for this type must connect p i and p j in its blue subgraph.In the BC-type, p i and p j are disconnected in the red subgraph but connected in the blue subgraph.In the N C-type, p i and p j are neither connected in the red subgraph nor in the blue subgraph.The algorithm maintains four tables, P C, RC, BC, and N C, each of size O(k 2 ), that are indexed by pairs of purple points.Each entry [i, j] of each table, stores the length of a minimum RBP spanning graph of the corresponding type for the point set {p i , p i+1 , . . ., p j }.Based on this, the length of an optimal solution can be found as min Let Λ ∈ {P, R, B, N }.The entries of each table are filled in order, so that when it is time to compute the value of an entry ΛC[i, j], all the entries corresponding to smaller problems, i.e., subproblems introduced by purple pairs to the left of the oriented segment p i p j , have already been computed.In order to fill entry ΛC[i, j], where 1 i < j k, the following two cases are considered, and the one with minimum cost will be stored in ΛC [i, j].See [11,12] for more details.
Figure 1: Solving subproblem (i, j): (a) p i is connected to a purple point p h , and (b) p i is not connected to any purple point.
1. p i is connected to some purple point(s) in an optimal solution of the subproblem (i, j); recall that by Lemma 1, p i can be connected to at most two purple points.Let p h be the one in the sequence p i+1 , . . ., p j that is closer to p j , see Figure 1(a).Note that p i and p h are connected in both red and blue subgraphs.Therefore, p h and p j must be connected in the same way as p i and p j .Since we do not know p h , we try all possible candidates and keep the one minimizing the cost, i.e., ΛC[i, j] = min This case takes O(j − i) time.
2. p i is not connected to other purple points in any optimal solution of the subproblem (i, j).Now Consider p i+1 .By Lemma 1, in an optimal solution no edge can cross the segment p i p i+1 .Since no purple edge is incident to p i , the segment p i+1 p j cannot be crossed either; see Figure 1(b).Therefore, an optimal solution for the subproblem (i, j) can be computed by combining the solutions associated to the subproblems (i, i + 1) and (i + 1, j).See [11,12] for more details.This case takes O(1) time.
Based on the description above, the total running time of the algorithm is O(k 3 + n).

Improving the Running Time
In this section we show how to improve the running time of the algorithm presented in Section 3.1 to O(k 2 + n).First we prove Lemma 2 which plays an important role in this regard.
A chord of a circle is a straight line segment whose endpoints lie on the circle.For any two points p and q on C let ı pq denote the smaller arc of C that has endpoints p and q.
Lemma 2. Let S be a set of red, blue, and purple points located on a circle.Let P be the set of purple points.Let a and b be any two points of P such that ı ab contains at least two points of P \ {a, b}.Let a * , b * ∈ P be the purple neighbors of a and b on ı ab, respectively.Proof.First we prove statement 1 of the lemma.The proof is by contradiction.Assume there exists a minimum RBP spanning graph G * for S that contains ab.Recall that G * consists of a red tree and a blue tree; moreover, the purple edges of G * belong to both trees.Let R a and R b be the two red trees obtained by removing ab from G * , such that a ∈ R a and b ∈ R b .Let B a and B b be the two blue trees obtained in a similar way.
We prove this claim for the case where a * ∈ R b and b * ∈ R a ; the proof for the other case is similar.By Lemma 1 (item 2) no red edge or blue edge can "jump" over a * or b * .Thus, in order to have a * ∈ R b and b * ∈ R a there must be two purple edges in G * that cross; this contradicts Lemma 1 (item 1).This proves the claim.
then by replacing the edge ab in G * with the purple edge a * b we obtain a valid RBP spanning graph that is smaller than G * (note that a * b is shorter than ab); see Figure 2(a  Theorem 2. Let S be a set of n points located on a circle that are angularly sorted, and each one of which is colored either red, blue, or purple.Let k be the number of purple points.Then, a minimum red-blue-purple spanning graph on S can be computed in O(k 2 + n) time.
Proof.Let P be the set of purple points in S. We define three sets of edges on P , as follows: Let E 0 be the set of all purple edges ab for which the arc ı ab does not contain any point of P \ {a, b}.Let E 1 be the set of all purple edges ab for which the arc ı ab contains exactly one point of P \ {a, b}.Let E 2 be the set of all purple edges ab for which the arc ı ab contains at least two points of P \ {a, b} and |aa * | + |bb * | > |ab|, where a * and b * are the two points of P \ {a, b} that are neighbors of a and b on ı ab, respectively.Let As a consequence of Lemma 2 there exists an optimal solution in which all the purple edges belong to E P .Thus, in case 1 of the dynamic programming algorithm, instead of looking at all pairs (p i , p h ) it is enough to only consider the pairs (p i , p h ) that are connected by an edge in E P .Each pair (p i , p h ) is considered only for the subproblems that have p i or p h as an endpoint; the number of such subproblems is O(k).Thus, the total time we spend for case 1 is O(k|E P |).Therefore the total running time of the algorithm is O(k|E P | + n).
Note that E P can be computed in O(k 2 ) time in the preprocessing phase.We are going to show that |E P | = O(k); this will complete the proof of the theorem.Each of E 0 and E 1 contains at most k edges.By Theorem 1 (where P and E 2 play the role of V and E), no three edges of E 2 pairwise cross.Agarwal et al. [1] have shown that any graph with n vertices that can be drawn in the plane such that no three edges pairwise cross, has O(n) edges.Thus, E 2 has O(k) edges.Therefore,

Proof of Theorem 1
In this section we prove Theorem 1.First we prove some lemmas that will be used in the proof of the theorem.The following theorem is a restatement of Theorem 7.11 in [5].
Theorem 3 (See [5]).If Proof.Without loss of generality assume C is centered at o and has radius 1.We consider two cases: (i) o is on ad, and (ii) o is not on ad.First, we prove case (i).Then, we show how to reduce case (ii) to case (i).Assume o is on ad, that is, ad is a diameter of C, and thus, |ad| = 2. See Figure 5 Now we show how to handle case (ii).Assume o is not on ad, and thus, ad is not a diameter of C. We show how to reduce this case to case (i).Follow Figure 5

Proof of Theorem
Recall that V is a set of points on a circle C.  Now we have all the tools that we need to prove Theorem 1.For the sake of contradiction assume that three edges aa , bb , and cc of E are pairwise crossing.Observe that if we remove all points of V except a, b, c, a , b , c , and then recompute E, the edges aa , bb , and cc will remain in E. Thus, without loss of generality we assume that V = {a, b, c, a , b , c }.Moreover, assume a, b, c, a , b , c appear in clockwise order on C. Let be the triangle whose vertices are the intersection points of aa , bb , and cc .We differentiate between the following two cases: (i) o is in the interior of , and (ii) o is not in the interior of .We will get contradictions in both cases.
In view of Corollary 2, we have |bc| This and Inequality (2) imply which contradicts Inequality (1); this is a contradiction for case (i).Now we are going to handle case (ii) where o is not in the interior of the triangle formed by the intersection of aa , bb , and cc .Without loss of generality assume that o is on or to the right side of all the oriented segments aa , bb , and cc ; see Figure 7 Thus, if o is on or to the right side of all the oriented segments aa , bb , and cc , then Inequality ( 4) is valid.In fact, Inequality (4) is the same as Inequality (3) where a and c play the role of a and c , respectively.Therefore, without loss of generality, from now on we assume that a is on a and c is on c , that is, aa and cc are two diameters of C. Let α = ∠aoc = ∠coa .We claim that α π 3 .Assume α > π 3 .This implies that ∠aoc 2π  Let p be the intersection point of C 1 and ı ac.Let ı ap and ı pc be the two sub-arcs of ı ac.Similarly, let q be the intersection point of C 2 and ã c , and let â q and qc be the two sub-arcs of In order to show this, it suffices to prove that where β = 2 arcsin 1 − sin α 2 , for all 0 < α π 3 .Inequality (5) simplifies to where 0 < α π 3 .Let u = sin α 2 .Then, Inequality (6) simplifies to where 0 u 1 2 ; it is easy to verify that Inequality (7) is valid in this range of u.This contradicts the fact that |bc| + |a b | > |bb |, and hence the existence of bb in E; this is a contradiction for case (ii).This completes the proof of Theorem 1.

The Algorithm for the General Case
In this section we consider the general case of the problem, where the input points are not necessarily on a circle.An O(n 6 )-time algorithm for this problem is presented in [12], where n is the total number of points.This algorithm is greedy and based on matroid theory.In fact it is based on the existence of an efficient algorithm for the weighted matroid intersection problem.In Section 5.1 we give an overview of this algorithm.We also add more details on the weighted matroid intersection algorithm.In Section 5.2 we show how to improve the running time to O(k 5 + k 3 n + kn 2 ), where k is the number of purple points.

Overview of the Previous Algorithm
Let S = R ∪ B ∪ P .Let E be the set of edges of the complete geometric graph on S except the edges that connect a red point to a blue point.Let m = |E| and n = |S|.Note that m = Θ(n 2 ).Let G = (S, E) be the edge-weighted graph with vertex set S and edge set E, where the weight w(e) of an edge e ∈ E is its Euclidean length.Let G * = (S, X * ) be any minimum RBP spanning graph on S. Note that X * is a subset of E.
Let I r be the collection of all subsets of E that form a forest on R ∪ P .Similarly, let I b be the collection of all subsets of E that form a forest on B ∪ P .The pairs (E, I r ) and (E, I b ) are matroids (and known as graphic matroids).See [16,Chapter 39] for the basic concepts of matriod theory.The elements of I r are called independent sets.The independents sets of I r that have the maximum number of elements are called bases.Thus, the bases of I r are the spanning trees for R ∪ P .Let B r be the set of bases of I r .Similarly let B b be the set of bases of I b .We define supersets of B r and B b as follows: is the set of all spanning graphs of R ∪ P (resp.B ∪ P ).Then, the minimum RBP spanning graph problem is formulated as follows: Note that the complement of any element Y in I r ∩ I b is a valid RBP spanning graph that belongs to Q r ∩ Q b and spans both R ∪ P and B ∪ P .On the other hand, any element X in Q r ∩ Q b is a valid RBP spanning graph whose complement belongs to I r ∩ I b .Thus, the complement of a solution for (P0) is a solution for (P1) and vice versa, that is, both problems are equivalent.The problem (P1) is an instance of the weighted matroid intersection problem in which we are looking for a common element of I r and I b that has maximum-weight; for this problem a polynomial-time algorithm exists.In the following paragraph we give a brief description of an algorithm that finds a maximum-weight independent set Y * in I r ∩ I b .Then, X * = E \ Y * will be a solution for (P0).
The general idea of the (maximum) weight matroid intersection algorithm is as follows (see [16,Chapter 41] for more details).Let I be a common independent set that has the maximum weight among all the common independents sets of size |I|.The algorithm computes a common independent set I , with |I | = |I| + 1, that has the maximum weight among all the common independent sets with |I| + 1 elements.Let M be the maximum-size of a common independent set of the two matroids.Since I 0 = ∅ is a maximum-weight common independent set of size zero, the algorithm iteratively finds common independent sets I 0 , I 1 , . . ., I M , such that I i is a maximum-weight common independent set of size i, i.e. |I i | = i.Note that I M is a maximum-weight common independent set of maximum-size.Taking one among I 0 , . . ., I M of maximum weight, we have a maximum-weight common independent set.
Since the minimum-size of an element in Q r ∩Q b is n−1, the maximum-size M of a common independent set of I r and I b is |E|−(n−1) = m−n+1.Therefore by computing I 0 , . . ., I m−n+1 one can obtain a maximum-weight element of I r ∩ I b ; the algorithm presented in [12] runs this way.This algorithm solves m − n + 1 = O(n 2 ) instances of weighted matriod intersection, where each instance can be solved in O(m 2 + m log m) = O(n 4 ) time.Thus, the total running time of their algorithm is O(n 6 ).See [12] for more details on the time complexity analysis and for an interpretation of this algorithm in terms of the original problem (P0).

Improving the Running Time
In this section we show how to improve the running time of the algorithm described in Section 5.1 to O(k 5 + k 3 n + kn 2 ).This improvement is obtained by modifying the algorithm in two ways: (i) by decreasing the total number of edges that have to be considered, and (ii) by reducing the number of instances of the weighted matroid intersection problem.The Gabriel graph on a given set of points in the plane is defined to have an edge between any two input points p and q if the closed disk with diameter pq does not contain any other input point.The following lemma is a direct consequence of a classic result by Matula and Sokal [14] that every minimum spanning tree of a point set in the plane is a subgraph of the Gabriel graph on that point set.Lemma 7. Every red edge (resp.blue edge) of any minimum RBP spanning graph on (R, B, P ) belongs to the Gabriel graph with vertex set R ∪ P (resp.B ∪ P ).
Let E R (resp.E B ) be the set of edges of the Gabriel graph with vertex set R ∪ P (resp.B ∪ P ).Let E P be the set of purple edges between any pair of purple points.Note that , X * ) be any minimum RBP spanning graph for S. As a consequence of Lemma 7, X * is a subset of E .Thus, in the algorithm of Section 5.1 it suffices to look at the matriods defined on E .This improves the running time to In the rest of this section we describe how to improve the running time further.Lemma 9. Let S be a set of n points in the plane that are colored either red, blue, or purple.Then, 1. every RBP spanning graph for S has at least n − 1 edges.
2. there exists an RBP spanning graph for S that has n − 1 edges.
3. in any RBP spanning graph of S with n − 1 edges, the subgraph induced by the purple points is a tree.
Proof.Since any RBP spanning graph is connected, it has at least n − 1 edges.This proves the first statement.
To prove the second statement we construct an RBP spanning graph with n − 1 edges.First we compute a spanning tree on the purple points, then we connect every other point (red or blue) to a purple point.The resulting graph is a valid RBP spanning graph that is a tree and and has n − 1 edges.
In order to prove the third statement, let G be an RBP spanning graph of S, having n − 1 edges.Since G is connected and has n − 1 edges, it is a tree.Let P be the set of purple points of S. For the sake of contradiction assume there are two points p and q in P such that there is no path between them in G[P ], i.e., there is no purple path between p and q.Since G is an RBP spanning graph, there is a path between p and q in the red tree, and there is another path between p and q in the blue tree.This creates a cycle in G, which contradicts the fact that G is a tree.Thus, G[P ] is connected; moreover it is a tree.Let X * i denote the set of edges of a minimum RBP spanning graph with exactly i edges.As a consequence of Lemma 9 there exists a minimum RBP spanning graph with |R|+|B|+|P |−1 = n−1 edges; note that this is the smallest possible number of edges for any RBP spanning graph.By Lemma 8 any minimum RBP spanning graph has at most |R| + |B| + 2|P | − 2 = n + k − 2 edges.Thus, the weight of X * is equal to the smallest weight among the weights of X * i for all n − 1 i n + k − 2. Since the addition of edges maintains the RBP spanning property, we conclude that for every i ∈ {n − 1, . . ., n + k − 2} there exists an RBP spanning graph with exactly i edges.Based on Lemma 9, X * n−1 can simply be computed by first computing the minimum spanning tree of the purple points, and then adding the red points, and then the blue points, in an optimal manner in a similar way as Prim's algorithm for minimum spanning trees.
One can easily modify the weighted matroid intersection algorithm as follows: having a maximum-weight common independent set I with |I| elements, we can compute a maximumweight common independent set I with |I | = |I| − 1 elements.Let M be the maximum-size of a common independent set of the two matroids.Therefore, if we have I M , the algorithm can be modified to first compute I M , I M −1 , . . ., I 0 and then take the one with maximum weight.
Since the minimum-size of an element in Q r ∩Q b is n−1, the maximum-size M of a common independent set of I Recently, Akitaya et al. [2] showed that it is possible to solve this problem by computing a subset of red edges and a subset of blue edges of a minimum RBP spanning graph in advance in O(n log n) time, and then run the matroid intersection algorithm on a set m of size O(k 2 ).This, in turn, improves the running time of the algorithm to O(k 5 + n log n), however, the worst case running time of the algorithm is still O(n 5 ).We summarize the result of the discussion of this section in the following theorem.Theorem 4. Let S be a set of n points in the plane, each one of which is colored either red, blue, or purple.Let k be the number of purple points.Then, a minimum red-blue-purple spanning graph on S can be computed in O(k 5 + n log n) time.

Conclusions
In this paper we considered the minimum red-blue-purple spanning graph problem on a point set in the plane.The difficulty of this problem is coming from the fact that the purple edges can be used for both the red and the blue trees.By considering a smaller number of potential purple edges we improved the running time of the previous algorithms by a linear factor.In fact, we showed that this problem can be solved in O(n 5 ) time, where n is the number of input points.Moreover, for points that are on a circle we showed how to solve this problem in O(n 2 ) time.A natural open problem is to improve any of these running times.
The extended version of this problem where each point can belong to more than two color classes is NP-complete [2].Hurtado et al. [12] presented an approximation algorithm for the case where the number of color classes is three, however, the approximation ratio is improved by Akitaya et al. [2].Several other special cases are still open, such as points on a circle with three color classes or points in convex position with two color classes.

1 .
No purple edge of G * can cross any other edge of G * .2. No red or blue edge of G * can cross any segment between two purple points (which are not necessarily connected by an edge in G * ).
).This contradicts the minimality of G * .Assume that a * ∈ B b ; see Figure2(b).Then by Claim 1, we have b * ∈ B b .If b * ∈ R b , then by replacing the edge ab with the purple edge ab * we obtain a valid RBP spanning graph that is smaller than G * ; see Figure 2(b).This contradicts the minimality of G * .Assume that b * ∈ R a ; see Figure 2(c).Then, by replacing ab with aa * and bb * we obtain a valid RBP spanning graph that is smaller than G * .This contradicts the minimality of G * .a b b *

Figure 2 :
Figure 2: Proof of Lemma 2: (a) a * ∈ R a and a * ∈ B a .(b) a * ∈ R a and a * ∈ B b .(c) a * ∈ B b and b * ∈ R a .Now we prove statement 2 of the lemma.As we have seen in the proof of statement 1, if |aa * | + |bb * | = |ab|, in all cases we obtain an RBP spanning graph that is smaller than G * , except for the case when we replace ab with aa * and bb * .Let G be the graph that is obtained after replacing all such kind of edges.Since |aa * | + |bb * | = |ab|, G has a weight equal to the weight of G * .Moreover, G does not contain ab.Thus, G is a spanning graph that satisfies statement 2 of the lemma.We prove the following theorem in Section 4.

Figure 3 :Lemma 3 . 2 ä.
Figure 3: Proof of Lemma 3: (a) o does not lie in convex quadrilateral a, b, a , b , and (b) o lies in convex quadrilateral a, b, a , b .

C 1 and C 2 2 . 6 .
are convex polygonal regions with C 1 ⊆ C 2 , then the length of the boundary of C 1 is at most the length of the boundary of C Lemma Let a, b, c, and d be four points on a circle C, in clockwise order, such that the center of C is on or to the right side of the oriented segment ad.Then |ab| + |bc| + |cd| 3 2 • |ad|.
(b).Let C be the circle with diameter ad.Since C and C intersect only at the two points a and d, we argue that b and c are in the interior of C .Extend ab and dc to intersect C at b and c , respectively.Now we consider two cases depending on whether bb and cc intersect or not.In the former case, let o be the intersection point of bb and cc .By Theorem 3 we have |ab| + |bc| + |cd| |ao | + |o d|.Since o is in the interior of C , then |ao | + |o d| √ 2 • |ad|; and we are done with this case.In the latter case, by Theorem 3 we have |ab| + |bc| + |cd| |ab | + |b c | + |c d|.As we have seen in case (i), |ab | + |b c | + |c d| 3 2 • |ad|; which completes the proof of the lemma.
ã c .If b is in the interior of ı ap then |ab| + |a c| < 2 = |aa |, which contradicts the existence of aa in E. Thus b ∈ ı pc, and similarly, b ∈ â q.We are going to show that |bc| + |a b | |bb |; this will contradict the existence of bb in E. Since bb ∈ E we have |bc| + |a b | > |bb |.By Lemma 4 if we move b towards p, then |bc| increases more than |bb |.Similarly, if we move b towards q, then |a b | increases more than |bb |.Therefore, |bc| + |a b | > |bb | holds after moving b to p, and b to q.Thus, from now we assume b = p and b = q.See Figure 8(b).Note that all the triangles aob, boc, coa , a ob , b oc , and bob are isosceles.Let x = |a c|, and thus, |ab| = |b c | = 2 − |a c| = 2 − x.Note that x = 2 sin α 2 .Let β = ∠aob = ∠b oc .Then, β = 2 arcsin Then, (E, I r ) and (E, I b ) are matroids that are dual of (E, I r ) and (E, I b ), respectively.Consider the following maximization problem (P1) Maximize e∈Y w(e) subject to Y ∈ I r ∩ I b .

Lemma 8 .
Let R, B, and P be pairwise disjoint sets of points in the plane that are colored red, blue, and purple, respectively.Then every minimum RBP spanning graph for R ∪ B ∪ P has at most |R| + |B| + 2|P | − 2 edges.Proof.Let G * be a minimum RBP spanning graph for R ∪ B ∪ P .The induced subgraphs G * [R ∪ P ] and G * [B ∪ P ] are trees and have |R| + |P | − 1 and |B| + |P | − 1 edges, respectively.Since the edge set of G * is the union of the edge set of G * [R ∪ P ] and the edge set of G * [B ∪ P ], we conclude that G * has at most |R| + |B| + 2|P | − 2 edges.
r and I b is |E | − (n − 1) = m − n + 1.As described above, we can compute a minimum-weight element X * n−1 in Q r ∩ Q b that has n − 1 edges.The complement of X * n−1 is a maximum-weight common independent set I m −n+1 of I r and I b .Therefore by computing I m −n+1 , . . ., I m −n−k+2 and taking the one with maximum weight, we obtain a maximum-weight element of I r ∩ I b .Note that in (P0) we compute X * n−1 , . . ., X * n+k−2 and take the one with the smallest weight as X * .We solve O(k) instances of the weighted matriod intersection problem, each of which can be solved in O((m) 2 + m log m ) = O(k 4 + k 2 n + n 2 ) time (recall that m = O(k 2 + n)).Thus, the total running time of the algorithm is O(k 5 + k 3 n + kn 2 ).Since k is at most n, the running time of the algorithm is O(n 5 ).
The edge set E contains an edge ab if and only if a, b ∈ V and |aa * | + |bb * | > |ab|, where a * and b * are the two points of V that are neighbors of a and b on the smaller arc of C that is determined by the chord ab, respectively.Without loss of generality assume C is centered at o and has radius 1.Based on the definition of E, the following observation is valid.Observation 1.For any edge ab ∈ E, we have |aa * | > 1 2 • |ab| or |bb * | > 1 2 • |ab|.Corollary 2. For any edge ab ∈ E, we have |a * b * | < 1 2 • |ab|.Proof.Since ab ∈ E, we have |aa * | + |bb * | > |ab|.By Lemma 6 we have |aa * | + |a * b * | + |b * b|