Destroying Bicolored $P_3$s by Deleting Few Edges

We introduce and study the Bicolored $P_3$ Deletion problem defined as follows. The input is a graph $G=(V,E)$ where the edge set $E$ is partitioned into a set $E_r$ of red edges and a set $E_b$ of blue edges. The question is whether we can delete at most $k$ edges such that $G$ does not contain a bicolored $P_3$ as an induced subgraph. Here, a bicolored $P_3$ is a path on three vertices with one blue and one red edge. We show that Bicolored $P_3$ Deletion is NP-hard and cannot be solved in $2^{o(|V|+|E|)}$ time on bounded-degree graphs if the ETH is true. Then, we show that Bicolored $P_3$ Deletion is polynomial-time solvable when $G$ does not contain a bicolored $K_3$, that is, a triangle with edges of both colors. Moreover, we provide a polynomial-time algorithm for the case that $G$ contains no blue $P_3$, red $P_3$, blue $K_3$, and red $K_3$. Finally, we show that Bicolored $P_3$ Deletion can be solved in $ O(1.84^k\cdot |V| \cdot |E|)$ time and that it admits a kernel with $ O(k\Delta\min(k,\Delta))$ vertices, where $\Delta$ is the maximum degree of $G$.


Introduction
Graph modification problems are a popular topic in computer science. In these problems, one is given a graph and wants to apply a minimum number of modifications, for example edge deletions, to obtain a graph that fulfills some graph property Π.
An important reason for the popularity of graph modification problems is their usefulness in graphbased data analysis. A classic problem in this context is CLUSTER EDITING where we may insert and delete edges and Π is the set of cluster graphs. These are exactly the graphs that are disjoint unions of cliques and it is well-known that a graph is a cluster graph if and only if it does not contain a P 3 , a path on three vertices, as induced subgraph. CLUSTER EDITING has many applications [4], for example in clustering gene interaction networks [3] or protein sequences [30]. The variant where we may only delete edges is known as CLUSTER DELETION [26]. Further graph-based data analysis problems that lead to graph modification problems for some graph property Π defined by small forbidden induced subgraphs arise in the analysis of biological [8,18] or social networks [6,24].
Besides the application, there is a more theoretical reason why graph modification problems are very important in computer science: Often these problems are NP-hard [23,31] and thus they represent interesting case studies for algorithmic approaches to NP-hard problems. For example, by systematically categorizing graph properties based on their forbidden subgraphs one may outline the border between tractable and hard graph modification problems [2,22,31].
In recent years, multilayer graphs have become an increasingly important tool for integrating and analyzing network data from different sources [21]. Formally, multilayer graphs can be viewed as edgecolored (multi-)graphs, where each edge color represents one layer of the input graph. With the advent of multilayer graphs in network analysis it can be expected that graph modification problems for edgecolored graphs will arise in many applications as it was the case in uncolored graphs.
One example for such a problem is MODULE MAP [27]. Here, the input is a simple graph with red and blue edges and the aim is to obtain by a minimum number of edge deletions and insertions a graph that contains no P 3 with two blue edges, no P 3 with a red and a blue edge, and no a triangle, called K 3 , with two blue edges and one red edge. MODULE MAP arises in computational biology [1,27]; the red layer represents genetic interactions and the blue layer represents physical protein interactions [1].
Motivated by the practical application of MODULE MAP, an edge deletion problem with bicolored forbidden induced subgraphs, we aim to study such problems from a more systematic and algorithmic point of view. Given the importance of P 3 -free graphs in the uncolored case, we focus on the problem where we want to destroy all bicolored P 3 s, that is, all P 3 s with one blue and one red edge, by edge deletions.
BICOLORED P 3 DELETION (BPD) Input: A two-colored graph G = (V, E r , E b ) and an integer k ∈ N. Question: Can we delete at most k edges from G such that the remaining graph contains no bicolored P 3 as induced subgraph?
We use E := E r ⊎ E b to denote the set of all edges of G, n := |V | to denote the number of vertices in G, and m := |E| to denote the number of edges in G.
Bicolored P 3 s are closely connected to Gallai colorings of complete graphs [14,17]. A Gallai coloring is an edge-coloring such that the edges of every triangle receive at most two different colors. When we view nonedges of G as edges with a third color, say green, then a bicolored P 3 is the same as a triangle that violates the property of Gallai colorings. Thus, BPD is essentially equivalent to the following problem: Given a complete graph with an edge-coloring with the colors red, blue, and green that is not a Gallai coloring, can we transform the coloring into a Gallai coloring by recoloring at most k blue or red edges with the color green?
Our Results. We show that BPD is NP-hard and that, assuming the Exponential-Time Hypothesis (ETH) [20], it cannot be solved in a running time that is subexponential in the instance size. We then study two different aspects of the computational complexity of the problem.
First, we consider special cases that can be solved in polynomial time, motivated by similar studies for problems on uncolored graphs [7]. We are in particular interested in whether or not we can exploit structural properties of input graphs that can be expressed in terms of colored forbidden subgraphs. We show that BPD can be solved in polynomial time on graphs that do not contain a certain type of bicolored K 3 s as induced subgraphs, where bicolored K 3 s are triangles with edges of both colors. Moreover, we show that BPD can be solved in polynomial time on graphs that contain no K 3 s with one edge color and no P 3 s with one edge color as induced subgraphs.
Second, we consider the parameterized complexity of BPD with respect to the natural parameter k. We show that BPD can be solved in O(1.84 k · nm) time and that it admits a problem kernel with O(k∆ min(k, ∆)) vertices, where ∆ is the maximum degree in G. As a side result, we show that BPD admits a trivial problem kernel with respect to ℓ := m − k.

