# Path: src/common.py
# def removekey(d, key):
# def colinear(p0, p1, p2):
# def manhattan_dist(A,B):
# def euclidean_dist(A,B):
# def Charge(X_charge = 0, Z_charge = 0):
# def Sign(count, num_sides):
#     def __init__(self, depth, dimension = 2):
#     def Syndrome(self, type, charge_type):
#     def PhysicalErrors(self):
#     def distance(self, type, node1, node2):
#     def Assessment(self):
# class Code:


from decoders import *
from matplotlib import path
from math import floor
from src import common
import sys
import networkx as nx
import numpy as np

    for node in cluster:
        if UnclusteredGraph.degree(node[0]) > degree and 'external' not in node[1]:
            center = node
            degree = UnclusteredGraph.degree(center[0])

    return center


def Fuse(code, UnclusteredGraph, cluster, dim, type, charge_type):
    # use syndrome transport to move excitations around lattice
    center = CentralNode(UnclusteredGraph, cluster)
    for mate in cluster:
        if mate != center:
            Transport(code, center, mate, dim, type, charge_type)

def Transport(code, fixed_node, mobile_node, dim, type, charge_type):

    chain = nx.shortest_path(code.Dual[type], mobile_node[0], fixed_node[0])
    chain_length = len(chain) - 1
    first_link = chain[0]

    charge = code.Stabilizers[type][first_link]['charge'][charge_type]

    for link in range(chain_length):
        previous, next = chain[link], chain[link + 1]
        for shared in code.Stabilizers[type][previous]['data']:
            if shared in code.Stabilizers[type][next]['data']:
                num_sides = code.Stabilizers[type][next]['sides']
                count = code.Stabilizers[type][previous]['data'][shared]

# Path: src/common.py
# def removekey(d, key):
# def colinear(p0, p1, p2):
# def manhattan_dist(A,B):
# def euclidean_dist(A,B):
# def Charge(X_charge = 0, Z_charge = 0):
# def Sign(count, num_sides):
#     def __init__(self, depth, dimension = 2):
#     def Syndrome(self, type, charge_type):
#     def PhysicalErrors(self):
#     def distance(self, type, node1, node2):
#     def Assessment(self):
# class Code:


# Path: src/decoders/rg.py
from decoders import *
from matplotlib import path
from math import floor
from src import common
import sys
import networkx as nx
import numpy as np


    for node in cluster:
        if UnclusteredGraph.degree(node[0]) > degree and 'external' not in node[1]:
            center = node
            degree = UnclusteredGraph.degree(center[0])

    return center


def Fuse(code, UnclusteredGraph, cluster, dim, type, charge_type):
    # use syndrome transport to move excitations around lattice
    center = CentralNode(UnclusteredGraph, cluster)
    for mate in cluster:
        if mate != center:
            Transport(code, center, mate, dim, type, charge_type)

def Transport(code, fixed_node, mobile_node, dim, type, charge_type):

    chain = nx.shortest_path(code.Dual[type], mobile_node[0], fixed_node[0])
    chain_length = len(chain) - 1
    first_link = chain[0]

    charge = code.Stabilizers[type][first_link]['charge'][charge_type]

    for link in range(chain_length):
        previous, next = chain[link], chain[link + 1]
        for shared in code.Stabilizers[type][previous]['data']:
            if shared in code.Stabilizers[type][next]['data']:
                num_sides = code.Stabilizers[type][next]['sides']
                count = code.Stabilizers[type][previous]['data'][shared]

                sign = common.Sign(count, num_sides)