|
| 1 | +--- |
| 2 | +tags: |
| 3 | + - OMSCS |
| 4 | + - Algorithms |
| 5 | + - Practice |
| 6 | +--- |
| 7 | +# 8.15 - Maximum Common Subgraph |
| 8 | + |
| 9 | +Show that the following problem is NP-complete. |
| 10 | +- **Maximum Common Subgraph (MCS)** |
| 11 | +- **Input:** Two graphs $G_1=(V_1,E_1)$ and $G_2 = (V_2,E_2)$; a budget $b$. |
| 12 | +- **Output:** Two set of nodes $V'_1 \subseteq V_1$ and $V'_2 \subseteq V_2$ whose deletion leaves at least $b$ nodes in each graph, and makes the two graphs identical. |
| 13 | + |
| 14 | +## MCS in NP Notes |
| 15 | +How do we validate the solution in P-time? |
| 16 | + |
| 17 | +- Count vertices, make sure they're the same. |
| 18 | +- Count edges, make sure they're the same. |
| 19 | +- Get vertex degrees, make sure they have the same distribution of vertex degrees. |
| 20 | +- If undirected |
| 21 | + - Check number/sizes of connected components. |
| 22 | +- If directed |
| 23 | + - Check SCCs |
| 24 | +- Wait, this one might not be verifiable in P-time. |
| 25 | + |
| 26 | +The Graph Isomorphism problem is unknown as whether it's in P or NP-Complete. In the general case, this question if MCS in NP is indeterminate. In the context of this course/problem, we assume that the graphs $G_1$ and $G_2$ were derived from the same set of vertices, and therefore $G_1'$ and $G_2'$ have the same vertex labels. |
| 27 | + |
| 28 | +## MCS in NP |
| 29 | +A solution to the MCS problem can be verified through a multi-step polynomial-time process. |
| 30 | + |
| 31 | +- Construct $G'_1$ and $G'_2$ by removing $V_1'$ from $V_1$ and removing $V_2'$ from $V_2$. This step is at worst $O(n^2)$. |
| 32 | +- Count the number of vertices in both $G_1'$ and $G_2'$. Make sure the are the same number and equal to $b$. This step is $O(n)$. |
| 33 | + - For all vertices in $G_1'$, check that the vertex exists in $G_2'$. This step is at worst $O(n^2)$. |
| 34 | + - Count the number of edges in both $G'_1$ and $G'_2$. Make sure this is the same. This step is $O(n+m)$. |
| 35 | + - For each edge in $G_1'$, check to make sure that the edge exists in $G_2'$. This step is $O((n+m)^2)$ |
| 36 | + |
| 37 | +The overall verification runtime is $O((n+m)^2)$, which is polynomial in the size of $I$. Therefore, the MSC problem is in NP. |
| 38 | + |
| 39 | +## Reduction Idea |
| 40 | +- We can easily reduce from Clique problem or the IS problem. We will use the IS problem because I always use the Clique problem. |
| 41 | +- Set $G_1=(V_1,E_1)=G=(V,E)$ |
| 42 | +- Create an IS of size $|V|$ by making a $G_2=(V_2,\emptyset)$, where $|V_2|=|V|$. |
| 43 | +- Set $b=g$ |
| 44 | +- Since $G_2$ contains all possible ISets from 1 to $|V|$, the solution to the MCS problem must be 2 ISs of size $b$, where one of the ISs came from $G$. |
| 45 | +- Return $S=V-V'_1$ as a solution to the IS problem. |
| 46 | + |
| 47 | +**A big note**, I originally wrote to create an IS of only size $g$. This presents a problem with the note from earlier, in that the Graph Isomorphism problem is unknown as being part of P or NP-Complete. Therefore, we must create an IS with the same size as $G$, so that an IS in $G$ of size $g$ can be found which has the same vertex labels as the artificially constructed IS. |
| 48 | + |
| 49 | +## Reduction from IS to MCS |
| 50 | +We will demonstrate that the IS problem can be reduced to the MCS problem, demonstrating that the MCS problem is in NP-Hard. |
| 51 | + |
| 52 | +### Input Transformation |
| 53 | +Take an instance $I=(G=(V,E), g)$ of the IS problem. |
| 54 | + |
| 55 | +- Create $G_1$, a perfect copy of $G$. $O(n+m)$ |
| 56 | +- Create $G_2$, a copy of $G$ containing all the vertices of $G$, but no edges. $O(n)$ |
| 57 | +- Set $b=g$. This is $O(1)$ |
| 58 | + |
| 59 | +Use $I'=(G_1,G_2,b)$ as the instance of the MCS problem. This transformation requires $O(n+m)$ time, which is polynomial in $|I|$. |
| 60 | + |
| 61 | +### Output Transformation |
| 62 | +If there is no solution to the MCS problem, return "no" as the solution to the IS problem. |
| 63 | + |
| 64 | +If there is a solution to the MCS problem, we are given $S=(V'_1, V'_2)$. Create the solution to the IS problem $S'$ by removing all vertices in $V_1'$ from $V$. This requires $O(n^2)$ time at worst. |
| 65 | + |
| 66 | +### Justification |
| 67 | +The IS problem seeks to find a subset of vertices $S \subseteq V$ which have no edges between them in $G$, where $|S|=g$. We can find that subset using the MCS problem, by artificially constructing $G_2$ which only contains vertices, and is therefore an IS of size $|V|$. All independent sets in $G$ of any size also exist in $G_2$. Therefore, if we find a common subgraph between $G$ and $G_2$, that common subgraph is an IS. If that subgraph is of size $b=g$, then we have a solution to the IS problem. |
| 68 | + |
| 69 | +If the IS problem has a solution, then there exists an IS in G of size $g$. Therefore, there exists a solution to the MCS problem, because that IS can pair up with the corresponding vertices of $G_2$ to form 2 identical subgraphs. |
| 70 | + |
| 71 | +If the IS problem doesn't have a solution, there there does not exist an IS in G of size $g$. Therefore, there does not exist a solution to the MCS problem, because there is no way to extract a subgraph of G of size $b$ which matches any subgraph of $G_2$ of size $b$. |
| 72 | + |
| 73 | +Therefore, the MCS problem has a solution if-and-only-if the IS problem has a solution. |
| 74 | + |
| 75 | +## Conclusion |
| 76 | +We have demonstrated that the MCS problem is in NP, by demonstrating a polynomial time solution verification algorithm. We have also shown that the MCS problem is in NP-Hard, by demonstrating that there exists a reduction from the IS problem to the MCS problem. Therefore, the MCS problem is in NP-Complete. |
0 commit comments