Preliminaries
We consider undirected simple graphs G with vertex set V and edge set E, where E is partitioned into a set E b of blue edges and a set E r of red edges, denoted by G = (V, E r , E b ).
In each context we may omit the subscript G if the graph is clear from the context. For Furthermore, we say that two edges {u, v} and {v, w} form a bicolored P 3 if G[{u, v, w}] is a bicolored P 3 . An edge e is part of a bicolored P 3 if there exists some other edge e ′ such that e and e ′ form a bicolored P 3 . For any edge set E ′ we denote by G − E ′ := (V, E r \ E ′ , E b \ E ′ ) the graph we obtain by deleting all edges in E ′ . As a shorthand, we write G − e := G − {e} for an edge e. An edge deletion set S is a solution for an instance (G, k) of BPD if G − S is bicolored-P 3 -free and |S| ≤ k.
A branching rule for some problem L is a computable function that maps an instance w of L to a tuple of instances (w 1 , . . . , w t ) of L. A branching rule is called correct if w is a yes-instance for L if and only if there is some i ∈ {1, . . . , t} such that w i is a yes-instance of L. The application of branching rules gives rise to a search tree whose size is analyzed using branching vectors; for more details refer to the textbook of Fomin and Kratsch [13]. A reduction rule for some problem L is a computable function that maps an instance w of L to an instance w ′ of L such that w is a yes-instance if and only if w ′ is a yes-instance.
Parameterized Complexity is the analysis of the complexity of problems depending on the input size n and a problem parameter k [9,10]. A problem is called fixed-parameter tractable if there exists an algorithm with running time f (k) · n O(1) for some computable function f that solves the problem. An important tool in the development of parameterized algorithms is problem kernelization. Problem kernelization is a polynomial-time preprocessing by reduction rules: A problem L admits a problem kernel if, given any instance I of L with parameter k, one can compute an equivalent instance I ′ of L with parameter k ′ in polynomial time such that k ′ ≤ k and the size of I ′ is bounded by some computable function g only depending on k. The function g is called kernel size. The Exponential Time Hypothesis (ETH) is a standard complexity theoretical conjecture used to prove lower bounds. It implies that 3-SAT cannot be solved in 2 o(|φ|) time where φ denotes the input formula [20].

Bicolored P Deletion is NP-hard
In this section we prove the NP-hardness of BPD. This motivates our study of polynomial-time solvable cases and the parameterized complexity in Sections 4 and 5, respectively. Theorem 3. 1. BPD is NP-hard even if the maximum degree of G is 8.

Proof:
We present a polynomial-time reduction from the NP-hard (3,4)-SAT problem where one is given a 3-CNF formula φ where each variable occurs in at most four clauses, and the question is if there is a satisfying assignment for φ [29].
Let φ be a 3-CNF formula with variables X = {x 1 , . . . , x |X| } and clauses C = {C 1 , . . . , C |C| } with four occurrences per variable. For a given variable x i that occurs in a clause C j we define the occurrence number Ψ(C j , x i ) as the number of clauses in {C 1 , C 2 , . . . , C j } where x i occurs. Intuitively, Ψ(C j , x i ) = r means that the rth occurrence of variable x i is the occurrence in clause C j . Since each variable occurs in at most four clauses, we have Ψ(C j , x i ) ∈ {1, 2, 3, 4}.
Construction: We describe how to construct an equivalent instance (G = (V, E r , E b ), k) of BPD from φ.
For each variable x i ∈ X we define a variable gadget as follows. The variable gadget of x i consists of a central vertex v i and two vertex sets We add a blue edge from v i to every vertex in T i and a red edge from v i to every vertex in F i .
For each clause C j ∈ C we define a clause gadget as follows. The clause gadget of C j consists of three vertex sets We add blue edges such that the vertices in B j ∪ W j form a clique with only blue edges in G. Moreover, for each p ∈ {1, 2, 3}, we add a blue edge {a p j , b p j } and a red edge {a p j , u} for every u ∈ W j ∪ B j \ {b p j }. Observe that there are no edges between a 1 j , a 2 j , and a 3 j ; all other vertex pairs are connected either by a red edge or a blue edge. We connect the variable gadgets with the clause gadgets by identifying vertices in T i ∪ F i with vertices in A j as follows. Let C j be a clause containing variables x i1 , x i2 , and x i3 . For each p ∈ {1, 2, 3} we set Now, for every variable x i ∈ X each vertex in T i ∪ F i is identified with at most one vertex a p j . Figure 1 shows an example of a clause gadget and its connection with the variable gadgets. To complete the construction of the BPD instance (G, k) we set k := 4 · |X| + 14 · |C|. Intuition: Before showing the correctness of the reduction, we describe its idea. For each variable x i we have to delete all blue edges in E({v i }, T i ) or all red edges in E({v i }, F i ) in the corresponding variable gadget. Deleting the edges in E({v i }, T i ) assigns true to the variable x i while deleting the edges in E({v i }, F i ) assigns false to x i . Since we identify vertices in T i ∪ F i with vertices in A j the information of the truth assignment is transmitted to the clause gadgets. We will be able to make a clause-gadget bicolored-P 3 -free with 14 edge deletions if and only if there is at least one vertex in A j which is incident with a deleted edge of its variable gadget.

