Exemple #1
0
def main_test():
    file = utils.get_file_from_parameters()

    amount = int(file.readline())
    print "samples = ", amount

    time_results = []
    for i in range(amount):
        N = int(file.readline())
        points = np.fromfile(file = file, dtype = int, count = 2 * N, sep=" ").reshape(N, 2)
        vec_points = []
        for i in range(len(points)):
            p = points[i]
            vec_points.append(Vec2(long(p[0]), long(p[1])))


        start_time = time.time()
        disk, disk_points_indices = md.build_min_disk(vec_points)
        end_time = time.time()

        result = (N, end_time - start_time)
        time_results.append(result)
        print result

    print time_results
Exemple #2
0
def main():
    for attemp in range(1000):
        radius = 10
        n = 30
        points = gvs.generate_vertex_set(radius, n)

        disk, disk_points_indices = md.build_min_disk(points)
        print(disk_points_indices)
        print disk
        print

        plt.prepare_axis(radius)

        plt.draw_points(points, enumerate = True)
        plt.draw_disk((disk.center.x, disk.center.y, disk.radius))

        plt.draw()
from vector import Vec2
import fileinput
import min_disk as md


def get_points_array_from_stdin():
    N = input()
    points = []
    for i in range(N):
        array = map(int, raw_input().split())
        p = [array[0], array[1]]
        points.append(p)

    return points


if __name__ == "__main__":
    points = []

    samples_amount = input()
    for id in range(samples_amount):
        points = get_points_array_from_stdin()
        disk, indices = md.build_min_disk(points)
        print disk
        print indices