@@ -29,7 +29,7 @@ def compose_u(decomposition): | |||||
def name_of(vop): | def name_of(vop): | ||||
""" Get the formatted name of a VOP """ | """ Get the formatted name of a VOP """ | ||||
return get_name[vop].title() if vop in get_name else "VOP%d" % vop | |||||
return "%s" % get_name[vop] if vop in get_name else "VOP%d" % vop | |||||
@cache_to_disk("tables.pkl") | @cache_to_disk("tables.pkl") | ||||
@@ -9,12 +9,10 @@ import clifford | |||||
def remove_vop(g, vops, a, avoid): | def remove_vop(g, vops, a, avoid): | ||||
""" Reduces VOP[a] to the identity, avoiding (if possible) the use of vertex b as a swapping partner """ | """ Reduces VOP[a] to the identity, avoiding (if possible) the use of vertex b as a swapping partner """ | ||||
other_neighbours = g[a] - {avoid} | |||||
c = avoid if len(other_neighbours) == 0 else other_neighbours.pop() | |||||
d = clifford.decompositions[vops[a]] | |||||
for v in reversed(d): | |||||
target = a if v == "x" else c | |||||
local_complementation(g, vops, target) | |||||
others = g[a] - {avoid} | |||||
swap_qubit = others.pop() if others else avoid | |||||
for v in reversed(clifford.decompositions[vops[a]]): | |||||
local_complementation(g, vops, a if v == "x" else swap_qubit) | |||||
def local_complementation(g, vops, v): | def local_complementation(g, vops, v): | ||||
@@ -38,4 +36,5 @@ if __name__ == '__main__': | |||||
pos = viz.draw(g, vops, "out.pdf") | pos = viz.draw(g, vops, "out.pdf") | ||||
remove_vop(g, vops, 0, 1) | remove_vop(g, vops, 0, 1) | ||||
remove_vop(g, vops, 1, 2) | |||||
viz.draw(g, vops, "out2.pdf", pos) | viz.draw(g, vops, "out2.pdf", pos) |
@@ -19,11 +19,11 @@ def draw(graph, vops, filename="out.pdf", pos=None, ns=500): | |||||
nx.draw_networkx_nodes(g, pos, node_color="white", node_size=ns) | nx.draw_networkx_nodes(g, pos, node_color="white", node_size=ns) | ||||
nx.draw_networkx_nodes(g, pos, node_color=colors, node_size=ns, alpha=.4) | nx.draw_networkx_nodes(g, pos, node_color=colors, node_size=ns, alpha=.4) | ||||
nx.draw_networkx_edges(g, pos, edge_color="gray") | nx.draw_networkx_edges(g, pos, edge_color="gray") | ||||
nx.draw_networkx_labels(g, pos) | |||||
nx.draw_networkx_labels(g, pos, font_family="FreeSans") | |||||
labels = {i: clifford.name_of(vops[i]) for i in g.nodes()} | labels = {i: clifford.name_of(vops[i]) for i in g.nodes()} | ||||
pos = {k: v + np.array([0, -.1]) for k, v in pos.items()} | pos = {k: v + np.array([0, -.1]) for k, v in pos.items()} | ||||
nx.draw_networkx_labels(g, pos, labels) | |||||
nx.draw_networkx_labels(g, pos, labels, font_family="FreeSans") | |||||
plt.axis('off') | plt.axis('off') | ||||
plt.savefig(filename) | plt.savefig(filename) | ||||
return pos | return pos | ||||