View on GitHub
Open this notebook in GitHub to run it yourself
Toy problem

Grover algorithm
We assignred, blue, orange, and green to the unassigned black nodes above under the given constraints. Here, in order to encode the colors in a program, we replace them with integers:
- red = 0,
- blue = 1,
- orange = 2,
- green =
- Therefore, representing a color requires at most two qubits. We assign two qubits to each node as follows.
oracle function
Next, we construct the oracle that enforces the rule that no two adjacent nodes may share the same color. This condition can be expressed using propositional logic. Here, we denote the color of each node by a variable , where each alphabet represents the node color. For example, refers to the color of node A. Let us first consider node A as a concrete example. Node A is adjacent to three other nodes, so it must satisfy the following constraints: In other words, node A must not be red or blue, and it must also have a different color from its neighbor B. Now consider node B. Since node B is connected to multiple nodes, it has the following constraints: Here, denotes AND. This means that B must not be red or orange, and it must also have a different color from its neighbors C and E. By applying this idea to each node and summarizing their respective constraints, we can express the oracle in Qmod as follows.Bulding block of Grover
Output:
Output:
post processing
