INDIAN INSTITUTE OF INFORMATION
TECHNOLOGY, DESIGN &
MANAGEMENT, KANCHEEPURAM
STUDY OF NP-COMPLETE PROBLEMS
COMPUTING OPTIMUM SOLUTIONS AND POLYNOMIAL TIME
REDUCTIONS
K SESHAGIRI RAO 2010UIT190
MNIT JAIPUR
INTERNSHIP OVERVIEW
• STUDY OF NP-COMPLETENESS
• PERMUTATION PROBLEMS
• SUBSET PROBLEMS
• POLYNOMIAL TIME REDUCTIONS
• CONCLUSION
INTRODUCTION
• Any problem is either solvable or unsolvable
• Solvability depends on the availability of an algorithm that terminates in
finite amount of time
• An unsolvable problem may be due to its infinitely large domain or due to
unavailability of an algorithm
• So, it can be said that a problem is unsolvable if the algorithm NEVER
TERMINATES!
SOLVABLE PROBLEMS
• Efficiency depends on time and space complexities!
• Time complexity is dependent on H/W configuration
• As a better measure, number of steps taken to solve may be considered
1. Polynomial Time – O(nk), k is a +ve integer
2. Exponential Time – O(kn), k is a +ve integer
NP COMPLETENESS
• Problems solved in a machine with countably infinite no of processors
within a polynomial amount of time belong to NP-Class
• NP is the set of decision problems where the "yes"-instances can be
accepted in polynomial time by a non-deterministic Turing machine
• A decision problem C is NP-complete if:
1. C is in NP, and
2. Every problem in NP is reducible to C in polynomial time
or one NPC problem is reducible to C in polynomial time
PERMUTATION PROBLEMS
HAMILTONIAN PATH
• A Hamiltonian path is a path that visits each vertex exactly once
• Trivial solution to this problem is an exponential time one with a complexity
O(n!)
• This is known to be NP-Complete by a polynomial-time
reduction from the Vertex Cover problem
HAMILTONIAN PATH
• Exactly n-1 edges are present in the Hamiltonian path ( say n-vertex graph)
• Pass G to decision box and if this returns yes, there is a Hamiltonian path
for this problem. If no, then no such path exists
• If yes, remove the first edge and let the new graph be G1. Pass G1 to the
decision box. If yes, there is a Hamiltonian path which does not include that
edge. If no, it means that the edge is a must in the Hamiltonian path.
• Proceed until all the edges are checked in a similar way.
• Complexity is O(n).
HAMILTONIAN CYCLE
• Hamiltonian cycle of a graph G is a sub graph such that each vertex is
traversed exactly once, except the ones at the edge of the cycle, and all the
vertices in the graph are covered
• Trivial solution to this problem is an exponential time
one with a complexity O(n!)
• The algorithm to solve this problem is exactly same as the one
explained for Hamiltonian Path!
3-VERTEX COLORING
• It is a way of coloring the vertices of a graph such that no two adjacent
vertices share the same color and we must use exactly 3 colors in the graph
to color the vertices
• The trivial solution to solve this coloring problem runs
typically with a complexity O(3n)
• Let G with vertex set V(G) and color set {c1, c2, c3}
• Using this decision box algo, the total complexity of coloring
is O(3*m) in the worst case
• Pass G to the decision box which checks if the graph can be colored using
only 3 colors or less. If yes, proceed and if no, no 3 color graph exists
• Color vertex v1 with c1 and then pass new graph G1 to decision box
• If it gives yes, leave the vertex colored. Otherwise, change the color to c2
and again pass G1 to decision box. Similarly, do upto we get a yes or all 3
colors are used up
• Repeat the procedure for all the vertices and this must finally leave a graph
colored with 3 colors given in the color set.
• If we get no at any vertex after using all colors, no solution exists for that G
3-VERTEX COLORING
3 EDGE COLORING
• An edge coloring of a graph is an assignment of “colors” to the edges of the
graph so that no two adjacent edges have the same color and 3 colors are
used exactly on a whole here
• The trivial solution to solve this coloring problem runs
typically with a complexity O(3n)
• Let G with edge set E(G) and color set {c1, c2, c3}
• Remove edges one by one and check the algo similar to
Vertex coloring
• The total complexity of coloring is O(3*m) in the worst case
SUBSET PROBLEMS
MINIMUM VERTEX COVER
• A vertex cover of a graph G is a set C of vertices such that each edge of G
is incident to at least one vertex in C
• A minimum vertex cover of a graph is the set of minimum possible no. of
vertices that cover all the edges in the graph
• No successful polynomial time algorithm has been designed till today to find
an optimum solution to this problem
• Trivial solution complexity is O(2n)
MINIMUM VERTEX COVER
ALGORITHM PROPOSED
1. Sort the vertices in descending order of the degree of vertices.
2. Pick the one with max degree and remove all the edges that are connected
to this vertex.
3. Pick max from the remaining set.
4. Repeat this till the set of edges in the graph becomes zero.
• This algorithm also definitely runs in polynomial time and gives a VC! But it
cant be proven to be a min VC
MINIMUM VERTEX COVER
Algo using decision box:
• Let the total no of vertices be ‘n’ and set be V(G) in graph G and let the set of
edges be E(G).
• Now, is known that V(G) is itself a VC with cardinality n.
• Pass G, n to the decision box that tests if there exists a vertex cover of size n in
graph G and returns yes if present otherwise no. If yes, pass G, n-1 and continue
this until a first no appears.
• Say G, k is yes and G, k-1 is no. So, k is the cardinality of the minimum vertex cover.
So, this runs with a complexity O(n)
MINIMUM VERTEX COVER
• Remove a vertex v1 from the graph G and say its G1 and pass G1, k to
decision box and see if the min VC changes.
• If it says it doesn’t change, the vertex v1 is not present in the VC and if it
changes, that means this vertex v1 is a part of VC and add this to the set of
VC
• Add this back and now remove v2 and check similarly. This will finally
generate the min VC for the graph G
• This gives only one of the all possible solutions and complexity is O(n)
MINIMUM STEINER TREE
• For a graph G, let V(G) is set of vertices &
given R, a set of vertices & integer K, then
Steiner tree is the tree which contains all R&
has minimum total length <=K
• Similar to Min Spanning Tree
• Multiple solutions exist
• Trivial Solution is O(2n)
FINDING SIZE OF MIN STEINER TREE
• The minimum number of edges needed is |R| - 1
• Now pass G, |R|-1 to Decision box which checks if there is some possibility in
the graph such that vertices in R may be connected using exactly |R|-1 number
of vertices.
• If yes, proceed forward or else increase the number of edges passed by 1 and
pass to decision box until k is reached in similar manner i.e., G, i is passed
where i ranges from |R|-1 to k
• Stop at a position you get “Yes” or at the end when i reaches K and we get a no
MINIMUM STEINER TREE
FINDING THE TREE ITSELF
• After obtaining the min number of edges, say l, remove an edge say e1 from the
graph and let the new graph be G1.
• Pass G1, l to decision box to see if it gives yes or not.
• Go on like this removing it the edges as long as the graph says yes and on
obtaining no, restore the removed edge and this means that it is present in the
min Steiner tree.
• This runs with complexity of O(n).
MINIMUM STEINER TREE
MINIMUM DOMINATING SET
• A dominating set for a graph G (V, E) is a subset DS of V such that every
vertex not in DS is adjacent to at least one member of DS
• Minimum DS is a DS with least possible cardinality
• Multiple solutions may exist
• No polynomial time solution found till date
• Trivial Solution Complexity - O(2n)
MINIMUM DOMINATING SET
• Let n is total number of vertices G.
• The vertex set V(G) is a dominating set of size n.
• So, continuously pass G, i to decision box until we get a “no” such that i
starts from n and ends at 1, reducing in steps of 1. Suppose we get first false
at k-1. Then k is the cardinality of the min DS
• Then remove each vertex one by one after passing new graph G1, k such
that if we get a no, add that vertex to DS else leave that removed from the
graph
MAXIMUM CLIQUE
• A clique in an undirected graph G is a subset of its vertices such that every
two vertices in the subset are connected by an edge
• Maximum clique is a clique for G with largest possible cardinality
• Maximal clique is a set of vertices so that if other vertex in the
graph can be added to, it will no longer remain a clique.
• Every maximum clique is a maximal clique but converse is not always true.
• For a complete graph, size of the maximum clique is ‘n’ and for all the rest
of the graphs, it is always < n
• Trivial Solution Complexity O(2n)
MAXIMUM CLIQUE
• Every single vertex is a clique.
• So, start passing G, i to decision box where, G is the graph and 1<= i <=n.
• Stop at the point where G, i is false for the first time. So, i-1 is largest clique(say K)
• Remove the vertex v1 from the graph and pass the new graph G1, k to the
decision box and see if it is true. If it is true, remove that vertex. If it is false, add
it back
• Now check similarly for v2 to vn and the graph left finally is the maximum clique
OPTIMIZATION
• Similarly,
Satisfiability and Exact-3-Cover problems are also solved in
polynomial time using a decision box
POLYNOMIAL-TIME REDUCTIONS
• In computational complexity theory, a polynomial-time reduction is a
reduction which is computable by a deterministic Turing machine in
polynomial time
• Reduction is a method of solving one problem by means of a hypothetical
subroutine for solving a different problem
• A polynomial-time reduction proves that the first problem is no more
difficult than the second one, because whenever an efficient algorithm exists
for second problem, one exists for the first problem as well
CONCLUSION
• A problem is NP-Complete if belongs to the class of NP problems and
It must be reducible to each and every other problem in NP class
Or
It must be reduced in polynomial time from any 1 NP-Complete problem
• Assumption is that SAT is an NPC and from that we have reduced various
problems that are discussed above. For eg., are Hamiltonian Path and cycle
Vertex & Edge Coloring, Steiner Tree, DS, Min VC, Max IS, Max Clique,
X3C

