def test_get_shared_edges(backend): a = tn.Node(np.ones((2, 2, 2)), backend=backend) b = tn.Node(np.ones((2, 2, 2)), backend=backend) c = tn.Node(np.ones((2, 2, 2)), backend=backend) e1 = tn.connect(a[0], b[0]) e2 = tn.connect(b[1], c[1]) e3 = tn.connect(a[2], b[2]) assert tn.get_shared_edges(a, b) == {e1, e3} assert tn.get_shared_edges(b, c) == {e2}
def right_edges(self, j): """ Args: i(int): Index of the node. Returns: list: list of right edges of the i'th node. """ jn = (j + 1) % self.n_qubits return list(tn.get_shared_edges(self.nodes[j], self.nodes[jn]))
def left_edges(self, i): """ Args: i(int): Index of the node. Returns: list: list of left edges of the i'th node. """ ip = (i + self.n_qubits - 1) % self.n_qubits return list(tn.get_shared_edges(self.nodes[i], self.nodes[ip]))