def test_1d_3_on_c16(self): embedding = find_grid_embedding([3], 16) self.assertEqual(len(embedding), 3) target_adj = target_to_source(dnx.chimera_graph(16), embedding) G = nx.path_graph(3) for u in G.adj: for v in G.adj[u]: self.assertIn(u, target_adj) self.assertIn(v, target_adj[u]) for u in target_adj: for v in target_adj[u]: self.assertIn(u, G.adj) self.assertIn(v, G.adj[u])
def test_3d_4x4x4_on_c16(self): dims = [4, 4, 4] chimera = (16, ) embedding = find_grid_embedding(dims, *chimera) self.assertEqual(len(embedding), self.prod(dims)) target_adj = target_to_source(dnx.chimera_graph(*chimera), embedding) G = nx.grid_graph(dims) for u in G.adj: for v in G.adj[u]: self.assertIn(u, target_adj) self.assertIn(v, target_adj[u], "{} is not adjacent to {}".format(v, u)) self.assertEqual(set(G.nodes), set(target_adj))
def test_3d_2x2x2_on_c2(self): embedding = find_grid_embedding([2, 2, 2], 2, 2, t=4) # should be 4 grids self.assertEqual(len(embedding), 2 * 2 * 2) target_adj = target_to_source(dnx.chimera_graph(2), embedding) G = nx.grid_graph(dim=[2, 2, 2]) for u in G.adj: for v in G.adj[u]: self.assertIn(u, target_adj) self.assertIn(v, target_adj[u]) for u in target_adj: for v in target_adj[u]: self.assertIn(u, G.adj) self.assertIn(v, G.adj[u])
def test_2d_6x4_on_c6(self): dims = [3, 2] chimera = (3, ) embedding = find_grid_embedding(dims, *chimera) self.assertEqual(len(embedding), self.prod(dims)) target_adj = target_to_source(dnx.chimera_graph(*chimera), embedding) G = nx.grid_graph(list(reversed(dims))) for u in G.adj: for v in G.adj[u]: self.assertIn(u, target_adj) self.assertIn(v, target_adj[u], "{} is not adjacent to {}".format(v, u)) for u in target_adj: for v in target_adj[u]: self.assertIn(u, G.adj) self.assertIn(v, G.adj[u], "{} is not adjacent to {}".format(v, u))
def test_3d_6x3x4_on_c4(self): dims = [6, 3, 4] chimera = (4, ) with self.assertRaises(ValueError): find_grid_embedding(dims, *chimera)