Correctness:
We now show the correctness of the reduction by proving that there is a satisfying assignment for φ if and only if (G, k) is a yes-instance of BPD.
(⇒) Let A : X → {true, false} be a satisfying assignment for φ. In the following, we construct a solution S for (G, k).
For each variable Note that for each variable we add exactly four edges to S. For each C j ∈ C we add the following edges: Since A is satisfying, C j contains a variable x i such that A(x i ) satisfies C j . By the construction of G there is exactly one p ∈ {1, 2, 3} such that a p j = t we add exactly 14 edges per clause. Thus, we have an overall number of 4 · |X| + 14 · |C| edges in S.
Let G ′ := G − S. It remains to show that there is no bicolored where v i is the central vertex of the variable gadget of a variable x i occurring in C j . By the construction of G it follows that a 3 j ∈ {t Hence, there is no bicolored P 3 in G ′ consisting of two edges from one variable gadget. Since there is no vertex in G ′ that is adjacent to two vertices of distinct variable gadgets, an edge is part of a bicolored P 3 in G ′ as shown above, e does not form a bicolored P 3 with an edge from a clause gadget. Therefore, no edge in 3 . It follows that G ′ does not contain any bicolored P 3 .
(⇐) Conversely, let S be a solution for (G, k). For every variable Before we define a satisfying assignment A : X → {true, false} for φ, we take a more detailed look at the edges of the clause gadgets that need to be in S. Let C j ∈ C be a clause and let G j := G[A j ∪ B j ∪ W j ] be the induced subgraph of the corresponding clause gadget. We show that 14 edge deletions are necessary and sufficient to transform G j into a bicolored-P 3 -free graph. Obviously, for pairwise distinct p, q, r ∈ {1, 2, 3}, deleting the 14 edges in E Gj ({a p j , a q j }, B j ∪ W j ) transforms G j into a bicolored-P 3 -free graph, since {a r j } ∪ B j ∪ W j is a clique in G j . Hence, deleting 14 edges is sufficient. It remains to show that when deleting less than 14 edges there are still bicolored P 3 s in G j . To this end, we show that either one of the vertices in A j is not incident with an edge deletion in G j or we need more than 14 edge deletions to transform G j into a bicolored-P 3 -free graph. We consider three vertices u 1 , u 2 , u 3 ∈ B j ∪ W j representing the endpoints of deleted edges incident with a 1 j , a 2 j , and a 3 j , respectively. Let S j := {{a p j , u p } | p ∈ {1, 2, 3}}. The following claim gives a lower bound on the number of edge deletions in G j after deleting S j .
Proof . We define three sets P 1 , P 2 , and P 3 containing bicolored P 3 s and show that the union P 1 ∪P 2 ∪P 3 contains at least 12 edge-disjoint bicolored P 3 s in G j − S j . Here, we represent bicolored P 3 s by edge sets of size two. For each p ∈ {1, 2, 3} we set We now show that the union P 1 ∪ P 2 ∪ P 3 contains at least 12 edge-disjoint bicolored P 3 s in G j − S j . To this end, consider the following subset Obviously, Q 1 , Q 2 , Q 3 ∈ P and |P| ≥ 3 · 5 − 3 = 12. It remains to show that all bicolored P 3 s in P are edge-disjoint. Assume towards a contradiction that there are P, R ∈ P with P = R and P ∩ R = ∅.
Since every P p contains edge-disjoint bicolored P 3 s, it follows that P ∈ P p and R ∈ P r for some p = r. Without loss of generality assume p < r. Since for every w ∈ B j ∪ W j , the edges {a r j , w} are not part of any bicolored P 3 in P p and, conversely, the edges {a p j , w} are not part of any bicolored P 3 in P r it follows that P ∩ R = {{u p , u r }}. We conclude R = {{a r j , u p }, {u p , u r }}. Consider the case p = 1 and r = 2. Then, R = Q 1 ∈ P. Analogously, if p = 1 and r = 3, then R = Q 2 ∈ P, and if p = 2 and r = 3, then R = Q 3 ∈ P. In every case we have R ∈ P which contradicts the assumption P, R ∈ P. Hence, there are no bicolored P 3 s in P that share an edge and therefore P 1 ∪ P 2 ∪ P 3 contains at least 12 edge-disjoint bicolored P 3 s as claimed. ✸

Claim 1 implies that if every vertex in
are the only three possible ways to transform G j into a bicolored-P 3free graph with less than 15 edge deletions. By Claim 1, we can assume without loss of generality We show that this implies that all edges incident with a 1 j and a 2 j in G j are deleted by S.
We conclude from Claim 2 that deleting the 14 edges in E Gj ({a p j , a q j }, B j ∪ W j ) for distinct p, q ∈ {1, 2, 3} are the only three possible ways to destroy all bicolored P 3 s in G j with at most 14 edge deletions.
This fact combined with the fact that we need at least 4 edge deletions per variable gadget and We now define a satisfying assignment A : X → {true, false} for φ by The assignment A is well-defined since in each variable gadget either all red or all blue edges belong to S.
In both cases, the assignment A satisfies C j which completes the correctness proof.

Polynomial-Time Solvable Cases
Since BPD is NP-hard, there is little hope to find a polynomial-time algorithm that solves BPD on arbitrary instances. In this section we provide polynomial-time algorithms for two special cases of BPD that are characterized by colored forbidden induced subgraphs.

BPD on Bicolored K 3 -free Graphs
Our first result is a polynomial-time algorithm for BPD, when G = (V, E r , E b ) does not contain a certain type of bicolored K 3 s.
contains exactly three edges such that exactly two of them have the same color. A bicolored K 3 is endangered in G if at least one of the two edges with the same color is part of a bicolored P 3 in G.
A bicolored K 3 on vertices u, v, w can be seen as an induced subgraph of G, such that after one edge deletion in E G ({u, v, w}) one might end up with a new bicolored P 3 containing the vertices u, v, and w. This happens, if we delete one of the two edges with the same color. If the bicolored K 3 is endangered, it might be necessary to delete one of these two edges to transform G into a bicolored-P 3 -free graph. Intuitively, a graph G that contains no (endangered) bicolored K 3 can be seen as a graph from which we can delete any edge that is part of a bicolored P 3 without producing a new one. Note that the following result also implies that BPD can be solved in polynomial time on triangle-free graphs and thus also on bipartite graphs.
Proof: We prove the theorem by reducing BPD to VERTEX COVER on bipartite graphs which can be solved in polynomial time since it is equivalent to computing a maximum matching.

VERTEX COVER
Input: A graph G = (V, E) and an integer k ∈ N. Question: Is there a vertex cover of size at most k in G, that is, a set S ⊆ V with |S| ≤ k such that every edge e ∈ E has at least one endpoint in S?
That is, G ′ contains a vertex for each edge of G and edges are adjacent if they form a P 3 in G. Moreover, let k ′ = k. The graph G ′ is obviously bipartite with partite sets E b and E r .
We now show that (G, k) is a yes-instance for BPD if and only if (G ′ , k ′ ) is a yes-instance for VERTEX COVER.
(⇒) Let S be a solution for (G, k). Note that the edges of G are vertices of G ′ by construction and therefore S ⊆ V ′ . We show that S is a vertex cover in G ′ . Assume towards a contradiction that there is an edge {x, y} ∈ E ′ with x, y ∈ S. By the definition of E ′ , the edges x and y form a bicolored P 3 in G. This contradicts the fact that G − S is bicolored-P 3 -free. Hence, S is a vertex cover of size at most k in G ′ .
(⇐) Let C ⊆ V ′ with |C| ≤ k be a minimal vertex cover of G ′ . Note that the vertices of G ′ are edges of G by construction and therefore C ⊆ E. We show that G − C is bicolored-P 3 -free. Assume towards a contradiction that there are edges x = {u, v} ∈ E b \ C and y = {v, w} ∈ E r \ C forming a bicolored P 3 in G − C. Then, x and y do not form a bicolored P 3 in G since otherwise there is an edge {x, y} ∈ E ′ , which has no endpoint in the vertex cover C. It follows that there is an edge {u, w} in G that is not present in G − C. Consequently, {u, w} ∈ C. Obviously, the vertices u, v, w form a bicolored K 3 . Since x and y form a bicolored P 3 in G − C, one of these edges has the same color as {u, w}. Since {u, w} ∈ C and C is minimal, it follows that {u, w} ∈ V ′ is an endpoint of an edge in G ′ and thus {u, w} is part of a bicolored P 3 in G. Therefore, G[{u, v, w}] forms an endangered bicolored K 3 in G which contradicts the fact that G contains no endangered bicolored K 3 . This proves the correctness of the reduction.
For a given instance (G, k) of BPD, the VERTEX COVER instance (G ′ , k ′ ) can be computed in O(nm) time by computing all bicolored P 3 s of G. Since VERTEX COVER can be solved in O(|E ′ | · |V ′ |) time on bipartite graphs [19] and since |V ′ | = m and |E ′ | ≤ nm, we conclude that BPD can be solved in O(nm 3 2 ) time on graphs without endangered K 3 s.

BPD on Graphs without Monochromatic K 3 s and P 3 s
We now show a second polynomial-time solvable special case that is characterized by four colored forbidden induced subgraphs: the two monochromatic K 3 s, these are the K 3 s where all three edges have the same color, and the two monochromatic P 3 s, these are the P 3 s where both edges have the same color.
Observe that a graph that does not contain these forbidden induced subgraphs may still contain K 3 s or P 3 s.
We provide two reduction rules that lead to a polynomial-time algorithm for this special case. These rules can also be applied to general instances of BPD and thus their running time bound is given for general graphs. We will later show that on graphs without monochromatic K 3 s and P 3 s we can apply them exhaustively in O(n) time.

Reduction Rule 1.
a) Remove all bicolored-P 3 -free components from G.
b) If G contains a connected component C of size at most five, then compute the minimum number of edge deletions k C to make G[C] bicolored-P 3 -free, remove C from G, and set k ← k − k C . The second reduction rule involves certain bridges that may be deleted greedily. An edge e is a bridge if the graph G − e has more connected components than G.

