def InternalRecovery(code, terminal1, terminal2, type, charge_type):
measure_chain = nx.shortest_path(code.Dual[type], terminal1, terminal2)
chain_length = nx.shortest_path_length(code.Dual[type], terminal1, terminal2)
for link in range(chain_length):
vertex1 = measure_chain[link]
vertex2 = measure_chain[link + 1]
for data_qubit in code.Stabilizers[type][vertex1]['data']:
if data_qubit in code.Stabilizers[type][vertex2]['data']:
prior_charge = code.Primal.node[data_qubit]['charge'][charge_type]
code.Primal.node[data_qubit]['charge'][charge_type] = (prior_charge + 1) % 2
return code
评论列表
文章目录