# 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 time
import networkx as nx
import numpy as np
 #
 # QTop
 #
 # Copyright (c) 2016 Jacob Marks (jacob.marks@yale.edu)
 #
 # This file is part of QTop.
 #
 # QTop is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation, either version 3 of the License, or
 # (at your option) any later version.

sys.path.append('../')
# sys.path.append('../../')

################ GCC ###################

def center(cluster):
	X = round(np.mean([x for (x,y) in cluster]),3)
	Y = round(np.mean([y for (x,y) in cluster]),3)
	return (X,Y)

def closest_to_point(nodes,pt):

# 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/gcc.py
from decoders import *
from matplotlib import path
from math import floor
from src import common
import sys
import time
import networkx as nx
import numpy as np

 #
 # QTop
 #
 # Copyright (c) 2016 Jacob Marks (jacob.marks@yale.edu)
 #
 # This file is part of QTop.
 #
 # QTop is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation, either version 3 of the License, or
 # (at your option) any later version.

sys.path.append('../')
# sys.path.append('../../')

################ GCC ###################

def center(cluster):
	X = round(np.mean([x for (x,y) in cluster]),3)
	Y = round(np.mean([y for (x,y) in cluster]),3)
	return (X,Y)

def closest_to_point(nodes,pt):

	return min(nodes, key = lambda x:common.euclidean_dist(pt, x))