Exemplo n.º 1
0
 def test_hexagonal_lattice_2_2_factory(self):
     coupling = CouplingMap.from_hexagonal_lattice(2, 2, bidirectional=False)
     edges = coupling.get_edges()
     expected = [
         (0, 1),
         (1, 2),
         (2, 3),
         (3, 4),
         (5, 6),
         (6, 7),
         (7, 8),
         (8, 9),
         (9, 10),
         (11, 12),
         (12, 13),
         (13, 14),
         (14, 15),
         (0, 5),
         (2, 7),
         (4, 9),
         (6, 11),
         (8, 13),
         (10, 15),
     ]
     self.assertEqual(set(edges), set(expected))
Exemplo n.º 2
0
class TestVF2LayoutLattice(LayoutTestCase):
    """Fit in 25x25 hexagonal lattice coupling map"""

    cmap25 = CouplingMap.from_hexagonal_lattice(25, 25, bidirectional=False)

    def graph_state_from_pygraph(self, graph):
        """Creates a GraphState circuit from a PyGraph"""
        adjacency_matrix = retworkx.adjacency_matrix(graph)
        return GraphState(adjacency_matrix).decompose()

    def test_hexagonal_lattice_graph_20_in_25(self):
        """A 20x20 interaction map in 25x25 coupling map"""
        graph_20_20 = retworkx.generators.hexagonal_lattice_graph(20, 20)
        circuit = self.graph_state_from_pygraph(graph_20_20)

        dag = circuit_to_dag(circuit)
        pass_ = VF2Layout(self.cmap25, seed=self.seed, max_trials=1)
        pass_.run(dag)
        self.assertLayout(dag, self.cmap25, pass_.property_set)

    def test_hexagonal_lattice_graph_9_in_25(self):
        """A 9x9 interaction map in 25x25 coupling map"""
        graph_9_9 = retworkx.generators.hexagonal_lattice_graph(9, 9)
        circuit = self.graph_state_from_pygraph(graph_9_9)

        dag = circuit_to_dag(circuit)
        pass_ = VF2Layout(self.cmap25, seed=self.seed, max_trials=1)
        pass_.run(dag)
        self.assertLayout(dag, self.cmap25, pass_.property_set)