NP Complete Problems -- Internship

  • 1.
    INDIAN INSTITUTE OFINFORMATION TECHNOLOGY, DESIGN & MANAGEMENT, KANCHEEPURAM STUDY OF NP-COMPLETE PROBLEMS COMPUTING OPTIMUM SOLUTIONS AND POLYNOMIAL TIME REDUCTIONS K SESHAGIRI RAO 2010UIT190 MNIT JAIPUR
  • 2.
    INTERNSHIP OVERVIEW • STUDYOF NP-COMPLETENESS • PERMUTATION PROBLEMS • SUBSET PROBLEMS • POLYNOMIAL TIME REDUCTIONS • CONCLUSION
  • 3.
    INTRODUCTION • Any problemis either solvable or unsolvable • Solvability depends on the availability of an algorithm that terminates in finite amount of time • An unsolvable problem may be due to its infinitely large domain or due to unavailability of an algorithm • So, it can be said that a problem is unsolvable if the algorithm NEVER TERMINATES!
  • 4.
    SOLVABLE PROBLEMS • Efficiencydepends on time and space complexities! • Time complexity is dependent on H/W configuration • As a better measure, number of steps taken to solve may be considered 1. Polynomial Time – O(nk), k is a +ve integer 2. Exponential Time – O(kn), k is a +ve integer
  • 5.
    NP COMPLETENESS • Problemssolved in a machine with countably infinite no of processors within a polynomial amount of time belong to NP-Class • NP is the set of decision problems where the "yes"-instances can be accepted in polynomial time by a non-deterministic Turing machine • A decision problem C is NP-complete if: 1. C is in NP, and 2. Every problem in NP is reducible to C in polynomial time or one NPC problem is reducible to C in polynomial time
  • 6.
    PERMUTATION PROBLEMS HAMILTONIAN PATH •A Hamiltonian path is a path that visits each vertex exactly once • Trivial solution to this problem is an exponential time one with a complexity O(n!) • This is known to be NP-Complete by a polynomial-time reduction from the Vertex Cover problem
  • 7.
    HAMILTONIAN PATH • Exactlyn-1 edges are present in the Hamiltonian path ( say n-vertex graph) • Pass G to decision box and if this returns yes, there is a Hamiltonian path for this problem. If no, then no such path exists • If yes, remove the first edge and let the new graph be G1. Pass G1 to the decision box. If yes, there is a Hamiltonian path which does not include that edge. If no, it means that the edge is a must in the Hamiltonian path. • Proceed until all the edges are checked in a similar way. • Complexity is O(n).
  • 8.
    HAMILTONIAN CYCLE • Hamiltoniancycle of a graph G is a sub graph such that each vertex is traversed exactly once, except the ones at the edge of the cycle, and all the vertices in the graph are covered • Trivial solution to this problem is an exponential time one with a complexity O(n!) • The algorithm to solve this problem is exactly same as the one explained for Hamiltonian Path!
  • 9.
    3-VERTEX COLORING • Itis a way of coloring the vertices of a graph such that no two adjacent vertices share the same color and we must use exactly 3 colors in the graph to color the vertices • The trivial solution to solve this coloring problem runs typically with a complexity O(3n) • Let G with vertex set V(G) and color set {c1, c2, c3} • Using this decision box algo, the total complexity of coloring is O(3*m) in the worst case
  • 10.
    • Pass Gto the decision box which checks if the graph can be colored using only 3 colors or less. If yes, proceed and if no, no 3 color graph exists • Color vertex v1 with c1 and then pass new graph G1 to decision box • If it gives yes, leave the vertex colored. Otherwise, change the color to c2 and again pass G1 to decision box. Similarly, do upto we get a yes or all 3 colors are used up • Repeat the procedure for all the vertices and this must finally leave a graph colored with 3 colors given in the color set. • If we get no at any vertex after using all colors, no solution exists for that G 3-VERTEX COLORING
  • 11.
    3 EDGE COLORING •An edge coloring of a graph is an assignment of “colors” to the edges of the graph so that no two adjacent edges have the same color and 3 colors are used exactly on a whole here • The trivial solution to solve this coloring problem runs typically with a complexity O(3n) • Let G with edge set E(G) and color set {c1, c2, c3} • Remove edges one by one and check the algo similar to Vertex coloring • The total complexity of coloring is O(3*m) in the worst case
  • 12.
    SUBSET PROBLEMS MINIMUM VERTEXCOVER • A vertex cover of a graph G is a set C of vertices such that each edge of G is incident to at least one vertex in C • A minimum vertex cover of a graph is the set of minimum possible no. of vertices that cover all the edges in the graph • No successful polynomial time algorithm has been designed till today to find an optimum solution to this problem • Trivial solution complexity is O(2n)
  • 13.
    MINIMUM VERTEX COVER ALGORITHMPROPOSED 1. Sort the vertices in descending order of the degree of vertices. 2. Pick the one with max degree and remove all the edges that are connected to this vertex. 3. Pick max from the remaining set. 4. Repeat this till the set of edges in the graph becomes zero. • This algorithm also definitely runs in polynomial time and gives a VC! But it cant be proven to be a min VC
  • 14.
    MINIMUM VERTEX COVER Algousing decision box: • Let the total no of vertices be ‘n’ and set be V(G) in graph G and let the set of edges be E(G). • Now, is known that V(G) is itself a VC with cardinality n. • Pass G, n to the decision box that tests if there exists a vertex cover of size n in graph G and returns yes if present otherwise no. If yes, pass G, n-1 and continue this until a first no appears. • Say G, k is yes and G, k-1 is no. So, k is the cardinality of the minimum vertex cover. So, this runs with a complexity O(n)
  • 15.
    MINIMUM VERTEX COVER •Remove a vertex v1 from the graph G and say its G1 and pass G1, k to decision box and see if the min VC changes. • If it says it doesn’t change, the vertex v1 is not present in the VC and if it changes, that means this vertex v1 is a part of VC and add this to the set of VC • Add this back and now remove v2 and check similarly. This will finally generate the min VC for the graph G • This gives only one of the all possible solutions and complexity is O(n)
  • 16.
    MINIMUM STEINER TREE •For a graph G, let V(G) is set of vertices & given R, a set of vertices & integer K, then Steiner tree is the tree which contains all R& has minimum total length <=K • Similar to Min Spanning Tree • Multiple solutions exist • Trivial Solution is O(2n)
  • 17.
    FINDING SIZE OFMIN STEINER TREE • The minimum number of edges needed is |R| - 1 • Now pass G, |R|-1 to Decision box which checks if there is some possibility in the graph such that vertices in R may be connected using exactly |R|-1 number of vertices. • If yes, proceed forward or else increase the number of edges passed by 1 and pass to decision box until k is reached in similar manner i.e., G, i is passed where i ranges from |R|-1 to k • Stop at a position you get “Yes” or at the end when i reaches K and we get a no MINIMUM STEINER TREE
  • 18.
    FINDING THE TREEITSELF • After obtaining the min number of edges, say l, remove an edge say e1 from the graph and let the new graph be G1. • Pass G1, l to decision box to see if it gives yes or not. • Go on like this removing it the edges as long as the graph says yes and on obtaining no, restore the removed edge and this means that it is present in the min Steiner tree. • This runs with complexity of O(n). MINIMUM STEINER TREE
  • 19.
    MINIMUM DOMINATING SET •A dominating set for a graph G (V, E) is a subset DS of V such that every vertex not in DS is adjacent to at least one member of DS • Minimum DS is a DS with least possible cardinality • Multiple solutions may exist • No polynomial time solution found till date • Trivial Solution Complexity - O(2n)
  • 20.
    MINIMUM DOMINATING SET •Let n is total number of vertices G. • The vertex set V(G) is a dominating set of size n. • So, continuously pass G, i to decision box until we get a “no” such that i starts from n and ends at 1, reducing in steps of 1. Suppose we get first false at k-1. Then k is the cardinality of the min DS • Then remove each vertex one by one after passing new graph G1, k such that if we get a no, add that vertex to DS else leave that removed from the graph
  • 21.
    MAXIMUM CLIQUE • Aclique in an undirected graph G is a subset of its vertices such that every two vertices in the subset are connected by an edge • Maximum clique is a clique for G with largest possible cardinality • Maximal clique is a set of vertices so that if other vertex in the graph can be added to, it will no longer remain a clique. • Every maximum clique is a maximal clique but converse is not always true. • For a complete graph, size of the maximum clique is ‘n’ and for all the rest of the graphs, it is always < n • Trivial Solution Complexity O(2n)
  • 22.
    MAXIMUM CLIQUE • Everysingle vertex is a clique. • So, start passing G, i to decision box where, G is the graph and 1<= i <=n. • Stop at the point where G, i is false for the first time. So, i-1 is largest clique(say K) • Remove the vertex v1 from the graph and pass the new graph G1, k to the decision box and see if it is true. If it is true, remove that vertex. If it is false, add it back • Now check similarly for v2 to vn and the graph left finally is the maximum clique
  • 23.
    OPTIMIZATION • Similarly, Satisfiability andExact-3-Cover problems are also solved in polynomial time using a decision box
  • 24.
    POLYNOMIAL-TIME REDUCTIONS • Incomputational complexity theory, a polynomial-time reduction is a reduction which is computable by a deterministic Turing machine in polynomial time • Reduction is a method of solving one problem by means of a hypothetical subroutine for solving a different problem • A polynomial-time reduction proves that the first problem is no more difficult than the second one, because whenever an efficient algorithm exists for second problem, one exists for the first problem as well
  • 25.
    CONCLUSION • A problemis NP-Complete if belongs to the class of NP problems and It must be reducible to each and every other problem in NP class Or It must be reduced in polynomial time from any 1 NP-Complete problem • Assumption is that SAT is an NPC and from that we have reduced various problems that are discussed above. For eg., are Hamiltonian Path and cycle Vertex & Edge Coloring, Steiner Tree, DS, Min VC, Max IS, Max Clique, X3C