Part 1:
For this problem, we will demonstrate that the problem is NP-Complete via a poly-time transformation from the known NP-Complete problem . We prove this in 2 parts: (1) we show is NP and (2) we present a polynomial transformation.
→ Showing is NP
To show this is NP, we first define the data type of the certificates. For this problem, this will be an array of vertices, where each vertex can be represented with an integer . The desired yes-certificate format is an array of vertices that form a simple s-t path in the graph with total weight at most .
Now, we design a poly-time verify(I,C)
algorithm, keeping in mind the oracle is non-deterministic:
→ We show the runtime for this algorithm is polynomial on the input size.
- The cost of this algorithm comes from iterating through the variables in the path. We know as we can have at most n vertices (all vertices) in the s-t path. So, this loop is bounded above by which is then bounded by .
- We analyze this with respect to the input size. Since we are in the unit-cost model, are constant space. The weight array has entries in it. For this graph, we can use the input size cheat sheet, defining the input size of to be .
- Thus, it can then be seen that the run-time is poly-time on the input size: runtime → =
Now that we have the poly-time verification algorithm, we provide a correctness proof for it.
→ Case 1: Let be any yes-instance → find such that **verify(I,C) = True**
- Let be any yes-instance of the problem. Since is a yes-instance, that means there must exist a simple s-t path , such that the path weight is . So, this will go through each check of the
verify(I,C)
algorithm, and we will see that:- The first vertex is and the last one is → will not return false in the first line
- All the edges in are indeed in the original graph , so the first
for
loop will not return false - There are no duplicate vertices since it is simple → after the second
for
loop will not return false - By definition, has path weight , so the return statement, the verification algorithm will return true
→ Case 2: If **verify(I,C)**
is true → prove is a yes-instance
- Suppose
verify(I,C)
is true. Then this means we:- At the first line, we did not return false, this means this path does start at and end at
- At the first for loop, did not return false. This means all edges found in path were in the graph , no extra or non-existent edges
- After the second for loop, when we compared the size of the path to the path inserted into a set (which only allows for distinct elements), we did not return false, which means the path has no duplicate vertices → simple
- At the end, we returned true, this means the sum of the edge weights in is
- So proves the existence of a simple s-t path with path weight
We have proven that is NP. Now, to prove that is is NP-Complete, we provide a polynomial transformation from the known NP-Complete problem: . To do so, we first define a poly-time transformation function. Consider the following transformation:
- Consider any input for the problem. So, the input is simply a directed graph .
- For each , we assign the edge a weight of , so that
- We assign the value
- Now, we need to assign values for and to map to a problem. To do so, can perform the following step:
- We add 2 new nodes and add edges between all nodes and , with no edge directly between and . We give each of these edges an edge weight of 0
- We make our source node and our destination node
- We argue this transformation has polynomial run-time on the input size:
- In total, we re-assign all edge weights →
- We add new edges between to all other edges →
- So total runtime comes to →
- For this problem, we say the input size is
- Thus, it is clear that the run time is polynomial on the input size.
- This polynomial transformation applies a transformation to the input, and a single call to the oracle without modification
→ We argue this transformation satisfies 2 key conditions:
- → If then
- Suppose is a yes-instance for the DHP problem. That its, we’re given a directed graph that contains a hamiltonian path. This hamiltonian path has a start node and destination node. By the transformation, this hamiltonian path now has a new head and new tail . Now, say the hamiltonian path is with path weight since there are edges and each edge has weight . Now with the transformation, we have the s-t path which still has path weight . By definition, it is a simple path as we only visit each node once, so we need to show this path has weight . In the transformation, we have defined to be . Therefore, this path is a simple s-t path that has path weight , and thus, .
- ← If then
- Suppose is a yes-instance of the modified s-t path problem. So, we know there is a simple s-t path that has path weight . Now, we know from the transformation, that each edge was weight and . Since there is an s-t path with path weight of the form: , then since and have edge weight 0, then that means the path must also have path weight . Given that each edge was weight , this tells us there must be edges in . So, consider removing nodes and and all associated edges. Now, the remaining graphs has nodes. We know the existence of the path which has edges and thus visits all vertices in the graph. So, by definition, this is a directed hamiltonian path → we obtain instance such that .
Therefore, as we proved that is in NP and that there is a valid polynomial transformation from a NP-Complete problem, we conclude that is also NP-Complete.
Part 2:
For this problem, we will demonstrate that the problem is NP-Complete via a poly-time transformation from the known NP-Complete problem . We prove this in 2 parts: (1) we show is NP and (2) we present a polynomial transformation.
→ Showing is NP
To show this is NP, we first define the data type of the certificates. For this problem, this will be an set/array of integers. The desired yes-certificate format is an array of integers, such that there exists a subset that has sum 1. Now, we design a poly-time verify(I,C)
algorithm, keeping in mind the oracle is non-deterministic:
We show this poly-time on the input size: Checking whether is can be done in polynomial time → for example, we could perform a binary search for each element in . There are items in and at most items in , meaning this is at worst . Evidently, this certificate verification algorithm runs in poly-time with respect to the input size.
Now that we have the poly-time verification algorithm, we provide a correctness proof for it.
→ Case 1: Let be any yes-instance → find such that **verify(I,C) = True**
Given is a yes-instance, that means there is some subset that has sum equal to 1. For any such subset , verify(I,C)
will return true.
→ Case 2: If **verify(I,C)**
is true → prove is a yes-instance
Say the verification algorithm returns true, this means that is a subset, where its sum is 1. Therefore, is a yes-instance for the problem.
We have proven that is NP. Now, to prove that is is NP-Complete, we provide a polynomial transformation from the known NP-Complete problem: . To do so, we first define a poly-time transformation function. Consider the following transformation:
- For every integer in the input, we multiply it by 10
- Then, for each positive value , we add to the set of integers as well
- Then, we can call the oracle for
Clearly, this transformation is polynomial on the input size.
→ We argue this transformation satisfies 2 key conditions:
- → If then
- Suppose is a yes-instance for problem. So, there exists a subset that has sum equal to 0. Let’s consider the effects of the transformation on . Say with sum 0, where we’ve moved negatives to the left and positives to the right for easy of demonstration. So, after the transformation, this set will look like . Notice that first part of the union still has sum 0, as scaling by a factor of 10 does not have effect on the sum. Now, notice that by replacing any of the positive terms in the left set, with that term itself + 1 found in the right set, then there exists a subset , where the sum of is 1. Hence, stepping back, we then have a subset that has sum equal to 1. Hence, .
- If then
- Suppose is a yes-instance. So, this means there exists a subset with sum 1. That is, there is some set where the sum is 1. By the construction of transformation, one of these numbers ends with 1 (every term in either ends in 0 or 1, and is either a multiple of 10, or one more than a multiple of 0) and the rest will end in 0. Those ending in 0 are negative and those ending in 1 are positive. During the transformation, for all 1-ending terms , the value is also in . So, since for the one element ending one in the subset of that sums to 1, we replace it with it’s counterpart. Now, we effectively decremented that subset’s sum by 1, thus making it 0. Now, we can remove all excess values ending in 1, and scale back down by dividing by 10. Regardless of this step, we have obtained a set of integers , where there is a subset with sum 0. Thus,
Therefore, as we proved that is in NP and that there is a valid polynomial transformation from a NP-Complete problem, we conclude that is also NP-Complete.