NP-complete variants of some classical graph problems
NNP-COMPLETE VARIANTS OF SOME CLASSICAL GRAPHPROBLEMS
PER ALEXANDERSSON
Abstract.
Some classical graph problems such as finding minimal spanningtree, shortest path or maximal flow can be done efficiently. We describe slightvariations of such problems which are shown to be NP-complete. Our proofsuse straightforward reduction from 3-SAT. Introduction
Graph theory is a rich source of interesting computational problems. Considerthe following classical decision problems regarding a graph G with weighted edges: • determine if G has a spanning tree with cost ≤ k , • determine if G has a path from u to v in G with cost ≤ k , • determine if G has a flow from u to v in G with value ≥ k .These three questions can be answered efficiently, as there are algorithms for findingthe minimal spanning tree (Prim’s algorithm), shortest path (Dijkstra), or maximalflow (Ford–Fulkerson). On the other hand, determining if G has a Hamiltonian path,or if G has a k -clique are NP-complete decision problems, see [Kar72]. Introducingadditional restrictions on a problem with an efficient solution may make the problemNP-complete. For example, the problem of determining if a bipartite graph ( X, Y )has a perfect matching can be done in polynomial time. D. Plaisted consider thefollowing variant, which he shows is NP-complete.
Problem 1 (See [PZ80]) . Given a bipartite graph (
X, Y ) and partitions X , Y of X and Y , respectively, determine if there is a perfect matching such that there areno two edges { x, y } , { x , y } such that x, x are in the same block of X and y, y arein the same block of Y .In this note, we show that the following decision problems are NP-complete. prob:vecPath Problem 2 (Vector-valued shortest path) . Let G = ( V, E ) be a graph and let w : E → Z N ≥ be a vector-valued weight on the edges. For a path P = ( v , v , . . . , v ‘ ),let w ( P ) be the vector P i w ( v i , v i +1 ). Let u, v be vertices of G and let k ∈ R .Determine if there is a path P in G from u to v such that | w ( P ) | ≤ k . prob:spanningTree Problem 3 (Restricted spanning tree) . Let G = ( V, E ) be a graph and w : E → Z ≥ . Let F ⊆ E be a set of forbidden pairs of edges, and let k ∈ Z .Determine if there is a spanning tree T ⊆ E of G such there is nopair of edges of T in F , with cost ≤ k . (TEX January 14, 2020 2.48). Key words and phrases.
NP-complete, complexity, graph algorithms. a r X i v : . [ c s . CC ] J a n PER ALEXANDERSSON prob:Flow
Problem 4 (All-or-nothing flow) . Let N = ( G, s, t, c ) be a network with source s ,sink t and capacity c . Furthermore, let A be a subset of the edges of G . A flow f on N is A - valid if for all ( x, y ) ∈ A we have either f ( x, y ) = c ( x, y ) or f ( x, y ) = 0.Determine if N has an A -valid flow f with | f | ≥ k . Acknowledgements.
This note was part of the requirements for a course inmathematical communication. These proofs may serve as examples for studentstaking classes in graph theory or complexity theory.1.1.
Preliminaries on complexity theory.
We assume that the reader is familiarwith basic graph theory terminology. For a background on graph theory, we refer to[Die17].The expression “NP” refers to the class of decision problems solvable by a non-deterministic Turing machine in polynomial time . It was shown by S. Cook in 1971[Coo71] that any such decision problem can be reduced to the so called 3 -SAT prob-lem . This means that a problem which can be solved by a non-deterministic Turingmachine, can be phrased as an instances of 3-SAT. Furthermore, this translationcan be carried out in polynomial time (polynomial in the size of the input). Problem 5 (3-SAT) . Let E be a boolean expression, given as a conjunction ofclauses, where each clause involves exactly three distinct literals. A literal is eithera boolean variable, or its negation. Determine if E is satisfiable.For example, E = ( x ∨ y ∨ ¬ z ) ∧ ( ¬ x ∨ ¬ y ∨ ¬ z ) ∧ ( x ∨ ¬ y ∨ z ) is such a conjunction,and the assignment x, z = true , y = false shows that E can be satisfied.A problem class C is said to be NP-complete if any 3-SAT problem can be reduced(in polynomial time) to an instance in C . In 1972, R. Karp presented a list of 21NP-complete problems [Kar72] from various areas of mathematics, thus highlightingthe ubiquity of this notion.To this date, Karp’s list have been extended with a large variety of decisionproblems, and we shall now extend this list even further.2. NP-complete variants of decision problems
To prove that the problems listed in the introduction are NP-complete, we shalldescribe reductions from 3-SAT. We use the boolean expression B = ( x ∨ y ∨ z ) ∧ ( x ∨ z ∨ w ) ∧ ( x ∨ y ∨ w ) ∧ ( y ∨ z ∨ w ) (1) {eq:booleanB} for all our examples illustrating the reductions.2.1. Restricted spanning trees.
Given in instance of a 3-SAT problem B with C clauses, we construct a graph G as in (2) as follows.The graph G = G ( B ) has one top vertex , one bottom vertex , and (3 + 1) · C auxiliary vertices. The weights of all edges is 1, except edges marked ∗ , which hassome fixed large weight M . The three edges in each small “block” of 4 vertices havebeen labeled according to a corresponding clause in B . The forbidden set F consists P-COMPLETE VARIANTS OF SOME CLASSICAL GRAPH PROBLEMS 3 of all pairs of edges, ( a, a ), where a is a variable appearing in B . x y z x z w x y w y z w ∗ ∗ ∗ ∗ (2) {eq:rst} In order for G ( B ) to have a spanning tree which does not use any expensive (markedwith ∗ ) edge, we must be able to reach the C vertices in the third layer, via some pathfrom the top vertex. This can only be done if and only if there is a truth-assignmentof the boolean variables which makes B true. For the example in (2), the assignment x = false , y = true , z = true , w = false makes B true, and there is a cheapminimal spanning tree, not using any ∗ -edges: y x x w By picking
M > C + 1, the questionDoes G ( B ) has a good spanning tree with cost ≤ M with noforbidden pairs in F ?is true if and only if B has an assignment of variables that makes B true. We havethus showed that the restricted spanning tree problem is at least as hard as 3-SAT.Note that if we are given a spanning tree T and a set F , and a number k , we caneasily check (in polynomial time) that T is indeed a spanning tree, no pair of edgesin F appear in T , and the total cost does not exceed k . It follows that our decisionproblem is NP-complete.2.2. All-or-nothing maximal flow.
For the next decision problem we use aconstruction which is similar to that of the restricted spanning tree problem. Givena boolean expression B with C clauses and V variables, we construct a network( G, s, t, c ) as follows, see the figure in Equation (3). There is a top vertex s , thesource, and a bottom vertex t , the sink. The source is connected to V vertices, w , . . . , w V positioned at level 2. Each w i is connected to two vertices on level 3,labeled x i and x i . These “literal” vertices are all connected to the vertex l , as wellas the corresponding vertices in the C clauses.The dashed edges describe the elements in A . We have the following capacities: • Any edge starting from the top s has capacity C . • The edge ( l, t ) has capacity
V C − C . • All other edges ending at t has capacity 1. • The edges in A has capacity C . • All the other edges are given a large capacity, say
V C . PER ALEXANDERSSON stl x ¯ x y ¯ y z ¯ z w ¯ wx y z x z w x y w y z w {eq:flowExample} By construction, the restrictions imposed by A imply that at most one of vertices x and ¯ x has a non-zero flow (of size exactly C ) leaving the vertex.The edges leaving s have total capacity V C , so this is an upper bound on themaximal flow in the network. Furthermore, the flow
V C can only be obtained ifall edges flowing into t are saturated, as the total capacity of the edges adjacent to t is also V C . Hence, a maximal flow can exist only if every clause has some flowentering it (meaning at least one of the variables in the clause is true). Hence, amaximal flow can only be obtained if the boolean expression is satisfiable. On theother hand, if there is a way to satisfy B , then we can find an edge in each clause(labeled with a literal being true) with flow 1, and let the remaining flow go viavertex l . Hence, our network has a maximal flow with value V C if and only if B issatisfiable.2.3. Vector-valued path.
Given a boolean expression B corresponding to an in-stance of 3-SAT with C clauses and V variables, we construct a weighted graph G on 4 V + 5 C vertices as follows. For each clause c i , we have the vertices { a i , w i , w i , w i , b i } , and edges ( a i , w ij ), ( w ij , b i ) for j = 1 , ,
3. We also have theedges ( b i − , a i ) for all i = 2 , . . . , C . This part of the graph is the clause subgraph .Furthermore, for each variable x i , there are vertices { u iin , u i , u i , u iout } , and edges( u iin , u i ), ( u i , u iout ), ( u iin , u i ), ( u i , u iout ) as well as the edges ( u i − out , u iin ) for all i =2 , . . . , V . This part of the graph is the variable subgraph . Finally, we have an edge( u Vout , a ) connecting the two subgraphs.We shall now assign vector-valued weights with values in the 2 V -dimensionalvector space N V ⊕ N V . We let e i denote the i th unit vector in the first set ofcoordinates, and e i the i th unit vector in the second set of coordinates. The V edges ( u iin , u i ) and ( u iin , u i ) are given the weights M e i and M e i , respectively, where M (cid:29) a i , v ij ) is given weight e ‘ (or e ) if x ‘ (or x ‘ ) is the variable at position j in clause i , and the remaining edges in the graphare assigned weight 0 in every coordinate.We shall now argue that B is satisfiable if and only if the questionIs there is a path P from u in to b C with cost at most √ V M + C ?has a positive answer. P-COMPLETE VARIANTS OF SOME CLASSICAL GRAPH PROBLEMS 5 xxyyzzwwxyz xzw xyw yzw
Figure 1.
Only the labeled edges have non-zero weight. The pathgoes from the upper-rightmost vertex ( u in ) to the lower right-mostvertex ( b C ). fig:shortestPath Any shortest path P from u in to b C must use exactly one of the edges withweight M e i or M e i , so at least half of the 2 V available coordinates are non-zero inthe cost of P . Let us call these edges (and corresponding coordinates) in P largeedges . If there are no other edges in the path using the large coordinates, the totalcost squared is less than V M + C , (Satisfiable-upper-bound)as the maximal value in any of the remaining coordinates is C , and there are atmost C such coordinates.Suppose now that there is some additional edge using a large coordinate e i in P .Then the total cost squared is at least( M + 1) + ( V − M > V M + 2 M, (Unsatisfiable-lower-bound)the first term is the contribution from coordinate e i , and there is a contributionfrom the V − M . By choosing M > C , we have that V M + 2 M > V M + C , so there is a path with cost not exceeding √ V M + C if and only if we can avoid having additional edges with non-zero value at a largecoordinate. Such a path can be found if and only if the corresponding 3-SATproblem is satisfiable. Question 6.
In the above setting, the length of the vector is allowed to depend on V , the number of variables. What if the length is a fixed constant instead? Is theproblem still in NP? References [Coo71] Stephen A. Cook. The complexity of theorem-proving procedures. In
Proceedings of theThird Annual ACM Symposium on Theory of Computing , STOC ’71, pages 151–158, NewYork, NY, USA, 1971. ACM. doi:10.1145/800157.805047 .[Die17] Reinhard Diestel.
Graph Theory . Springer Berlin Heidelberg, 2017. doi:10.1007/978-3-662-53622-3 .[Kar72] Richard M. Karp. Reducibility among combinatorial problems. In
Complexity of ComputerComputations , pages 85–103. Springer US, 1972. doi:10.1007/978-1-4684-2001-2_9 .[PZ80] David A. Plaisted and Samuel Zaks. An NP-complete matching problem.
Discrete AppliedMathematics , 2(1):65–72, April 1980. doi:10.1016/0166-218x(80)90055-4 . PER ALEXANDERSSON
Dept. of Mathematics, Stockholm University, Sweden
E-mail address ::