|  | @@ -1,14 +1,26 @@ | 
														
													
														
															
																|  |  | from clifford import * |  |  | from clifford import * | 
														
													
														
															
																|  |  | 
 |  |  | 
 | 
														
													
														
															
																|  |  | """ |  |  |  | 
														
													
														
															
																|  |  | Porting Anders and Briegel to Python |  |  |  | 
														
													
														
															
																|  |  | """ |  |  | """ | 
														
													
														
															
																|  |  |  |  |  | Porting Anders and Briegel to Python | 
														
													
														
															
																|  |  |  |  |  | """ | 
														
													
														
															
																|  |  |  |  |  | 
 | 
														
													
														
															
																|  |  |  |  |  | stab_rep = {None: "-", 0: "X", 1: "Y", 2: "Z"} | 
														
													
														
															
																|  |  |  |  |  | 
 | 
														
													
														
															
																|  |  |  |  |  | class Stabilizer(object): | 
														
													
														
															
																|  |  |  |  |  | 
 | 
														
													
														
															
																|  |  |  |  |  | def __init__(self, graph): | 
														
													
														
															
																|  |  |  |  |  | self.paulis = [[None for i in range(graph.nqubits)] | 
														
													
														
															
																|  |  |  |  |  | for j in range(graph.nqubits)] | 
														
													
														
															
																|  |  |  |  |  | 
 | 
														
													
														
															
																|  |  |  |  |  | def __str__(self): | 
														
													
														
															
																|  |  |  |  |  | return "\n".join(" ".join(stab_rep[x] for x in row) for row in self.paulis) | 
														
													
														
															
																|  |  |  |  |  | 
 | 
														
													
														
															
																|  |  | 
 |  |  | 
 | 
														
													
														
															
																|  |  | class Vertex(object): |  |  | class Vertex(object): | 
														
													
														
															
																|  |  | 
 |  |  | 
 | 
														
													
														
															
																|  |  | def __init__(self, index): |  |  | def __init__(self, index): | 
														
													
														
															
																|  |  | self.index = index |  |  | self.index = index | 
														
													
														
															
																|  |  | self.vertex_operator = lco_h; |  |  |  | 
														
													
														
															
																|  |  |  |  |  | self.vertex_operator = lco_h | 
														
													
														
															
																|  |  | self.neighbors = set() |  |  | self.neighbors = set() | 
														
													
														
															
																|  |  | 
 |  |  | 
 | 
														
													
														
															
																|  |  | def edgelist(self): |  |  | def edgelist(self): | 
														
													
												
													
														
															
																|  | @@ -21,6 +33,7 @@ class Vertex(object): | 
														
													
														
															
																|  |  | class GraphRegister(object): |  |  | class GraphRegister(object): | 
														
													
														
															
																|  |  | 
 |  |  | 
 | 
														
													
														
															
																|  |  | def __init__(self, n): |  |  | def __init__(self, n): | 
														
													
														
															
																|  |  |  |  |  | self.nqubits = n | 
														
													
														
															
																|  |  | self.vertices = [Vertex(i) for i in xrange(n)] |  |  | self.vertices = [Vertex(i) for i in xrange(n)] | 
														
													
														
															
																|  |  | 
 |  |  | 
 | 
														
													
														
															
																|  |  | def add_edge(self, v1, v2): |  |  | def add_edge(self, v1, v2): | 
														
													
												
													
														
															
																|  | @@ -38,12 +51,13 @@ class GraphRegister(object): | 
														
													
														
															
																|  |  | self.add_edge(v1, v2) |  |  | self.add_edge(v1, v2) | 
														
													
														
															
																|  |  | 
 |  |  | 
 | 
														
													
														
															
																|  |  | def edgelist(self): |  |  | def edgelist(self): | 
														
													
														
															
																|  |  | return map(tuple, frozenset(frozenset((v.index, n)) |  |  |  | 
														
													
														
															
																|  |  | for v in self.vertices |  |  |  | 
														
													
														
															
																|  |  | for n in v.neighbors)) |  |  |  | 
														
													
														
															
																|  |  |  |  |  | return map(tuple, frozenset(frozenset((v.index, n)) | 
														
													
														
															
																|  |  |  |  |  | for v in self.vertices | 
														
													
														
															
																|  |  |  |  |  | for n in v.neighbors)) | 
														
													
														
															
																|  |  | 
 |  |  | 
 | 
														
													
														
															
																|  |  | def __str__(self, ): |  |  | def __str__(self, ): | 
														
													
														
															
																|  |  | return "\n".join(str(v) for v in self.vertices if len(v.neighbors) > 0) |  |  |  | 
														
													
														
															
																|  |  |  |  |  | return "\n".join(str(v) for v in self.vertices | 
														
													
														
															
																|  |  |  |  |  | if len(v.neighbors) > 0) | 
														
													
														
															
																|  |  | 
 |  |  | 
 | 
														
													
														
															
																|  |  | if __name__ == '__main__': |  |  | if __name__ == '__main__': | 
														
													
														
															
																|  |  | g = GraphRegister(10) |  |  | g = GraphRegister(10) | 
														
													
												
													
														
															
																|  | 
 |