Reduction Rule 2.
a) Remove all bridges from G that are not contained in any bicolored The running time can be seen as follows: We compute in O(n + m) time the bridges of G [28]. Given the bridges, one can compute in O(n + m) the block-cut-forest F of G. The vertices of F are maximal 2edge-connected components of G and the edges correspond to the bridges of G. Then in O(nm) time, we enumerate all bicolored P 3 s. Using the set of bicolored P 3 s, we can compute for each 2-edge-connected component whether it contains a bicolored P 3 . Moreover, for each bridge e and each incident 2-edgeconnected component C, we can compute whether e forms a bicolored P 3 with some edge of C. Finally, we can compute for each bridge the set of edges with which it forms a conflict. This additional information can be computed in O(nm) time. We incorporate this information into the block-cut-forest F as follows: A vertex of F is colored black if the corresponding 2-edge-connected component contains a bicolored P 3 , otherwise it is colored white.
The exhaustive application of the rule is now performed on the block-cut-forest F via the following algorithm. First, remove all white singletons from G and F . Then, remove all bridges of G from G and F that are not part of in any bicolored P 3 in G. Checking whether one of these two conditions is fulfilled can be performed in O(n + m) time per removed edge and vertex. In the following, we assume that these removals have been applied exhaustively.
To To do this efficiently, we characterize such bridges as follows. Altogether, applying the rules using F needs O(n + m) time per removed vertex and edge. Since each application removes some vertex or bridge of G, there are in total O(n) applications. Moreover, after removing all isolated vertices from G, we have n ≤ 2m and thus the overall running time of O(nm) for the application of the rule follows.
As we will show later, any graph without monochromatic P 3 s and monochromatic K 3 s to which the above reduction rules do not apply has maximum degree two. These graphs can be solved in linear time as we see in the following lemma.
Lemma 4. 5. Let (G, k) be an instance of BPD such that G has maximum degree 2. Then, (G, k) can be solved in O(n) time.
Proof: In the following, we construct a solution S for (G, k). If G has maximum degree 2, then each connected component of G is either a path or a cycle. The algorithm first deals with cycles and then considers the remaining paths. Observe that every connected component of size at most 3 can be solved within O(1) time. For the rest of the proof we assume that every connected component has size at least 4.
First, we consider each connected component C of G which is a cycle. We either transform C into one or two paths or solve C directly. First, assume that C contains three subsequent edges e 1 , e 2 , and e 3 of the same color, then edge e 2 is not part of any bicolored P 3 . Hence e 2 can be removed without decreasing k. The remaining connected component is a path and will be solved in the second step. Second, assume that C contains two subsequent edges e 1 and e 2 with the same color. Recall that we may assume that |C| ≥ 4. Further, let e 0 be the other edge that is incident with e 1 and let e 3 be the other edge that is incident with e 2 . According to our assumption, e 0 and e 1 form a bicolored P 3 and e 2 and e 3 form a bicolored P 3 . Hence, either e 0 ∈ S or e 1 ∈ S and either e 2 ∈ S or e 3 ∈ S. Since e 1 and e 2 have the same color and no further edges are incident with e 1 and e 2 , we may assume that e 0 , e 3 ∈ S. The remaining connected components are paths and will be solved in the second step. Third, consider the case that C contains no two subsequent edges of the same color. Then C consists of 2ℓ edges e 1 , . . . , e 2ℓ and each two subsequent edges form a bicolored P 3 . Thus, C contains a set of ℓ edge-disjoint bicolored P 3 s: {e 1 , e 2 }, {e 3 , e 4 }, . . . , {e 2ℓ−1 , e 2ℓ } and contains exactly ℓ blue edges. Thus, deleting the ℓ blue edges of C is optimal.
In a second step, we consider each connected component that is a path. Let P n be a path consisting of n vertices v 1 , . . . , v n . Visit the edges {v i , v i+1 } for increasing i starting at v 1 . For each edge, check whether it is part of some bicolored P 3 . Let {v i , v i+1 } be the first encountered edge that is in a bicolored P 3 . Then, delete {v i+1 , v i+2 }, decrease k by one, and continue with {v i+2 , v i+3 } if it exists. First, observe that {v i+1 , v i+2 } exists since {v i , v i+1 } does not form a bicolored P 3 with {v i−1 , v i }. Second, observe that the deletion of {v i+1 , v i+2 } is simply an application of Reduction Rule 2 and therefore correct. Clearly, this greedy algorithm runs in O(n) time.
In altogether O(n) time, we can consider each cycle C and either solve C or delete one or two edges, which transforms C into one or two paths. The greedy algorithm for paths runs in O(n) time on all paths. Thus, the remaining instance can be solved in O(n) time. The overall running time follows.
We have now all ingredients to present the polynomial-time algorithm for graphs without monochromatic K 3 and monochromatic P 3 . In order to prove the correctness of the algorithm and the linear running time, we make the following observation about such graphs. Lemma 4. 6. Let G be a graph that contains no monochromatic K 3 and no monochromatic P 3 as induced subgraphs. Then, the maximum blue degree and the maximum red degree in G are 2. Proof: We show the proof only for the blue degree, the bound for the red degree can be shown symmetrically. Assume towards a contradiction that G contains a vertex t with at least three blue neighbors u, v, and w.  Proof: The algorithm first applies Reduction Rule 1 exhaustively. Afterwards, Reduction Rule 2 is applied on all bridges {u, v} with deg(u) ≥ 3 or deg(v) ≥ 3. Thus, let G be the graph after the applications of Reduction Rules 1 and 2 as described above. We show that G has maximum degree at most 2. Afterwards, Lemma 4.5 applies and the remaining instance can be solved in O(n) time. Observe that by Lemma 4.6, the maximum degree in G is 4. For an illustration of the small uncolored graphs used in this proof see Figure 2. First, assume that the maximum degree of G is 4 and let v be a vertex of degree 4. We show that N [v] is a connected component of G. This implies that N [v] is removed by Reduction Rule 1 in this case. By Lemma 4.6, the vertex v has exactly two blue neighbors u 1 , u 2 and exactly two red neighbors w 1 , w 2 . Since G contains no monochromatic P 3 and no monochromatic K 3 , {u 1 , u 2 } is red and {w 1 , w 2 } is blue. Now assume towards a contradiction, that one of these four vertices has a neighbor t / ∈ N [v] in G. Without loss of generality assume that this vertex is u 1 . See Figure 3 (a) Figure 3 (b) for an example. Assume without loss of generality that u is a blue neighbor of v. Then, by Lemma 4.6, one of t and w, say w, is a red neighbor of v. This implies that t is a blue neighbor of v, because otherwise G[{v, w, t}] is a red P 3 . Consequently, t is a red neighbor of u because otherwise t, v, and u form a blue K 3 N [v]] is a paw. Let t, u, and w be the neighbors of v where u and w are adjacent. For an example see Figure 3 (c). Assume furthermore without loss of generality that v is incident with two blue edges. This implies that t is a red neighbor of v as otherwise t, v, and u form a monochromatic P 3 . Also, u and w are blue neighbors of v. Consequently, {u, w} is red. As in the proof above for the case that G[N [v]] is a diamond, u and w have no further neighbor in G. Thus, {v, t} is a bridge with deg(v) = 3 that fulfills the condition of Reduction Rule 2 b) and thus {v, t} is removed by this rule. Altogether this implies that any instance to which Reduction Rules 1 and 2 have been applied as described above has maximum degree 2. By Lemma 4.5, we can thus solve the remaining instance in linear time.
Next, we consider the running times of Reduction Rules 1 and 2 in more detail since for both rules the running time analysis given above did not assume that G contains no monochromatic P 3 and no monochromatic K 3 .
First, we apply Reduction Rule 1 exhaustively. Since G has maximum degree at most four, we can label all vertices that are part of some bicolored P 3 in O(n) time and thus Reduction Rule 1 can be applied exhaustively in O(n) time. Observe that in the resulting graph the maximum degree of G is three since vertices of degree four are in connected components of size five.
Next, we consider the running time of Reduction Rule 2, after Reduction Rule 1 was applied exhaustively. Recall that Reduction Rule 2 is only applied to bridges that have at least one endpoint with degree three. To apply the rule exhaustively, we first compute in O(n) time the set of all vertices of degree three.

Parameterized Complexity
In this section we study the parameterized complexity of BPD parameterized by k, ℓ := m−k, and (k, ∆), where ∆ denotes the maximum degree of G. We first provide an O(1.84 k · nm)-time fixed-parameter algorithm for BPD. Afterwards, we study problem kernelizations for BPD parameterized by (k, ∆) and ℓ.

A Fixed-Parameter Algorithm for Bicolored P 3 Deletion
We now provide a fixed-parameter algorithm that solves BPD parameterized by k. Note that there is a naive O(2 k · nm) branching algorithm for BPD: For a given instance (G, k), check in O(nm) time if G contains a bicolored P 3 . If this is not the case, then answer yes. Otherwise, answer no if k < 1. If k ≥ 1, then compute a bicolored P 3 formed by the edges e 1 and e 2 and branch into the cases (G − e 1 , k − 1) and (G − e 2 , k − 1). We modify this simple algorithm by branching on slightly more complex structures, obtaining a running time of O(1.84 k · nm). Note that by Corollary 3.2 a subexponential algorithm in k is not possible when assuming the ETH. The basic idea of the algorithm is to branch on LC-Diamonds, LO-Diamonds, IIZ-Diamonds and CC-Hourglasses. For the definition of these structures see Figure 4. We say that a graph G is nice if G has none of the structures from Figure 4 as induced subgraph and every edge of G forms a bicolored P 3 with at most one other edge of G. We give a polynomial-time algorithm that solves BPD when the input graph is nice. To this end consider the following proposition.
Proposition 5. 1. Let (G = (V, E r , E b ), k) be an instance of BPD such that G is nice. Moreover, let p be the number of bicolored P 3 s in G. Then, for every two edges e 1 and e 2 forming a bicolored P 3 in G there is an edge e ∈ {e 1 , e 2 } such that a) G − e contains p − 1 bicolored P 3 s and every bicolored P 3 of G − e is a bicolored P 3 in G, and b) G − e is nice.
Proof: For the proof of Statement a), let u and v denote the endpoints of e 1 ∈ E b and let v and w denote the endpoints of e 2 ∈ E r . Note that the number of bicolored P 3 s in G − e 1 and G − e 2 is at least p − 1 since every edge of G is part of at most one bicolored P 3 since G is nice. It remains to show that there is an edge e ∈ {e 1 , e 2 } such that the number of bicolored P 3 s in G − e is at most p − 1, and that every bicolored P 3 in G − e is a bicolored P 3 in G. Assume towards a contradiction that there are at least p bicolored P 3 s in G − e 1 and in G − e 2 . Then, there exist vertices z 1 , z 2 ∈ V , such that {u, z 1 } and {z 1 , v} form a bicolored P 3 in G − e 1 and also {v, z 2 } and {z 2 , w} form a bicolored P 3 in G − e 2 .
First, assume z 1 = z 2 =: z. If {v, z} ∈ E r , then {u, z} ∈ E b , {w, z} ∈ E b , and G[{u, v, w, z}] is an LC-Diamond with two red and three blue edges. This contradicts the fact that G contains no induced LC-Diamond. Analogously, if {v, z} ∈ E b , then G[{u, v, w, z}] is an LC-Diamond with two blue and three red edges. We conclude z 1 = z 2 .
Second, assume {v, z 1 } ∈ E b . Then, {u, z 1 } ∈ E r . Since every edge of G is part of at most one bicolored P 3 , there is an edge is an IIZ-Diamond. This contradicts the fact that G contains no induced LC-or IIZ-Diamond. Therefore, {v, z 1 } ∈ E r . With the same arguments we can show that {v, Case 2: is an induced LO-Diamond. Both cases contradict the fact that G is nice.
is an LC-Diamond. Both cases contradict the fact that G is nice.
All cases lead to a contradiction. Hence, there exists e ∈ {e 1 , e 2 } such that G − e contains p − 1 bicolored P 3 s which proves Statement a).
Next, we show Statement b). To this end, let e 1 and e 2 be two edges forming a bicolored P 3 in G. Let e ∈ {e 1 , e 2 } that satisfies a). We show that G − e is nice. From a) we know that every bicolored P 3 of G − e is also a bicolored P 3 in G. Hence, the fact that every edge of G is part of at most one bicolored P 3 implies that every edge of G − e is part of at most one bicolored P 3 .
First, assume towards a contradiction that G − e contains an induced LC-, LO-or IIZ-Diamond (G − e)[{u, v, w, z}] as given in Figure 4. Since G contains no such structure, we conclude e = {u, w} and {u, v, w, z} is a clique in G. Then, deleting e from G produces a new bicolored P 3 on edges {u, v} and {v, w} in G − e which contradicts Statement a). Therefore, G − e contains no induced LC-, LO-and IIZ-Diamonds.
Second, assume towards a contradiction that the graph G−e contains some induced CC-Hourglass (G− e)[{u, v, w, z 1 , z 2 }] as given in Figure 4 All cases lead to a contradiction and therefore G − e contains no induced LC-, LO-, IIZ-Diamonds, CC-Hourglasses and every edge of G − e is part of at most one bicolored P 3 . Proposition 5.1 implies a simple algorithm for BPD on such graphs. It remains to show that this algorithm is correct. Assume G contains p bicolored P 3 s. Since every edge of G forms a bicolored P 3 with at most one other edge, all bicolored P 3 s in G are edge-disjoint. Hence, p edge deletions are necessary. By Proposition 5.1 a) we can eliminate exactly one bicolored P 3 with one edge deletion without producing other bicolored P 3 s. By Proposition 5.1 b) this can be done successively with every bicolored P 3 , since after deleting one of its edges we do not produce LC-, LO-, IIZ-Diamonds, CC-Hourglasses or edges that form a bicolored P 3 with more than one other edge. Thus, p edge deletions are sufficient. Hence, the algorithm is correct.
Next, we describe how to transform an arbitrary graph G into a nice graph G ′ by branching. To this end consider the following branching rules applied on an instance (G, k) of BPD.
Branching Rule 1. If there are three distinct edges e 1 , e 2 , e 3 ∈ E r ∪ E b such that e 1 forms a bicolored P 3 with e 2 and with e 3 , then branch into the cases Proof: We show that (G, k) is a yes-instance of BPD if and only if at least one of the instances I 1 or I 2 is a yes-instance of BPD.
(⇐) Assume I 1 is a yes-instance or I 2 is a yes-instance. In each branching case I i , the parameter k is decreased by the exact amount p i of edges deleted from G. Therefore, if some I i has a solution of size at most k − p i , then (G, k) has a solution.
(⇒) Let S be a solution for G. Since e 1 and e 2 form a bicolored P 3 , at least one of these edges belongs to S. If e 1 ∈ S, then I 1 is a yes-instance since we can transform G − e 1 into a bicolored-P 3 -free graph by deleting the at most k − 1 edges in S \ {e 1 }. Otherwise, if e 1 ∈ S, then e 2 , e 3 ∈ S. Hence, I 2 is a yes-instance since we can transform G − {e 2 , e 3 } into a bicolored-P 3 -free graph by deleting the at most k − 2 edges in S \ {e 2 , e 3 }.
Branching Rule 2. If there are vertices u, v, w, z ∈ V such that G[{u, v, w, z}] is an LC-Diamond (Figure 4 (a)) or an LO-Diamond (Figure 4 (b)) or an IIZ-Diamond (Figure 4  We use the Branching Rules 1-3 to state the following theorem. Theorem 5. 6. BPD can be solved in O(1.84 k · nm) time.
Proof: We solve BPD for an instance (G, k) as follows: Initially, we compute the adjacency matrix of G in O(n 2 ) time. We then compute one of the structures we branch on, which is an induced LC-Diamond, LO-Diamond, IIZ-Diamond, CC-Hourglass or some edge which forms a bicolored P 3 with two other edges. Next, we branch according to the Branching Rules 1, 2, and 3. If no further branching rule is applicable we check in O(nm) time whether the remaining instance is a yes-instance or not. This is possible by Corollary 5.2. The branching vectors are (1, 2) for Branching Rule 1, and (1, 2, 3) for Branching Rules 2 and 3. This delivers a branching factor smaller than 1.8393. We next describe in detail how we can find one of the structures we branch on, in such a way that the algorithm described above runs in O(1.84 k · nm) time Isolated vertices do not contribute to the solution of the instance. Thus, we delete all isolated vertices in O(n) time. Hence we can assume n ≤ 2m in the following. Afterwards, we compute a maximal packing P of edge-disjoint bicolored P 3 s. Here, we represent a bicolored P 3 by an edge set of size two. We define P := p∈P p as the set of all edges of bicolored P 3 s in P. Note that P and thus P can be found in O(nm) time by enumerating all bicolored P 3 s in G. If |P | > 2k, the graph G contains more than k edge-disjoint bicolored P 3 s and (G, k) is a no instance. In this case we can stop and return no. Otherwise, we have |P | ≤ 2k and use P to compute the structures we apply Branching Rules 1-3 on as follows.
Note Finally, let e 1 be an edge that forms two bicolored P 3 s with other edges e 2 and e 3 . Again, at least one of the edges e 1 , e 2 , or e 3 is an element of P . Thus, we can find e 1 , e 2 , and e 3 in O(kn 2 ) time iterating over all triples containing an edge from P and two vertices from V , which form the remaining two endpoints.
Since n ≤ 2m we can find one of the structures on which we apply Branching Rules 1-3 in O(k 2 nm) time. This gives us a total running time of O(1.8393 k · k 2 nm) ⊆ O(1.84 k · nm) time as claimed.
It is possible to improve the branching rules on LO-Diamonds, IIZ-Diamonds, and CC-Hourglasses to obtain a branching vector (2, 2, 3, 3), but branching on LC-Diamonds still needs a branching vector of (1, 2, 3), which is the bottleneck. To put the running time of Theorem 5.6 into perspective note that CLUSTER DELETION, which can be viewed as the uncolored version of BPD, can be solved in O(1.42 k + m) time [5]. Thus there is a large gap between the running time bounds of the problems. It would be interesting to know if this gap can be closed or if BPD is significantly harder than CLUSTER DELETION.

On Problem Kernelization
Finally, we consider problem kernelization for BPD parameterized by (k, ∆) and ℓ := m − k. Recall that ∆ denotes the maximum degree of the input graph. We show that BPD admits problem kernels with O(k∆ min(k, ∆)) vertices or at most 2ℓ edges, respectively.
In the following, we provide two reduction rules leading to an O(k∆ min(k, ∆)) vertex kernel for BPD. The first reduction rule deletes all edges which form more than k bicolored P 3 s.
Reduction Rule 3. If G contains an edge {u, v} such that there exist vertices w 1 , . . . , w t with t > k such that G[{u, v, w i }] is a bicolored P 3 for each i, then remove {u, v} and decrease k by one. Reduction Rule 4. If G contains a vertex v ∈ V such that each vertex u ∈ N [v] is not part of any bicolored P 3 , then, remove v from G.
To show that Rule 4 is correct, we provide two simple lemmas about edge deletion sets.
Lemma 5. 8. Let G = (V, E) be a graph and let S ⊆ E be an edge deletion set. If two edges {u, v} ∈ E and {v, w} ∈ E do not form a bicolored P 3 in G and form a bicolored P 3 in G − S, then {u, w} ∈ S.
The proof of Lemma 5.8 is trivial and thus omitted. Lemma 5. 9. Let (G, k) be an instance of BPD and let S be a solution for (G, k) of minimum size. Then, there exists an ordering (e 1 , . . . , e |S| ) of S such that for each i ∈ {1, . . . , |S|} the edge e i is part of a bicolored P 3 in G − {e 1 , . . . , e i−1 }.
Proof: Assume towards a contradiction that such an ordering does not exist. Then, for every ordering of S, there exists a maximal index 1 ≤ i < |S| such that there is a finite sequence (e 1 , . . . , e i ) where for each 1 ≤ j ≤ i the edge e j is part of a bicolored P 3 in G − {e 1 , . . . , e j−1 }. According to our choice of i, there exists no edge of S which is part of a bicolored P 3 in G − {e 1 , . . . , e i }. If G − {e 1 , . . . , e i } contains a bicolored P 3 formed by {x, y} and {y, z}, then {x, y} ∈ S and {y, z} ∈ S. This contradicts the fact that S is a solution for (G, k). Otherwise, G − {e 1 , . . . , e i } is bicolored-P 3 -free. Then, {e 1 , . . . , e i } S is a solution for (G, k). This contradicts the fact that S is a solution of minimum size for (G, k). Theorem 5. 11. BPD admits a O(k∆ min(k, ∆))-vertex kernel that can be computed in O(nm) time.
Proof: First, apply Reduction Rule 3 exhaustively. Second, apply Reduction Rule 4 exhaustively. This needs O(nm) time altogether. We prove that G contains at most 12 · k∆ min(k, ∆) vertices if (G, k) is a yes-instance. Let P be the set of vertices which are contained in a bicolored P 3 in G, and let P be a maximal set of edge-disjoint bicolored P 3 s in G. If (G, k) is a yes-instance for BPD, then |P | ≤ k. Since Reduction Rule 3 was applied exhaustively, each edge is part of at most min(k, 2∆) bicolored P 3 s. Hence, the total number of bicolored P 3 s in G is at most 2k min(k, 2∆). Consequently, |P| ≤ 6k min(k, 2∆). Since Reduction Rule 4 was applied exhaustively, V \ N [P] = ∅. In other words, set P has no second neighborhood in G. Since each vertex has degree at most ∆ we have |N (P)| ≤ 6k∆ min(k, 2∆). Hence, the overall number of vertices in G is 12 · k∆ min(k, ∆) if (G, k) is a yes-instance for BPD.
By the above, BPD admits a linear problem kernel in k if G has constant maximum degree. Note that a kernelization by ∆ alone is unlikely since BPD is NP-hard even if ∆ = 8 by Theorem 3.1. Since BPD is fixed-parameter tractable with respect to parameter k, we can trivially conclude that it admits an exponential-size problem kernel. It is open if there is a polynomial kernel depending only on k while CLUSTER DELETION has a relatively simple 4k-vertex kernel [16]. Summarizing, BPD seems to be somewhat harder than CLUSTER DELETION if parameterized by k.
In contrast, BPD seems to be easier than CLUSTER DELETION if parameterized by the dual parameter ℓ := m − k: there is little hope that CLUSTER DELETION admits a problem kernel of size ℓ O(1) [15] while BPD has a trivial linear-size problem kernel as we show below.
Theorem 5. 12. BPD admits a problem kernel with 2ℓ edges and vertices which can be computed in O(n+ m) time.
Proof: We show that instances with at least 2ℓ edges are trivial yes-instances. Let (G = (V, E r , E b ), k) with |E| ≥ 2ℓ be an instance of BPD. Then, since E r and E b form a partition of E, we have |E r | ≥ ℓ or |E b | ≥ ℓ. Without loss of generality let |E r | ≥ ℓ. Since |E b | = m − |E r | ≤ m − ℓ = k, E b is a solution for (G, k).

Outlook
We have initiated the algorithmic study of a natural edge-deletion problem on edge-colored graphs. In companion work, we considered the problem of destroying paths of length at least 4 that fulfill certain coloring constraints [11,12]. With this exception, however, the study of graph modification problems on edge-colored graphs has been neglected so far. Consequently, the complexity of many natural problems and a study of natural edge-colored graph classes remain open.
For the particular case of bicolored-P 3 -free graphs, we have also left open many questions for future work. First, it would be interesting to further investigate the structure of bicolored-P 3 -free graphs. Since each color class may induce an arbitrary graph it seems difficult to obtain a concise and non-trivial structural characterization of these graphs. One may, however, exploit the connection with Gallai colorings which are colorings where no triangle receives more than two colors. In particular, the following characterization of Gallai colorings is known [14,17]: any Gallai coloring of a complete graph can be obtained by taking some complete 2-colored graph and substituting its vertices with a complete graph and some Gallai coloring of this complete graph. This characterization relies on the decomposition property that in any Gallai coloring of a complete graph G with at least three colors, there is at least one edge color that spans a disconnected graph H. Then, by the property of Gallai colorings, the edges in G that are between two different components H 1 and H 2 of H have the same color.
Second, there are many open questions concerning BICOLORED P 3 DELETION. Does BICOLORED P 3 DELETION admit a polynomial-size kernel for k? Can BICOLORED P 3 DELETION be solved in 2 O(n) time? Can BICOLORED P 3 DELETION be solved in polynomial time on graphs that contain no monochromatic P 3 ? Can BICOLORED P 3 DELETION be solved in polynomial time on graphs that contain no cycle consisting only of blue edges? Even simpler is the following question: Can BICOLORED P 3 DELETION be solved in polynomial time if the subgraphs induced by the red edges and the subgraph induced by the blue edges are each a disjoint union of paths? Moreover, it would be interesting to perform a similar study on BICOLORED P 3 EDITING where we may also insert blue and red edges. Furthermore, it is open if BICOLORED-P 3 -FREE COMPLETION where we only may insert red or blue edges is NP-hard. Observe in this context that the uncolored problem CLUSTER COMPLETION can easily be solved by adding all missing edges in each connected component.
Third, it would also be interesting to identify graph problems that are NP-hard on general two-edge colored graphs but polynomial-time solvable on bicolored-P 3 -free graphs. Finally, we were not able to resolve the following question: Can we find bicolored P 3 s in O(n + m) time?
Using the connection to Gallai colorings and the decomposition property of Gallai colorings seems to be a promising approach to address these open questions.