Information Processing Letters 115 (2015) 119–124
Contents lists available at ScienceDirect
Information Processing Letters www.elsevier.com/locate/ipl
On the maximum acyclic subgraph problem under disjunctive constraints Sílvia Maria Santana Mapa a,b,∗,1 , Sebastián Urrutia a,2 a b
Computer Science Department, Federal University of Minas Gerais, Belo Horizonte, Brazil Production Engineering Department, Federal Institute of Minas Gerais, Congonhas, Brazil
a r t i c l e
i n f o
Article history: Received 12 December 2013 Received in revised form 30 May 2014 Accepted 25 July 2014 Available online 1 August 2014 Communicated by Ł. Kowalik Keywords: Maximum acyclic subgraph problem Disjunctive constraints Approximation algorithms Computational complexity
a b s t r a c t Disjunctively constrained versions of classic problems in graph theory such as shortest paths, minimum spanning trees and maximum matchings were recently studied. In this article we introduce disjunctive constrained versions of the Maximum Acyclic Subgraph problem. Negative disjunctive constraints state that a certain pair of edges cannot be contained simultaneously in a feasible solution. Positive disjunctive constraints enforces that at least one arc for the underlying pair is in a feasible solution. It is convenient to represent these disjunctive constraints in terms of an undirected graph, called constraint graph, whose vertices correspond to the arcs of the original graph, and whose edges encode the disjunctive constraints. For the Maximum Acyclic Subgraph problem under Negative Disjunctive Constraints we develop 1/2-approximative algorithms that are polynomial for certain classes of constraint graphs. We also show that determining if a feasible solution exists for an instance of the Maximum Acyclic Subgraph problem under Positive Disjunctive Constraints is an NP-Complete problem. © 2014 Elsevier B.V. All rights reserved.
1. Introduction A directed graph may contain directed cycles which may be undesirable or not allowed at all in some practical applications. Therefore, in order to withdraw as few arcs as possible, a maximum directed acyclic graph should be found. The problem of finding the Maximum Acyclic Subgraph (MAS) of a given directed graph G = ( V , A ) consists in determining a maximum subset A ⊆ A for which the subgraph G = ( V , A ) is cycle free. This problem is known to be NP-hard [5]. Simple approximation algorithms for this problem produce solutions with at least half of the number of arcs of an optimal solution [4].
*
Corresponding author. Tel.: +55 0313137318100. E-mail addresses:
[email protected] (S.M.S. Mapa),
[email protected] (S. Urrutia). 1 The author thanks CAPES and IFMG for financial support. 2 The author was partially supported by CNPq Grant 303442/2010-7. http://dx.doi.org/10.1016/j.ipl.2014.07.013 0020-0190/© 2014 Elsevier B.V. All rights reserved.
Negative disjunctive constraints forbid a certain pair of entities of the problem to be simultaneously part of any feasible solution. On the other hand, positive disjunctive constraints force at least one of the entities of a given pair to be part of any feasible solution. Disjunctively constrained versions of classic problems in graph theory such as shortest paths, minimum spanning trees and maximum matchings were recently studied [2]. All these problems, which are polynomially solvable in their basic form, turn NP-Hard in the presence of such disjunctive constraints. The maximum flow problem under positive and negative disjunctive constraints [8] and the classical 0–1 knapsack problem under negative disjunctive constraints [7], where also recently tackled in the literature. In this paper we consider the Maximum Acyclic Subgraph problem under Negative Disjunctive Constraints (MASNDC) and the Maximum Acyclic Subgraph problem under Positive Disjunctive Constraints (MASPDC).
120
S.M.S. Mapa, S. Urrutia / Information Processing Letters 115 (2015) 119–124
To formally define the problems, let G = ( V , A ) be a directed graph and let G¯ = ( A , E ) be an undirected graph, called constraint graph. The Maximum Acyclic Subgraph problem under Negative Disjunctive Constraints consists in determining a subset A ⊆ A of maximum cardinality for which the subgraph G = ( V , A ) is cycle free and A is an independent set ¯ On the other hand, the Maximum Acyclic Subgraph in G. problem under Positive Disjunctive Constraints consists in determining a subset A ⊆ A of maximum cardinality for which the subgraph G = ( V , A ) is cycle free and A is a ¯ Since MASNDC and MASPDC have MAS vertex cover in G. as a special case (when E = ∅), both are NP-Hard. In this paper we propose simple modifications of existing approximation algorithms for MAS that produce solutions to MASNDC maintaining the 1/2-approximation ratio of the original algorithms. Moreover, we show that determining the existence of a feasible solution for a given MASPDC instance is NP-Hard. The rest of the paper is organized as follows. In the next section we present three known algorithms for approximating MAS. In Section 3 we propose six new approximation algorithms for MASNDC adapting those from the MAS literature and following two distinct approaches. In Section 4 we prove that the feasibility of MASPDC is an NP-Complete problem. Finally, in Section 5 we give some concluding remarks. 2. Approximation algorithms for maximum acyclic subgraph Concerning MAS, we present in this section three algorithms that produce solutions with at least | A |/2 arcs. Since the cardinality of A is an upper bound to the optimal solution value, the algorithms are 1/2-approximative. No better constant approximation polynomial algorithm exists for the Maximum Acyclic Subgraph problem and none is expected to exist assuming the Unique Games Conjecture and P = NP [1,6]. Algorithm Sort(G ) This straightforward algorithm first sorts the vertices of the graph arbitrarily assigning a distinct label πi to every vertex i ∈ V . Then, it divides the arcs in A into two subsets: in A f it stores all arcs a = (i , j ) ∈ A such that πi < π j and in A b all arcs a = (i , j ) ∈ A such that πi > π j . The algorithm just picks the subset ( A f or A b ) with maximum cardinality and returns the subgraph with the selected set of arcs as the solution. Theorem 1. The solution of Sort(G ) is an acyclic graph with at least | A |/2 arcs. Proof. Observe that both subgraphs G f = ( V , A f ) and G b = ( V , A b ) are cycle free. A cycle v 1 , v 2 , . . . , v 1 would imply in the presence of an arc (i , j ) with πi < π j and of an arc (k, l) with πk > πl . Also, as each arc in A is either in A f or A b , one of those subsets must have at least | A |/2 arcs.
Algorithm Greedy(G ) This algorithm uses a greedy strategy while considering arcs for inclusion in an acyclic subgraph. The algorithm maintains two sets S and T . It greedily scans all arcs in A, adding an arc to S if with its addition the induced subgraph G [ S ] remains acyclic. Otherwise it adds the arc to T . When all arcs have been processed, the subset of largest cardinality, S or T , is selected to form the acyclic subgraph. Theorem 2. The solution of Greedy(G ) is an acyclic graph with at least | A |/2 arcs. Proof. G [ S ] is acyclic by construction. To show that G [ T ] is also acyclic consider the vertices in V sorted respecting a topological sort of G [ S ]. Each arc in T forms a cycle with a subset of arcs in S and in consequence it is a backward edge considering the topological sort of G [ S ]. Since all arcs in T are backward considering that order of the vertices, the argument for G b to be acyclic in the previous algorithm also holds for G [ T ]. As in the previous proof, each arc in A is either in S or T and one of them must have at least | A |/2 arcs. Algorithm Degree(G ) The third algorithm works as follows. It processes all the vertices of G, in any order, analyzing the incoming and outgoing arcs. If a vertex has more incoming arcs than outgoing ones, the incoming arcs are removed from the graph and added to a set A and the outgoing arcs are also removed but discarded. If a vertex has the same number of incoming and outgoing arcs, the outgoing arcs are added to the set A and the incoming arcs are discarded. When all vertices are processed, the algorithm returns set A to form the acyclic subgraph. Theorem 3. The solution of Degree(G ) is an acyclic graph with at least | A |/2 arcs. Proof. Consider a cycle x1 , . . . , xk , x1 in the subgraph G [ A ] and, without loss of generality, let x1 be the vertex in this cycle that was processed by the algorithm before every other vertex in the cycle. Then, either arc (xk , x1 ) or arc (x1 , x2 ) would have been discarded and therefore no cycle is possible. Also note that | A | ≥ | A |/2, since each arc in A is examined once and, while processing a certain vertex, the algorithm always adds to | A | at least as many arcs as it discards. For several other approximative algorithms for MAS the reader is referred to [4]. 3. Approximation algorithms for maximum acyclic subgraph under negative disjunctive constraints The direct application of the algorithms presented above to the MASNDC does not guarantee a solution with at least half of the number of arcs in an optimal solution. In fact, the presence of disjunctive constraints may
S.M.S. Mapa, S. Urrutia / Information Processing Letters 115 (2015) 119–124
turn the subset returned by an algorithm infeasible even when it is cycle free. In consequence, some of the arcs in the subset must be withdrawn from the solution, which in terms, may drop the number of arcs to less than one half of the number of arcs on an optimal solution. In what follows we show that small modifications in the algorithms allow us to obtain a feasible subset of A with at least as many arcs as half the number of arcs of an optimal solution. We now introduce an approach, called early, for adapting the three algorithms presented above for MAS to the MASNDC problem. The early approach simply returns the intersection between the solution given by the algorithm ¯ This and a maximum independent subset on graph G. approach computes a maximum independent subset on graph G¯ and in consequence is polynomial only if the maximum independent subset problem can be polynomially ¯ Maximum independent solved on the constraint graph G. sets can be computed in polynomial time whenever the constraint graph G¯ is claw-free [9] or perfect [3]. For the three following algorithms let I denote a maximum independent subset on graph G¯ and note that the value of the optimal solutions is bounded by | I |. Therefore an algorithm that guarantees obtaining a solution with at least | I |/2 arcs is a 1/2-approximative algorithm. Algorithm Sorte (G , G¯ ) Our first algorithm sorts the vertices in V arbitrarily and divides the arcs in A into sets A f and A b as in the corresponding algorithm for MAS. Then, it computes the two subsets I ∩ A f and I ∩ A b . Sorte (G , G¯ ) selects I ∩ A f if max(| I ∩ A f |, | I ∩ A b |) = | I ∩ A f | or I ∩ A b otherwise to form the acyclic subgraph.
121
Algorithm Degreee (G , G¯ ) This algorithm processes all the vertices of G, in any order, analyzing the incoming and outgoing arcs. For each vertex v ∈ V let δ + ( v ) be the set of its incoming arcs and δ − ( v ) be the set of its outgoing arcs. The algorithm computes I ∩ δ + ( v ) and I ∩ δ − ( v ), adds to set A the larger of the two subsets, discards all other arcs in δ + ( v ) ∪ δ − ( v ) and erase from G all arcs in δ + ( v ) ∪ δ − ( v ). Theorem 6. Algorithm Degreee (G , G¯ ) is 1/2-approximative for MASNDC. Proof. By the same argument used for the corresponding algorithm for MAS we conclude that A induces an acyclic subgraph in G. The obtained subset is an independent set in G¯ because it is a subset of I . Observe that all arcs in I are processed exactly once and while processing a certain vertex, the algorithm always adds to | A | at least as many arcs of I as the number of arcs of I that it discards. Then, A has at least | I |/2 arcs. The adaptation of the three previous algorithms may be approached in another way. In the approach we named late, the maximum independent set problem is computed on the subgraphs of G¯ induced by the set of arcs selected by the algorithm. Note that this approach is polynomial whenever the maximum independent set problem can be computed in polynomial time in induced subgraphs of G¯ . By definition, if a graph is perfect (resp. claw free), every induced subgraph is also perfect (resp. claw free). Algorithm Sortl (G , G¯ )
Proof. The graph obtained as a solution is a subgraph of the graph obtained executing Sort(G ) and in consequence is acyclic. Each arc in I belongs either to A f or A b and then, | I ∩ A f | ≥ | I |/2 or | I ∩ A b | ≥ | I |/2 holds. So, the solution obtained by the algorithm has at least half of the arcs in any optimal solution.
This algorithm considers G¯ [ A f ], the subgraph of G¯ induced by the set of vertices A f , and G¯ [ A b ], the subgraph of G¯ induced by the set of vertices A b . Let α f (resp. αb ) be the cardinality of a maximum independent set in G¯ [ A f ] (resp. G¯ [ A b ]). The algorithm selects A f if max(α f , αb ) = α f and A b otherwise. The solution of the algorithm is then obtained by computing the maximum independent set over the graph induced by the selected set ¯ in graph G.
Algorithm Greedye (G , G¯ )
Algorithm Greedyl (G , G¯ )
This algorithm greedily goes through all arcs in A, adding an arc to set S if with its addition G [ S ] remains acyclic. Otherwise it adds the arc to set T . Then, the algorithm computes I ∩ S and I ∩ T and returns that of larger cardinality.
For algorithm Greedyl (G , G¯ ), just substitute A f and A b with S and T in the previous algorithm.
Theorem 4. Algorithm Sorte (G , G¯ ) is 1/2-approximative for MASNDC.
Theorem 5. Algorithm Greedye (G , G¯ ) is 1/2-approximative for MASNDC. Proof. By the same argument of the previous proof the obtained subgraph is acyclic. Again, | I ∩ S | ≥ | I |/2 or | I ∩ T | ≥ | I |/2 holds and the algorithm is 1/2-approximative for MASNDC.
Algorithm Degreel (G , G¯ ) This Algorithm computes | I ∩ δ − ( v )| and | I ∩ δ + ( v )| for each vertex v ∈ V in any order. If | I ∩ δ − ( v )| ≥ | I ∩ δ + ( v )|, ¯ all the arcs in δ − ( v ), adding the algorithm adds to set A ¯ all the arcs in δ + ( v ) otherwise. Then, it discards all to A arcs in the other subset and erases from graph G all arcs in δ + ( v ) ∪ δ − ( v ). When all vertices have been processed, the algorithm computes a maximum independent set on ¯ ] to compute A . the induced subgraph G¯ [ A
122
S.M.S. Mapa, S. Urrutia / Information Processing Letters 115 (2015) 119–124
Fig. 1. A MASNDC instance.
Fig. 2. Infeasible MASPDC instance.
Each one of the three last algorithms produces feasible solutions for MASNDC. All sets of arcs returned are subsets of sets already known to induce acyclic subgraphs in G. Also, being independent sets of vertex induced subgraphs ¯ they are independent sets on G. ¯ The next theorem of G, shows that the late approach is always preferable to the early approach implying that the three last algorithms are 1/2-approximative for MASNDC. Theorem 7. If the arcs in G are partitioned in the same way, an algorithm following the late approach obtains a solution at least as good as the one obtained by the corresponding algorithm following the early approach. Proof. After the set A is divided into two subsets, the early approach algorithm returns the intersection of a maximum independent set in G¯ with one of the subsets. Since that intersection is an independent set in the graph induced by the selected subset in G¯ , its cardinality is a lower bound on the cardinality of a maximum independent set in the ¯ That is, the sograph induced by the selected subset in G. lution returned by the late approach algorithm is always at least as good as the one returned by the early approach algorithm. Fig. 1 shows an instance problem for which Sortl (G , G¯ ) returns a better solution than Sorte (G , G¯ ). Consider the numbers over the vertices in Fig. 1(a) as the labels from which they were sorted. The sets A f = {(3, 4), (4, 5), (5, 6), (6, 7)} and A b = {(1, 2), (2, 3)} were obtained. Note that I = {(1, 2), (2, 3), (4, 5), (5, 6), (6, 7)} ¯ We can is the unique maximum independent set of G. compute maximum independent sets in G¯ [ A f ], I f =
{(3, 4), (4, 5), (5, 6), (6, 7)} and in G¯ [ A b ], I b = {(1, 2), (2, 3)}. Therefore, α f = 4 and αb = 2. Algorithm Sorte (G , G¯ ) returns a solution with max(| I ∩ A f |, | I ∩ A b |) = max(3, 2) = 3 arcs and algorithm Sortl (G , G¯ ) returns a solution with max(α f , αb ) = max(4, 2) = 4 arcs. The optimal solution in this case has | I | = 5 arcs. 4. Complexity of the feasibility test for the maximum acyclic subgraph under positive disjunctive constraints Unlike the case of MASNDC, there is no guarantee of the existence of a feasible solution when solving the MASPDC problem. Graph G¯ imposes a lower bound on the number of arcs in the solution. In fact, no solution with fewer arcs than the cardinality of a minimum vertex cover in G¯ can be feasible. In consequence, a given instance of the problem may have no feasible solution. Fig. 2 shows an infeasible instance for the MASPDC. Observe that since G¯ is complete only one arc of A can be selected to be outside of A and therefore there is no way for graph G = ( V , A ) to be acyclic. In this section we show that deciding if an instance of MASPDC is feasible is an NP-Complete problem. We do this by a reduction from the classic vertex cover problem. Let G = ( V , A ) be a directed graph, let G¯ = ( A , E ) be an undirected constraint graph. The feasibility version of the Acyclic Subgraph problem under Positive Disjunctive Constraints (FASPDC) consists in deciding if there exists a subset A ⊆ A for which the subgraph G = ( V , A ) is cycle ¯ free and A is a vertex cover in G. FASPDC is in NP. This can be showed by noting that given a solution A for FASPDC one can polynomially check
S.M.S. Mapa, S. Urrutia / Information Processing Letters 115 (2015) 119–124
Fig. 3. Graph G = ( V , E ).
its feasibility. For verifying that G = ( V , A ) is acyclic one can rely on a simple Depth First Search and verifying that A is a vertex cover in G¯ consists in testing if every edge in E has an extreme in A . Let G = ( V , E ) be an undirected graph and k a nonnegative integer such that k ≤ | V |. The decision version of the Vertex Cover problem (DVC) consists in deciding if there is a subset V ⊆ V with | V | ≤ k and such that for every e = (u , v ) ∈ E it holds that u ∈ V or v ∈ V . DVC was proved NP-Complete in [5]. In the following, we define a function that takes as argument an instance of DVC and returns an instance of FASPDC. Next, we show that both decision problems over that instances have an equivalent solution. 4.1. Constructing a FASPDC instance Let us introduce f as a function that is given an undirected graph G = ( V , E ) with V = {0, 1, . . . , (n − 1)} and a non-negative integer k representing a DVC instance and returns a directed graph Gˆ = ( Vˆ , A ) and an undirected graph G¯ = ( A , E¯ ) representing a FASPDC instance. Function f is ¯ defined below by the definition of sets Vˆ , A and E.
Vˆ = { vˆ i , j /0 ≤ i ≤ k + 1; 0 ≤ j ≤ n}
H = h i , j ,t = ( vˆ i , j , vˆ i , j +1 )/0 ≤ i ≤ k + 1; 0 ≤ j < n; 0≤t ≤1
B = bk+1,n,t = ( vˆ k+1,n , vˆ 0,0 )/0 ≤ t ≤ 1
j + 1. Therefore, in order to have a cycle, any subgraph of Gˆ must include at least one arc from B and it must contain a path, with exactly n arcs, from vertex vˆ 0,0 to vertex vˆ k+1,n . Let A ⊆ A be a minimum vertex cover in G¯ and let B , H and D be equal to B ∩ A , H ∩ A and D ∩ A . Since the vertices associated with the two arcs in B are adjacent ¯ at least one of them is always present in B . In conin G, sequence, the induced subgraph Gˆ [ A ] is cycle free if and only if it does not have a path from vˆ 0,0 to vˆ k+1,n . The vertices associated with each pair of parallel arcs h i , j ,0 and h i , j ,1 in H are adjacent in G¯ and, as before, at least one of them is always present in H . Therefore, there is always a path in Gˆ [ A ] from vertex vˆ i , j to vˆ i ,t for any
j < t ≤ n. Thus, the existence of a cycle in Gˆ ( A ) depends only on the arcs belonging to D . For each vertex u ∈ V there are k + 1 arcs in D, namely di ,u such that 0 ≤ i ≤ k. Letus call these disjoint subsets as D u and observe that D = u ∈ V D u . If u is adjacent to another vertex v in G, the arcs associated with u and those associated with v in D are, in turn, vertices in G¯ that induce a complete bipartite subgraph. For each of these complete bipartite subgraphs, at least one of the sets of ¯ Thus, the bipartition must belong to any vertex cover of G. the minimum number of subsets D u that must be part of D matches the minimum number of vertices in any vertex cover of G. Going back to the induced subgraph Gˆ [ A ], observe that any path from vˆ 0,0 to vˆ k+1,n may use only one of the arcs of each subset D u and that exactly k + 1 of those arcs must be used. Therefore, a cycle exists in Gˆ [ A ] if and only if D is composed by at least k + 1 subsets D u . In consequence, it is possible to find a set A ⊆ A that simultaneously is a vertex cover of G¯ and induces an acyclic graph in Gˆ if and only if there exists a vertex cover in G with no more than k vertices.
D = di , j = ( vˆ i , j , vˆ i +1, j +1 )/0 ≤ i ≤ k; 0 ≤ j < n A=H∪B∪D
123
E¯ = (h i , j ,0 , h i , j ,1 )/0 ≤ i ≤ k + 1; 0 ≤ j < n
∪ (bk+1,n,0 , bk+1,n,1 ) ∪ (di , j , d p ,q )/( j , q) ∈ E ; 0 ≤ i ≤ k; 0 ≤ p ≤ k
In Figs. 3 and 4 we show the application of f to a simple DVC instance with k = 2. Observe that f can be computed in polynomial time. Set Vˆ has (k + 2) × (n + 1) vertices, set A has 2 × n × (k + 2) + 2 + n × (k + 1) arcs and set E¯ has n × (k + 2) + 1 + | E | × (k + 1)2 edges. Theorem 8. The solution of DVC with graph G and integer k is yes if and only if the solution of FASPDC on the graphs returned by f (G , k) is yes. Proof. We first notice that in graph Gˆ only arcs in B are backward if the vertices are partially sorted by their second index. All other arcs go from a vertex with second index equal to j to a vertex with second index equal to
Since FASPDC is in NP and it is possible to polynomially reduce DVC to FASPDC we can conclude that FASPDC is NP-Complete. 5. Concluding remarks In this paper we introduced disjunctive constrained versions of the Maximum Acyclic Subgraph problem. The Maximum Acyclic Subgraph problem under Negative Disjunctive Constraints (MASNDC), given a list of pair of arcs, forbids both arcs in each pair to be simultaneously in a feasible solution while the Maximum Acyclic Subgraph problem under Positive Disjunctive Constraints (MASPDC) forces at least one arc in each pair to be part of a feasible solution. Both problems were introduced using the concept of constraint graphs. Six constant approximation algorithms for the MASNDC were introduced. The algorithms maintain the 1/2-approximation ratio of classic algorithms for MAS and are polynomial whenever the maximum independent set problem is polynomially solvable in the constraint graph. Moreover, we showed that determining if a feasible solution exists for an instance of MASPDC is an NP-Complete
124
S.M.S. Mapa, S. Urrutia / Information Processing Letters 115 (2015) 119–124
Fig. 4. FASPDC instance obtained with f (G , 2).
problem. We did this by a polynomial reduction from the vertex cover problem. Future work includes the development of efficient exact and heuristic approaches for MASNDC and MASPDC. References [1] P. Austrin, R. Manokaran, C. Wenner, On the NP-hardness of approximating ordering constraint satisfaction problems, in: APPROXRANDOM, in: Lect. Notes Comput. Sci., vol. 8096, Springer, 2013, pp. 26–41. [2] A. Darmann, U. Pferschy, J. Schauer, G.J. Woeginger, Paths, trees and matchings under disjunctive constraints, Discrete Appl. Math. 159 (2011) 1726–1735.
[3] M. Grötschel, L. Lovász, A. Schrijver, Geometric Algorithms and Combinatorial Optimization, Algorithms Comb., vol. 2, Springer-Verlag, 1993. [4] R. Hassin, S. Rubinstein, Approximations for the maximum acyclic subgraph problem, Inf. Process. Lett. 51 (1994) 133–140. [5] R. Karp, Reducibility among combinatorial problems, in: R.E. Miller, J.W. Thatcher (Eds.), Complexity of Computer Computations, Plenum Press, New York, 1972, pp. 85–103. [6] Subhash Khot, On the power of unique 2-prover 1-round games, in: Proceedings of the 34th Annual ACM Symposium on Theory of Computing, STOC ’02, ACM Press, 2002, pp. 767–775. [7] U. Pferschy, J. Schauer, The knapsack problem with conflict graphs, J. Graph Algorithms Appl. 13 (2009) 233–249. [8] U. Pferschy, J. Schauer, The maximum flow problem with disjunctive constraints, J. Comb. Optim. 26 (2013) 109–119. [9] N. Sbihi, Algorithme de recherche d’un stable de cardinalité maximum dans un graphe sans étoile, Discrete Math. 29 (1980) 53–76.