Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand Generators Module #150

Open
mtreinish opened this issue Sep 30, 2020 · 6 comments
Open

Expand Generators Module #150

mtreinish opened this issue Sep 30, 2020 · 6 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@mtreinish
Copy link
Member

mtreinish commented Sep 30, 2020

What is the expected enhancement?

In #121 we added a new module for graph generators which will create graphs of with a certain layout easily. #121 only added a few different types of graphs with the intention of adding more in the future. We should add more generators to the graph to offer more options for quickly creating graphs. Networkx has a long list of generators that can be used for inspiration on different types of generators to add:

https://networkx.github.io/documentation/stable/reference/generators.html

Also, specifically for a qiskit use case we should make sure that we have generators to cover qiskit.transpiler.CouplingMap.from_line, qiskit.transpiler.CouplingMap.from_ring, qiskit.transpiler.CouplingMap.from_grid, and qiskit.transpiler.CouplingMap.from_full (this was handled by #191)

@mtreinish mtreinish added good first issue Good for newcomers enhancement New feature or request labels Sep 30, 2020
mtreinish pushed a commit that referenced this issue Nov 13, 2020
Adds both directed and undirected versions of Mesh and Grid graph generators.

Related to #150 

* Added Mesh and Grid graph generator

* Updated grid_graph generator for 1D weights list

* Lint refactoring

* Minor refactoring

* Added Graphviz examples for mesh and grid generators

* Minor refactors

Fixes Rust Lint error where <0 check was implemented on a usize variable
@mtreinish
Copy link
Member Author

Some generators that would be useful to do as part of this would be to add generators for some layouts that are used for error correction codes like heavy hex and heavy square. (see: https://journals.aps.org/prx/abstract/10.1103/PhysRevX.10.011022 ).

@nahumsa
Copy link
Contributor

nahumsa commented Mar 9, 2021

I will work on the heavy hex generator.

mtreinish pushed a commit that referenced this issue May 14, 2021
Related to #150.

Added new functions for the generator module:

    undirected hexagonal lattice graph;
    Directed hexagonal lattice graph;

* Added hexagonal graph without weights as input

* Added more hexagonal tests

* removed the weight argument

* Added itertools to dependencies

* Added complete_graph

* Add release notes complete_graph, hexagonal_graph

* Added complete graph

* Removed MANIFEST

* Linting

* Linting

* Removed complete graph

* Removed complete graph test

* Fixed typo on documentation.

Co-authored-by: georgios-ts <45130028+georgios-ts@users.noreply.github.com>

* Removed option for row and cols

Co-authored-by: georgios-ts <45130028+georgios-ts@users.noreply.github.com>

* Removed if statement

Removed if statement ` i + 1 < rowlen` because it would yield wrong results as pointed out by @georgios-ts

* Expanded test coverage

Added coverage for creating an empty hexagonal graph

* Add documentation for the deleted nodes

* fix docs typo

* change name to `hexagonal_lattice_graph`

* add `directed_hexagonal_lattice_graph`

* lint

* lint

* Fix test name

* typo on docs

* fix typo docs

* add edge_list assertion and bidirectional cases

* run black fmt

Co-authored-by: georgios-ts <45130028+georgios-ts@users.noreply.github.com>
mtreinish added a commit that referenced this issue May 21, 2021
Related to #150

* Add binomial tree graph

Add binomial tree graph for a given order.

* update documentation

* add release notes

* lint

* lint

* lint

* fix docs

* remove option for order

* change order to u32

This is done because that for `pow`method  a u32 is needed.

* clippy

* add directed binomial tree graph

* lint

* fix positional argument

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>

* updated test

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>

* updated tests

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>

* add case mismatch weights

* add edgelist assertion

* lint

* add find_edge before adding edge

`find_edge`makes sure that you don't add repeated edges on the graph

* add bidirectional tests

* clippy

* lint

* lint

* run black

* fix merge leftover

* fix lint

* add newline release notes

* add `.is_none()` assertion

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>

* `order` required arg

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>

* `order` required arg

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>

* Use `.is_none()` instead of `== None` everywhere

* Run cargo fmt

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
mtreinish added a commit that referenced this issue Aug 23, 2021
Added implementation of heavy hex [1], the input is the code distance, d. In the implementation I chose to add nodes referring to each type of qubit used in the Heavy Hex Code (data, syndrome, and flag) which may cause the node order to be confusing, but that was the best way that I figure out how to implement. Now I will explain the way that I implemented the code, which could be better for people without experience with the heavy hex code.

In the heavy hex code, there are d ** 2 data qubits, (d + 1) * (d - 1) / 2 syndrome qubits, and d * (d - 1) flag qubits. In order to implement I follow 3 steps:

 * Each flag qubit is conneceted with 2 data qubits forming a chain on the graph, the chain has size d.
 * Connect syndrome qubits that are connected to data qubits.
 * Connect flag and syndrome qubits.

In steps (ii) and (iii), there are two patterns depending on the eve (odd) columns of syndrome qubits, which are treated accordingly using an if statement. It was also required to use .chunk() for Vectors in order to represent them in a column.

Related to #150

[1] https://journals.aps.org/prx/abstract/10.1103/PhysRevX.10.011022

* Added heavy hex

Added firs implementation for heavy hex, it only implements 1 1 heavy hex and has some hardcoded parts that will be worked on.

* Added to docs

* lint

* lint

* add heavy hex generator

* lint

* add release notes

* add test edge assertion

* fix merge

* add doc references

* upgrade legibilitty

* fix doc identation

* add code-block for ASCII

* add ascii block

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>

* add `directed_heavy_hex_graph`

* updated release notes

* Fix edge directions

* Fix docstring typos

Co-authored-by: Eric Peterson <peterson.eric.c@gmail.com>

* Updates tests with direction fixes

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
Co-authored-by: Eric Peterson <peterson.eric.c@gmail.com>
mtreinish added a commit that referenced this issue Aug 23, 2021
* add heavy square graph to generators

Added implementation of [heavy square](https://journals.aps.org/prx/abstract/10.1103/PhysRevX.10.011022), the input is the code distance, d. In the implementation I chose to add nodes referring to each type of qubit used in the Heavy Hex Code (data, syndrome, and flag) which _may cause the node order to be confusing_, but that was the best way that I figure out how to implement.

Related to #150

* add release notes

* add heavy square edge assertion

* add reference on the docs

* fmt

* updated text_signature

* fmt

* fix doc identation

* Add code block for ASCII

* lint

* add note about the four-frequency variant

* add `directed_heavy_square_code`

* Fix edge directions

* Update edge directions in tests

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
@mtreinish
Copy link
Member Author

There has been a lot of good work here since this was initially opened and we've added a bunch of new generators. But, when you compare the number of generators in networkx: https://networkx.org/documentation/stable/reference/generators.html to list in networkx: https://qiskit.org/documentation/retworkx/api.html#generators there is still a large functionality gap.

I think before we can close this issue we need to close this gap much more. Each generator function is a really good starting PR that's self contained and a good project for getting your feet wet with the library.

@e-eight
Copy link
Contributor

e-eight commented Sep 25, 2021

Added a generator for undirected lollipop graphs in PR #454. Not sure if there should also be a directed version. Networkx does not seem to have any.

@e-eight
Copy link
Contributor

e-eight commented Oct 13, 2021

I am going add a generator for the barbell graph too, since it is just an extension of the lollipop graph. If anyone is already working on it, please let me know.

@k-tamuraphys
Copy link

I am working on lattice module, qiskit-community/qiskit-nature#365 , in which retworkx is used. I hope I can generate translational invariant graphs (lattice) with uniform weights on edges using retworkx. Standard examples of such are hypercubic (hyperrectangle, triangular, hexagonal lattices.
Furthermore, is such a graph has edges several directions like a square (or grid graph) and a triangular lattice , it is desirable to be able to assign uniform weights to each direction. For example, I may want to generate a square lattice with a weight of 1.0 in the horizontal direction and a weight of 2.0 in the vertical direction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants