Package: gsgmorph
G/SG MorphThe Graph/Subgraph Isomorphism Library for Quantum AnnealersG/SG Morph is an implementation ofCalude, Dinneen, and Hua's "QUBO formulations for the graph isomorphism problem and related problems"(Quantum Unconstrained Binary Optimization) QUBO's for finding graph, subgraph, and induced subgraph isomorphisms on quantum annealers.G/SG Morph also contains, with the permission of Richard Hua, a copy of his implementation of the Graph Isomorphism QUBO from his thesis"Adiabatic Quantum Computing with QUBO Formulations", Appendix Ewhich is used for benchmarking (see "Benchmarking" in this README).InstallationYou can eitherpip install gsgmorphor clone this repository and run the following in the folder (and your choice of python environment!):pip install .High Level OverviewG/SG Morph consists of two modules,matrix_formandpyqubo_form, both of which contain three core functions,graph_isomorphism(),subgraph_isomorphism(), andtranslate_sample()that accomplish identical tasks but are implemented differently.matrix_formrelies on the usage of dictionaries to provide a matrix representing the QUBO, whilepyqubo_formuses thePyQUBOlibrary to express QUBOs. Note thatpyqubo_formhas been intentionally programmed to follow the math presented in Calude, Dineen, and Hua's paper as closely as possible (with minor adjustments made to satisfy Python syntax).Bothgraph_isomorphism()andsubgraph_isomorphism()take twoNetworkXgraphs (a "graph to embed" onto a  "target graph") and will generate a QUBO suitable for running on a simulated annealer such asD-Wave Nealor actual hardware.The above functions also return a dictionary that, in conjunction with a sample from an annelear, can be translated into a dictionary that maps nodes from the graph to embed to the target graph with the help oftranslate_sample().subgraph_isomorphism()also has an additionalinducedargument that can be set toTrueindicating that you would like to generate a QUBO for the Induced Subgraph Isomorphism problem.ExamplesPlease refer to the Jupyter Notebooks in theexamplesfolder.gsgmorph_matrix_form_demo.ipynbshows the usage of thematrix_formmodulegsgmorph_pyqubo_form_demo.ipynbshows the usage of thepyqubo_formmoduleBenchmarkingSome benchmarking was conducted against Richard Hua's graph isomorphism QUBO generator and G/SG Morph'smatrix_formimplementation using Erdos-Renyi graphs in Google Colab. The results and techniques can be found in theBenchmarkingfolder.ContributingIf you find a bug or have an idea to improve the library, please feel free to either make an Issue or a Pull Request with your suggested changes! If you are contributing code, please do note that this library attempts to follow thePEP-8 Style Guide for Python Codeas well as usingGoogle Style Python DocstringsCreditsAlthough all the QUBO formulations used come fromCalude, Dinneen, and Hua's "QUBO formulations for the graph isomorphism problem and related problems", this library would not have been possible without the following helpful sources:Wangfan Fu's answer to 'What is the square of summation?'on the Math Stackexchange siteDury and Matteo's code from their paper "A QUBO formulation for qubit allocation"https://arxiv.org/pdf/2009.00140.pdfserved as inspiration for the usage of the Pythonproduct()function.PyQUBO Documentation: Integration with D-Wave Oceanfor showing how to useD-Wave Nealwith PyQUBOSilentGhost's answer to "Reverse / invert a dictionary mapping"ars' answer to "Get difference between two lists"Mccreesh, Prosser, Solnon, and Trimble's paper "When Subgraph Isomorphism is Really Hard, and Why This Matters for Graph Databasesfor providing a graph to test the Induced Subgraph Isomorphism problem onDan D.'s answer to "what is diffrence between number and repeat in python timeit?"