Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Leverage retworkx generators for all cmap constructors
In Qiskit#5183 we switched the internal graph datastructures used for the CouplingMap to be based on retworkx instead of networkx. That PR was written against the 0.6.0 retworkx release and for the from_grid() and from_full() constructors python had to be used since retworkx was missing functions to generate graphs of those types. However, in the recent 0.7.x retworkx release 2 new generators directed_grid_graph() [1] and directed_mesh_graph() [2] were added. This commit switches the implementation of from_grid() and from_full() to use these generators, which significantly speeds up (and reduces the memory overhead) of the constructor methods. The only constructor which still relies on a Python loop is the from_full() method when bidirection=False. This is because retworkx doesn't offer a constructor that will build a graph like that. If in a future release a generator is added we can remove that for loop too. [1] https://retworkx.readthedocs.io/en/stable/stubs/retworkx.generators.directed_grid_graph.html [2] https://retworkx.readthedocs.io/en/stable/stubs/retworkx.generators.directed_mesh_graph.html
- Loading branch information