This implementation of a mapper for arbitrary graphs relies on storing the gates in a directed acyclic graph and then generating the swap operations in order to maximise the number of 2-qubit gates that can be applied simultaneously, while ensuring a minimal number of swaps.
Example of a use-case:
import networkx as nx
from projectq.cengines import GraphMapper
# Example of a 3x3 grid graph
mygraph = nx.Graph()
# Add horizontal edges
mygraph.add_edges_from((0, 1), (1, 2), (3, 4), (4, 5), (6, 7), (7, 8))
# Add vertical edges
mygraph.add_edges_from((0, 3), (3, 6), (1, 4), (4, 7), (2, 5), (5, 8))
mapper = GraphMapper(graph=mygraph)
# use as any other mapper
This supersedes #324.
This implementation of a mapper for arbitrary graphs relies on storing the gates in a directed acyclic graph and then generating the swap operations in order to maximise the number of 2-qubit gates that can be applied simultaneously, while ensuring a minimal number of swaps.
Example of a use-case: