︠4671c85c-d778-427b-8096-b5e7eec13e19︠ def rcd(g, ancilla): # Maybe some Check Up here if g is of correct format # Creating Graph G = Graph(g, boundary = ancilla) # Required Matrix and Vector Space, p-list and Field F = GF(2) p = G.vertices() MS = MatrixSpace(F, G.order()) V = VectorSpace(F, G.order()) for x in G.get_boundary(): p.remove(x) # Creating subspace SemiSubSpace = V.basis_matrix().matrix_from_rows(p).row_space() SubSpace = SemiSubSpace.direct_sum(SemiSubSpace) # Creating Generator Matrix and Stabilizer Space adj = MS(G.adjacency_matrix()) Mgenerator = block_matrix([MS.identity_matrix(), adj], ncols = 2) Stabilizer = Mgenerator.row_space() # Projection onto spanned subspace TraceOut = Stabilizer.intersection(SubSpace) return TraceOut ︡138a2c76-df1b-4909-82c8-39bd59a705eb︡︡ ︠a8519c62-1e0b-4dfe-a3f2-3a1d552163c7︠ @interact def _(graph = input_box(default = {0:[1], 1:[2], 2:[3], 3:[4], 5:[0]}, label = 'Insert Graph here:',type = dict), ancilla = input_box(default = [0], label = 'Ancilla Vertices', type = list)): p = rcd(graph, ancilla) Graph(graph).plot print p ︡bc4c05a4-9f78-4395-9a65-0e9e60322275︡{"html": "
\n
\n\n
Insert Graph here: 
Ancilla Vertices 
\n \n \n \n
\n "}︡