Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

[Graph Coloring] Add Kata Implementation #82

Merged
merged 6 commits into from
Jul 1, 2019

Conversation

Dan-Tran
Copy link
Contributor

This commit implements a Kata exploring using Grover's search to solve
the constraint satisfaction problem of graph coloring, coloring nodes of
a graph in such a way that no adjacent nodes share the same color.

This project was done as part of UW CSE 490 Q as its final project.
The authors are Dan Tran, Daniel Snitkovskiy, and Frederik Schmitt.

This commit implements a Kata exploring using Grover's search to solve
the constraint satisfaction problem of graph coloring, coloring nodes of
a graph in such a way that no adjacent nodes share the same color.

This project was done as part of UW CSE 490 Q as its final project.
The authors are Dan Tran, Daniel Snitkovskiy, and Frederik Schmitt.
@msftclas
Copy link

msftclas commented Mar 21, 2019

CLA assistant check
All CLA requirements met.

Copy link
Contributor

@tcNickolas tcNickolas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is definitely a good example of a problem that can be solved with Grover.

  • I don't think we should duplicate the sources on Grover's algorithm that are listed in the GroverAlgorithm kata - we can say that that one is a prerequisite, and focus this one on solving a specific problem. Did you use any sources on graph coloring problem? They would be nice to list in the readme.

  • The tests have a lot of asserts which are not really readable, even for the easy oracles. Do you think you could rewrite them using some higher-level operations, like SolveSATWithGrover kata does? Comparing the results of oracle application with results of a boolean function will be a lot more readable and maintainable.

  • The tasks seem to have a lot of duplication with GroversAlgorithm and SolveSATWithGrover. I don't know if it will be interesting for the learner to do AND and OR oracles again, especially since only AND is reused later... I would try to come up with some tasks that are more specific to this problem, and re-word them in terms of this specific problem. Here are a couple of ideas for a task sequence:

    • Given a register of 2 qubits in one of the basis states, read off a color 0..3 from it (that is used in Task4_Reference, and can be done alternatively in one library call of MeasureInteger)

    • Keep the AND oracle, since it's used later

    • Given 2 registers of 2 qubits, implement an oracle which tells if they are in the same state (that's the current task 1.3)

    • Given 2 registers of N qubits, implement an oracle which tells if they are in the same state - that's a generalization which makes one look for a more efficient implementation for larger N, and it's good to make people think about alternative implementations. You'd have to restrict the number of gates used and the number of qubits allocated to make the learner implement the in-place CNOT trick, when you do CNOT from qubits of the first register to qubits of the second register, do CCNOT from it to target and uncompute.

    • Task 2.1 asks for at least one pair of registers to be in the same state, right? If we want to take that detour (it doesn't really lead us to the graph coloring oracle itself), I'd suggest adding a task for "exactly one pair is in the same state, but not all of them" - this little twist would make it more interesting.

    • Keep tasks 2.2 and (of course :-)) 3.1.

    • Purely classical task on validating the obtained coloring.

    • Are there any other graph coloring problems which are small enough to be simulated? Edge coloring seems to require too many resources, but there are a lot of others at https://en.wikipedia.org/wiki/Graph_coloring#Other_colorings_2. Weak coloring especially looks promising, since it uses different logic, more similar to tasks 2.1 and 2.2.

There is a fair amount of work to be done, but it has the potential to make a really cool kata! (I think the question "what kinds of problems you can solve with Grover" is one of the most frequently asked ones :-)). Please let me know if you want to keep working on it; if not, I'll probably have some time for that in the second half of April.

Thank you!!

@Dan-Tran
Copy link
Contributor Author

Dan-Tran commented Apr 7, 2019

Thank you for the feedback! I really appreciate it. Unfortunately, due to school and a relatively busy schedule, I'll be unable to keep working on it. I hope that my work though is a good stepping stone for the development of the kata! Thank you for the opportunity.

Copy link
Contributor

@tcNickolas tcNickolas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the kata, keeping to tasks related to vertex coloring problem for now - we can add weak coloring and other related tasks later in new sections.

The kata looks good to me now (naturally!). @alan-geller Could you please take a look at it as a sanity check?

@tcNickolas tcNickolas merged commit 58606af into microsoft:master Jul 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants