ProjectQ-Framework / ProjectQ

ProjectQ: An open source software framework for quantum computing
https://projectq.ch
Apache License 2.0
876 stars 271 forks source link

Implementation of a general graph mapper for ProjectQ #324

Closed Takishima closed 4 years ago

Takishima commented 5 years ago

This PR lays the ground work for an arbitrary graph mapper in ProjectQ.

Its use is similar to other ProjectQ mappers and has one required argument: a connected graph (nx.Graph). Here is an example:

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

Some implementation details:

The current implementation does not:

Takishima commented 4 years ago

Superseded by #340