Esempio n. 1
0
def plot_running_times():
    slow_measures = []
    #slow_measures.append(time.clock())
    last_time = time.clock()
    for size_cluster in range(2, 200):
        alg_project3_solution.slow_closest_pair(
            gen_random_clusters(size_cluster))
        slow_measures.append(time.clock() - last_time)
        last_time = time.clock()

    fast_measures = []
    #fast_measures.append(time.clock())
    last_time = time.clock()
    for size_cluster in range(2, 200):
        alg_project3_solution.fast_closest_pair(
            gen_random_clusters(size_cluster))
        fast_measures.append(time.clock() - last_time)
        last_time = time.clock()

    xlabel("number of points in cluster")
    ylabel("running time")
    #xscale('log')
    #yscale('log')
    plot(range(2, 200), fast_measures, '-b', label="fast_closest_pair")
    plot(range(2, 200), slow_measures, '-r', label="slow_closest_pair")
    legend(loc="upper left")
    show()
Esempio n. 2
0
def plot_running_times():
    slow_measures = []
    #slow_measures.append(time.clock())
    last_time = time.clock()
    for size_cluster in range(2,200):        
        alg_project3_solution.slow_closest_pair(gen_random_clusters(size_cluster))
        slow_measures.append(time.clock() - last_time)
        last_time = time.clock()
            
    fast_measures = []
    #fast_measures.append(time.clock())  
    last_time = time.clock()  
    for size_cluster in range(2,200):        
        alg_project3_solution.fast_closest_pair(gen_random_clusters(size_cluster))
        fast_measures.append(time.clock() - last_time)
        last_time = time.clock()
        
    xlabel("number of points in cluster")
    ylabel("running time")
    #xscale('log')
    #yscale('log')
    plot(range(2,200), fast_measures, '-b', label="fast_closest_pair")
    plot(range(2,200), slow_measures, '-r', label="slow_closest_pair")
    legend(loc="upper left")
    show()
Esempio n. 3
0
def question1_plot():
    xvals = []
    slow_cp_yvals = []
    fast_cp_yvals = []
    for num_clusters in range(2,200+1):
        xvals.append(num_clusters)
        grc = gen_random_clusters(num_clusters)

        start = time.clock()
        alg_project3_solution.slow_closest_pair(grc)
        elapsed = (time.clock() - start)
        slow_cp_yvals.append(elapsed)

        start = time.clock()
        alg_project3_solution.fast_closest_pair(grc)
        elapsed = (time.clock() - start)
        fast_cp_yvals.append(elapsed)

    plt.plot(xvals, slow_cp_yvals, '-b', label='slow_closest_pair')
    plt.plot(xvals, fast_cp_yvals, '-r', label='fast_closest_pair')
    plt.legend(loc='upper right')
    plt.xlabel('number of initial clusters ')
    plt.ylabel('running time')
    plt.title('desktop Python')
    plt.grid(True)
    plt.show()
 def test02(self):
     (distance,idx1,idx2) = fast_closest_pair([Cluster(set([]), 0, 0, 1, 0), Cluster(set([]), 0, 3, 1, 0), 
                                               Cluster(set([]), 1, 2, 1, 0), Cluster(set([]), 2, 2, 1, 0), 
                                               Cluster(set([]), 3, 0, 1, 0), Cluster(set([]), 3, 3, 1, 0)])
     self.assertAlmostEqual(distance,1)
     self.assertEqual(idx1, 2)
     self.assertEqual(idx2, 3)
 def test_one_pair(self):
     # flip, x, y, population, risk
     s = map(lambda x: Cluster(*x), [(5, 0, 0, 13, 0.1),
                                     (10, 42, 0, 14, 0.2)])
     r1 = list(slow_closest_pairs(s))[0]
     r2 = fast_closest_pair(s)
     self.assertEqual(r1, r2)
     self.assertEqual(r2, (42.0, 0, 1))
 def test03(self):
     (distance,idx1,idx2) = fast_closest_pair([Cluster(set(['06111']), 93.4973310868, 344.590570899, 753197, 5.8e-05), 
                                               Cluster(set(['06019']), 95.6093812211, 290.162708843, 799407, 6.4e-05), 
                                               Cluster(set(['06039']), 97.2145136451, 278.975077449, 123109, 6e-05)]
                                              )
     self.assertAlmostEqual(distance,11.3021921018)
     self.assertEqual(idx1, 1)
     self.assertEqual(idx2, 2)
 def test04(self):
     (distance,idx1,idx2) = fast_closest_pair([Cluster(set([]), -4.0, 0.0, 1, 0), 
                                               Cluster(set([]), 0.0, -1.0, 1, 0), 
                                               Cluster(set([]), 0.0, 1.0, 1, 0), 
                                               Cluster(set([]), 4.0, 0.0, 1, 0)]
                                              )
     self.assertAlmostEqual(distance,2.0)
     self.assertEqual(idx1, 1)
     self.assertEqual(idx2, 2)
 def test_one_pair(self):
     # flip, x, y, population, risk
     s = map(lambda x: Cluster(*x),
             [(5, 0, 0, 13, 0.1),
              (10, 42, 0, 14, 0.2)])
     r1 = list(slow_closest_pairs(s))[0]
     r2 = fast_closest_pair(s)
     self.assertEqual(r1, r2)
     self.assertEqual(r2, (42.0, 0, 1))
 def test_special(self):
     s = [Cluster(set([1, 2, 3, 4]), 0.0, 0.0, 55, 0.176363636364),
          Cluster(set([10, 11]), 10.0, 10.0, 28, 0.2),
          Cluster(set([12]), 10, 10, 14, 0.2),
          Cluster(set([13]), 10, 10, 14, 0.2)
          ]
     # print(s)
     d, i, j = fast_closest_pair(s)
     # print(d, i, j)
     # print(s[i], s[j])
     self.assertNotEqual((i, j), (0, 1))
Esempio n. 10
0
 def test_special(self):
     s = [
         Cluster(set([1, 2, 3, 4]), 0.0, 0.0, 55, 0.176363636364),
         Cluster(set([10, 11]), 10.0, 10.0, 28, 0.2),
         Cluster(set([12]), 10, 10, 14, 0.2),
         Cluster(set([13]), 10, 10, 14, 0.2)
     ]
     # print(s)
     d, i, j = fast_closest_pair(s)
     # print(d, i, j)
     # print(s[i], s[j])
     self.assertNotEqual((i, j), (0, 1))
Esempio n. 11
0
def timed_run():

    slow_times = []
    fast_times = []

    for i in range(2, 201):
        cluster_list = gen_random_clusters(i)

        start_time = time.time()
        process_cluster.slow_closest_pair(cluster_list)
        end_time = time.time()
        ellapsed_time = end_time - start_time
        slow_times.append(ellapsed_time)

        start_time = time.time()
        process_cluster.fast_closest_pair(cluster_list)
        end_time = time.time()
        ellapsed_time = end_time - start_time
        fast_times.append(ellapsed_time)

    return slow_times, fast_times
Esempio n. 12
0
def plot_running_time():
    slow_runnint_time = []
    fast_running_time = []
    x_axis = range(2, 201)
    for num_clusters in x_axis:
        cluster_list = gen_random_clusters(num_clusters)
        cluster_list.sort(key=lambda cluster: cluster.horiz_center())
        start = time.clock()
        student.slow_closest_pair(cluster_list)
        end_slow = time.clock()
        student.fast_closest_pair(cluster_list)
        end_fast = time.clock()
        slow_runnint_time.append(end_slow - start)
        fast_running_time.append(end_fast - end_slow)

    plt.plot(x_axis, slow_runnint_time, label="slow")
    plt.plot(x_axis, fast_running_time, label="fast")
    plt.legend()
    plt.ylabel('Running time')
    plt.xlabel('Number of clusters')
    plt.title("Closest Pair Algorithms Comparison")
    plt.show()
 def test_three_vert_pairs(self):
     s = map(lambda x: Cluster(*x),
             [(5,  0, 0, 13, 0.1),
              (10, 0, 2, 14, 0.2),
              (15, 0, 4, 15, 0.2),
              (20, 0, 5, 16, 0.2),
              (25, 0, 7, 17, 0.2),
              (30, 0, 9, 18, 0.2),
              ])
     r1 = list(slow_closest_pairs(s))[0]
     r2 = fast_closest_pair(s)
     self.assertEqual(r1, r2)
     self.assertEqual(r1, (1.0, 2, 3))
Esempio n. 14
0
 def test_three_vert_pairs(self):
     s = map(lambda x: Cluster(*x), [
         (5, 0, 0, 13, 0.1),
         (10, 0, 2, 14, 0.2),
         (15, 0, 4, 15, 0.2),
         (20, 0, 5, 16, 0.2),
         (25, 0, 7, 17, 0.2),
         (30, 0, 9, 18, 0.2),
     ])
     r1 = list(slow_closest_pairs(s))[0]
     r2 = fast_closest_pair(s)
     self.assertEqual(r1, r2)
     self.assertEqual(r1, (1.0, 2, 3))
def plot_running_times():
    """
    Use gen_random_clusters and your favorite Python timing code to compute the running times of the
    functions slow_closest_pair and fast_closest_pair for lists of clusters of size 2 to 200.
    """

    x_vals = []
    y_1_vals = []
    y_2_vals = []

    for num_clusters in range(2, 200, 1):
        cluster_list = gen_random_clusters(num_clusters)
        x_vals.append(num_clusters)

        # measure process time (= CPU time consumed) of "slow_closest_pair"
        t0 = time.clock()
        p.slow_closest_pair(cluster_list)
        y_1_vals.append(time.clock() - t0)

        # measure process time (= CPU time consumed) of "fast_closest_pair"
        t0 = time.clock()
        p.fast_closest_pair(cluster_list)
        y_2_vals.append(time.clock() - t0)

    plt.plot(x_vals, y_1_vals, label="slow_closest_pair")
    plt.plot(x_vals, y_2_vals, label="fast_closest_pair")

    plt.xlabel("Input size (number of clusters)")
    plt.ylabel('CPU running time (sec.)')

    #tegner
    plt.legend()

    plt.title("Comparison of running times (desktop Python)")

    #goer det hele synligt
    plt.show()
Esempio n. 16
0
def question1(filename):
    xs = range(2, 201)
    ys_fast, ys_slow = [], []
    for n in xs:
        clusters = get_random_clusters(n)
        ys_fast.append(timeit(lambda: fast_closest_pair(clusters), number=1))
        ys_slow.append(timeit(lambda: slow_closest_pair(clusters), number=1))

    plt.plot(xs, ys_fast, '-r', label='fast_closest_pair')
    plt.plot(xs, ys_slow, '-b', label='slow_closest_pair')
    plt.title('Running time of two closest_pair functions (desktop Python)')
    plt.xlabel('Number of initial clusters')
    plt.ylabel('Running time, seconds')
    plt.legend(loc='upper left')
    plt.tight_layout()
    plt.savefig(filename)
    print('Saved plot to %s', filename)
def question1(filename):
    xs = range(2, 201)
    ys_fast, ys_slow = [], []
    for n in xs:
        clusters = get_random_clusters(n)
        ys_fast.append(timeit(lambda: fast_closest_pair(clusters), number=1))
        ys_slow.append(timeit(lambda: slow_closest_pairs(clusters), number=1))

    plt.plot(xs, ys_fast, '-r', label='fast_closest_pair')
    plt.plot(xs, ys_slow, '-b', label='slow_closest_pairs')
    plt.title('Running time of *closest_pair functions (desktop Python)')
    plt.xlabel('Number of initial clusters')
    plt.ylabel('Running time, seconds')
    plt.legend(loc='upper left')
    plt.tight_layout()
    plt.savefig(filename)
    print('Saved plot to %s' % filename)
#####################################
# Code for answering question 1 of the application

# Measure the running times for the functions slow_closest_pair and fast_closest_pair
num_clusters = []
running_times_slow = []
running_times_fast = []
for index in range(2,201):
    cluster_list = gen_random_clusters(index)
    num_clusters.append(index)
    start_time = time.time()
    distance = sol.slow_closest_pair(cluster_list)
    end_time = time.time()
    running_times_slow.append(end_time - start_time)
    start_time = time.time()
    distance = sol.fast_closest_pair(cluster_list)
    end_time = time.time()
    running_times_fast.append(end_time - start_time)
    if index % 10 == 0:
        print "=====> Covered clusterlist up to", index
    
# Create plot of the result
plt.plot(num_clusters, running_times_slow, '-b', label='slow_closest_pair')
plt.plot(num_clusters, running_times_fast, '-r', label='fast_closest_pair')
plt.legend(loc='upper left')
plt.grid(True)
plt.title("Plot 9: running times of slow_closest_pair and fast_closest_pair")
plt.xlabel("number of clusters processed")
plt.ylabel("runnning time (sec.)")
plt.show()
Esempio n. 19
0
def test_fcp():
    cluster_list = [alg_cluster.Cluster(set([]),0.32,0.16,1,0),alg_cluster.Cluster(set([]),0.39,0.4,1,0),alg_cluster.Cluster(set([]),0.54,0.8,1,0),alg_cluster.Cluster(set([]),0.61,0.8,1,0),alg_cluster.Cluster(set([]),0.76,0.94,1,0)]
    print alg_project3_solution.fast_closest_pair(cluster_list)
Esempio n. 20
0
    def test_owl1(self):
        s = [
            Cluster(set(['01101']), 720.281573781, 440.436162917, 223510,
                    5.7e-05),
            Cluster(set(['01117']), 709.193528999, 417.394467797, 143293,
                    5.6e-05),
            Cluster(set(['01073']), 704.191210749, 411.014665198, 662047,
                    7.3e-05),
            Cluster(set(['01015']), 723.907941153, 403.837487318, 112249,
                    5.6e-05),
            Cluster(set(['01113']), 740.385154867, 436.939588695, 49756,
                    5.6e-05),
            Cluster(set(['04013']), 214.128077618, 396.893960776, 3072149,
                    6.8e-05),
            Cluster(set(['06025']), 156.397958859, 393.161127277, 142361,
                    5.6e-05),
            Cluster(set(['06065']), 146.410389633, 374.21707964, 1545387,
                    6.1e-05),
            Cluster(set(['06073']), 129.2075529, 387.064888184, 2813833,
                    6.6e-05),
            Cluster(set(['06059']), 113.997715586, 368.503452566, 2846289,
                    9.8e-05),
            Cluster(set(['06037']), 105.369854549, 359.050126004, 9519338,
                    0.00011),
            Cluster(set(['06111']), 93.4973310868, 344.590570899, 753197,
                    5.8e-05),
            Cluster(set(['06083']), 76.0382837186, 340.420376302, 399347,
                    6.4e-05),
            Cluster(set(['06029']), 103.787886113, 326.006585349, 661645,
                    9.7e-05),
            Cluster(set(['06071']), 148.402461892, 350.061039619, 1709434,
                    7.7e-05),
            Cluster(set(['06107']), 108.085024898, 306.351832438, 368021,
                    5.8e-05),
            Cluster(set(['06039']), 97.2145136451, 278.975077449, 123109,
                    6e-05),
            Cluster(set(['06019']), 95.6093812211, 290.162708843, 799407,
                    6.4e-05),
            Cluster(set(['06081']), 52.6171444847, 262.707477827, 707161,
                    5.6e-05),
            Cluster(set(['06001']), 61.782098866, 259.312457296, 1443741,
                    7e-05),
            Cluster(set(['06085']), 63.1509653633, 270.516712105, 1682585,
                    6.3e-05),
            Cluster(set(['06067']), 74.3547338322, 245.49501455, 1223499,
                    6.1e-05),
            Cluster(set(['06075']), 52.7404001225, 254.517429395, 776733,
                    8.4e-05),
            Cluster(set(['06113']), 68.2602083189, 236.862609218, 168660,
                    5.9e-05),
            Cluster(set(['06101']), 74.2003718491, 229.646592975, 78930,
                    5.6e-05),
            Cluster(set(['06021']), 65.2043358182, 213.245337355, 26453,
                    6.9e-05),
            Cluster(set(['06089']), 77.359494209, 188.945068958, 163256,
                    5.7e-05),
            Cluster(set(['08005']), 380.281283151, 270.268826873, 487967,
                    5.9e-05),
            Cluster(set(['08001']), 379.950978294, 265.078784954, 363857,
                    6.6e-05),
            Cluster(set(['08031']), 371.038986573, 266.847932979, 554636,
                    7.9e-05),
            Cluster(set(['09003']), 925.917212741, 177.152290276, 857183,
                    5.7e-05),
            Cluster(set(['12073']), 762.463896365, 477.365342219, 239452,
                    6.1e-05),
            Cluster(set(['13313']), 737.308367745, 378.040993858, 83525,
                    5.6e-05),
            Cluster(set(['13215']), 745.265661102, 430.987078939, 186291,
                    5.9e-05),
            Cluster(set(['13067', '13121']), 748.913132176, 398.791948963,
                    1423757, 6.74388143482e-05),
            Cluster(set(['13063', '13151']), 754.106675876, 406.912690943,
                    355858, 6.2646387042e-05),
            Cluster(set(['13089', '13247']), 754.838224932, 400.291739409,
                    735976, 6.68568485929e-05),
            Cluster(set(['13135']), 758.038826857, 395.110327675, 588448,
                    6.3e-05),
            Cluster(set(['13245']), 796.799727342, 404.391349655, 199775,
                    5.9e-05),
            Cluster(set(['19163']), 621.490118929, 227.666851619, 158668,
                    5.6e-05),
            Cluster(set(['17031']), 668.978975824, 219.400257219, 5376741,
                    6.1e-05),
            Cluster(set(['21019']), 768.726553092, 290.270551648, 49752,
                    5.8e-05),
            Cluster(set(['21111']), 715.347723878, 301.167740487, 693604,
                    5.9e-05),
            Cluster(set(['22017']), 570.826412839, 442.202574191, 252161,
                    6.2e-05),
            Cluster(set(['22071']), 651.338581076, 496.465402252, 484674,
                    6.4e-05),
            Cluster(set(['25017']), 943.405755498, 156.504310828, 1465396,
                    5.6e-05),
            Cluster(set(['25025']), 950.299079197, 158.007070966, 689807,
                    7e-05),
            Cluster(set(['24510', '24005']), 872.39640107, 248.277002427,
                    1405446, 6.70230005279e-05),
            Cluster(set(['24027']), 867.127763298, 252.141340019, 247842,
                    6e-05),
            Cluster(set(['24031']), 863.180208628, 255.65657011, 873341,
                    6.5e-05),
            Cluster(set(['26163']), 746.37046732, 200.570021537, 2061162,
                    6.4e-05),
            Cluster(set(['26125']), 743.036942153, 192.129690868, 1194156,
                    5.7e-05),
            Cluster(set(['27123']), 576.516685202, 151.219277482, 511035,
                    5.6e-05),
            Cluster(set(['27053']), 570.131597541, 151.403325043, 1116200,
                    5.8e-05),
            Cluster(set(['29189', '29510']), 629.976164517, 297.473005985,
                    1364504, 6.22965861588e-05),
            Cluster(set(['28027']), 631.700027283, 400.68741948, 30622, 6e-05),
            Cluster(set(['28159']), 663.514261498, 425.274137823, 20160,
                    5.9e-05),
            Cluster(set(['28049']), 638.051593606, 445.785870317, 250800,
                    6e-05),
            Cluster(set(['37119']), 813.724315147, 356.853362811, 695454,
                    5.6e-05),
            Cluster(set(['31055']), 525.799353573, 238.14275337, 463585,
                    6.2e-05),
            Cluster(set(['31109']), 516.78216337, 250.188023316, 250291,
                    6.1e-05),
            Cluster(
                set([
                    '36005', '34013', '34017', '36061', '36081', '36047',
                    '36085', '34039'
                ]), 911.004570517, 207.361438421, 9933427, 0.000100484812543),
            Cluster(set(['34003', '34031']), 906.566100671, 202.092249843,
                    1373167, 6.68631193438e-05),
            Cluster(set(['34023']), 904.976453741, 215.001458637, 750162,
                    5.9e-05),
            Cluster(set(['34007']), 899.061431482, 232.054232622, 508932,
                    5.7e-05),
            Cluster(set(['36059']), 917.384980291, 205.43647538, 1334544,
                    7.6e-05),
            Cluster(set(['36103']), 929.241649488, 199.278463003, 1419369,
                    6.3e-05),
            Cluster(set(['36119']), 912.141547823, 196.592589736, 923459,
                    6.5e-05),
            Cluster(set(['39035']), 776.351457758, 216.558042612, 1393978,
                    5.8e-05),
            Cluster(set(['41005']), 103.421444616, 88.318590492, 338391,
                    6.6e-05),
            Cluster(set(['41051']), 103.293707198, 79.5194104381, 660486,
                    9.3e-05),
            Cluster(set(['41067']), 92.2254623376, 76.2593957841, 445342,
                    7.3e-05),
            Cluster(set(['42101']), 894.72914873, 227.900547575, 1517550,
                    5.8e-05),
            Cluster(set(['42003']), 809.003419092, 233.899638663, 1281666,
                    6.1e-05),
            Cluster(set(['47037']), 700.009323976, 350.107265446, 569891,
                    6.1e-05),
            Cluster(set(['47065']), 732.643747577, 370.017730905, 307896,
                    6.1e-05),
            Cluster(set(['47093']), 753.012743594, 348.235180569, 382032,
                    5.6e-05),
            Cluster(set(['48201']), 540.54731652, 504.62993865, 3400578,
                    6e-05),
            Cluster(set(['48245']), 565.746895809, 504.541799993, 252051,
                    5.7e-05),
            Cluster(set(['51520']), 784.05333332, 328.847863787, 17367,
                    5.6e-05),
            Cluster(set(['51610', '51059']), 863.075130421, 262.406379235,
                    980126, 5.71270489713e-05),
            Cluster(set(['51510', '11001', '51013', '24033']), 868.773385157,
                    261.367545904, 1691310, 7.01566407105e-05),
            Cluster(set(['51775', '51770']), 821.539811344, 307.579291084,
                    119658, 6.35522990523e-05),
            Cluster(set(['51680']), 835.264653899, 302.326633095, 65269,
                    5.8e-05),
            Cluster(set(['51820']), 837.346467474, 285.851438947, 19520,
                    5.8e-05),
            Cluster(set(['51570']), 868.048530719, 299.360459202, 16897,
                    5.6e-05),
            Cluster(set(['51840']), 845.843602685, 258.214178983, 23585,
                    7.1e-05),
            Cluster(set(['51087', '51760']), 865.974521771, 293.191364776,
                    460090, 7.28875654763e-05),
            Cluster(set(['53011']), 104.00046468, 74.0182527309, 345238,
                    6.4e-05),
            Cluster(set(['53033']), 125.27486023, 39.1497730391, 1737034,
                    5.8e-05),
            Cluster(set(['55079']), 664.855000617, 192.484141264, 940164,
                    7.4e-05),
            Cluster(set(['54009']), 799.221537984, 240.153315109, 25447,
                    7.7e-05)
        ]

        # with open('owl1.csv', 'w') as f:
        #     f.write('n,x,y\n')
        #     f.writelines('%d,%s,%s\n' % (i, x.horiz_center(), x.vert_center())
        #                  for i, x in enumerate(s))
        expected = 5.2005419351770561, 27, 28

        self.assertEqual(fast_closest_pair(s), expected)
 def test01(self):
     (distance,idx1,idx2) = fast_closest_pair([Cluster(set([]), 0, 0, 1, 0), Cluster(set([]), 1, 0, 1, 0), Cluster(set([]), 2, 0, 1, 0), Cluster(set([]), 3, 0, 1, 0)])
     
     self.assertAlmostEqual(distance, 1.0)
Esempio n. 22
0
end = 200
slow_closest_list = []
fast_closest_list = []
for item in range(start,end):
    # create cluster list
    cluster_list = gen_random_clusters(item)
    
    # run hierarchy
    tStart = time.time()
    alg_project3_solution.slow_closest_pair(cluster_list)
    tStop = time.time()
    slow_closest_list.append(tStop - tStart)
    
    # run kmeans
    tStart = time.time()
    alg_project3_solution.fast_closest_pair(cluster_list)
    tStop = time.time()
    fast_closest_list.append(tStop - tStart)
    
    
# plot
def legend_example():
    xvals= [i for i in range(start,end)]
    yvals1 = slow_closest_list
    yvals2 = fast_closest_list
    
    fig = plt.figure()
    ax = fig.add_subplot(111)
    ax.set_title('Efficiency')
    ax.set_xlabel('number of clusters')
    ax.set_ylabel('running time(sec)')
Esempio n. 23
0
    def test_closest_pair_functions(self):

        cluster1 = p.c.Cluster(set(["DK"]), 1, 2, 100, 0.01)
        cluster2 = p.c.Cluster(set(["SW"]), 4, 6, 200, 0.05)
        cluster3 = p.c.Cluster(set(["Brasil"]), 4, 2, 100000000,
                               3)  #cluster1.merge_clusters(cluster2)
        cluster4 = p.c.Cluster(set(["NL"]), 5, 6, 4, 4)
        cluster5 = p.c.Cluster(set(["NL"]), 5, 3, 100, 0.01)

        self.assertEqual(p.slow_closest_pair([]), (float("inf"), -1, -1))
        self.assertEqual(p.slow_closest_pair([]), p.fast_closest_pair([]))

        self.assertEqual(p.slow_closest_pair([cluster1]),
                         (float("inf"), -1, -1))
        self.assertEqual(p.slow_closest_pair([cluster1]),
                         p.fast_closest_pair([cluster1]))

        self.assertEqual(p.slow_closest_pair([cluster1, cluster1]),
                         (0.0, 0, 1))
        self.assertEqual(p.slow_closest_pair([cluster1, cluster1]),
                         p.fast_closest_pair([cluster1, cluster1]))

        self.assertEqual(
            p.slow_closest_pair([cluster1, cluster2, cluster3, cluster4]),
            (1, 1, 3))
        self.assertEqual(
            p.slow_closest_pair([cluster1, cluster2, cluster3, cluster4]),
            p.fast_closest_pair([cluster1, cluster2, cluster3, cluster4]))

        self.assertEqual(p.slow_closest_pair([cluster1, cluster2, cluster3]),
                         (3, 0, 2))
        self.assertEqual(p.slow_closest_pair([cluster1, cluster2, cluster3]),
                         p.fast_closest_pair([cluster1, cluster2, cluster3]))

        self.assertEqual(
            p.slow_closest_pair(
                [cluster1, cluster2, cluster3, cluster4, cluster5]), (1, 1, 3))
        self.assertEqual(
            p.slow_closest_pair(
                [cluster1, cluster2, cluster3, cluster4, cluster5]),
            p.fast_closest_pair(
                [cluster1, cluster2, cluster3, cluster4, cluster5]))

        cluster0 = p.c.Cluster(set(["Al"]), 1.1, 10, 0, 0)
        cluster1 = p.c.Cluster(set(["DK"]), 1, 2, 100, 0.01)
        cluster2 = p.c.Cluster(set(["SW"]), 4, 6, 200, 0.05)
        cluster3 = p.c.Cluster(set(["Brasil"]), 4, 2, 100000000,
                               3)  #cluster1.merge_clusters(cluster2)
        cluster4 = p.c.Cluster(set(["NL"]), 5, 6, 4, 4)
        cluster5 = p.c.Cluster(set(["NL"]), 5, 6.1, 100, 0.01)
        cluster6 = p.c.Cluster(set(["hl"]), 6, 13, 0, 0)
        cluster7 = p.c.Cluster(set(["hl"]), 6.5, 15, 0, 0)
        cluster8 = p.c.Cluster(set(["hl"]), 8, 13, 0, 0)
        cluster_list = [
            cluster0, cluster1, cluster2, cluster3, cluster4, cluster5,
            cluster6, cluster7, cluster8
        ]

        self.assertEqual(p.slow_closest_pair(cluster_list),
                         p.fast_closest_pair(cluster_list))

        cluster0 = p.c.Cluster(set(["Al"]), 1.1, 10, 0, 0)
        cluster1 = p.c.Cluster(set(["DK"]), 1, 2, 100, 0.01)
        cluster2 = p.c.Cluster(set(["SW"]), 4, 6, 200, 0.05)
        cluster3 = p.c.Cluster(set(["Brasil"]), 4, 2, 100000000,
                               3)  #cluster1.merge_clusters(cluster2)
        cluster4 = p.c.Cluster(set(["NL"]), 5, 6, 4, 4)
        cluster5 = p.c.Cluster(set(["NL"]), 5, 6.1, 100, 0.01)
        cluster6 = p.c.Cluster(set(["hl"]), 6, 13, 0, 0)
        cluster7 = p.c.Cluster(set(["hl"]), 6.5, 15, 0, 0)
        cluster8 = p.c.Cluster(set(["hl"]), 8, 13, 0, 0)
        cluster_list = [
            cluster0, cluster1, cluster2, cluster3, cluster4, cluster5,
            cluster6, cluster7, cluster8
        ]
        #print p.slow_closest_pair(cluster_list)
        self.assertEqual(p.slow_closest_pair(cluster_list),
                         p.fast_closest_pair(cluster_list))

        cluster0 = p.c.Cluster(set(["Al"]), 1.1, 10, 0, 0)
        cluster1 = p.c.Cluster(set(["DK"]), 1, 2, 100, 0.01)
        cluster2 = p.c.Cluster(set(["SW"]), 4, 6, 200, 0.05)
        cluster3 = p.c.Cluster(set(["Brasil"]), 4, 2, 100000000,
                               3)  #cluster1.merge_clusters(cluster2)
        cluster4 = p.c.Cluster(set(["NL"]), 5, 50, 4, 4)
        cluster5 = p.c.Cluster(set(["NL"]), 5, 100, 100, 0.01)
        cluster6 = p.c.Cluster(set(["hl"]), 6, 13, 0, 0)
        cluster7 = p.c.Cluster(set(["hl"]), 6.5, 15, 0, 0)
        cluster8 = p.c.Cluster(set(["hl"]), 8, 13, 0, 0)
        cluster_list = [
            cluster0, cluster1, cluster2, cluster3, cluster4, cluster5,
            cluster6, cluster7, cluster8
        ]
        #print p.slow_closest_pair(cluster_list)
        self.assertEqual(p.slow_closest_pair(cluster_list),
                         p.fast_closest_pair(cluster_list))

        cluster0 = p.c.Cluster(set(["Al"]), 1.1, 10, 0, 0)
        cluster1 = p.c.Cluster(set(["DK"]), 1, 2, 100, 0.01)
        cluster2 = p.c.Cluster(set(["SW"]), 4, 6, 200, 0.05)
        cluster3 = p.c.Cluster(set(["Brasil"]), 4, 30, 100000000,
                               3)  #cluster1.merge_clusters(cluster2)
        cluster4 = p.c.Cluster(set(["NL"]), 5, 50, 4, 4)
        cluster5 = p.c.Cluster(set(["NL"]), 5, 100, 100, 0.01)
        cluster6 = p.c.Cluster(set(["hl"]), 6, 13, 0, 0)
        cluster7 = p.c.Cluster(set(["hl"]), 30, 15, 0, 0)
        cluster8 = p.c.Cluster(set(["hl"]), 40, 13, 0, 0)
        cluster_list = [
            cluster0, cluster1, cluster2, cluster3, cluster4, cluster5,
            cluster6, cluster7, cluster8
        ]
        #print p.slow_closest_pair(cluster_list)
        self.assertEqual(p.slow_closest_pair(cluster_list),
                         p.fast_closest_pair(cluster_list))

        cluster0 = p.c.Cluster(set(["Al"]), 0, 10, 0, 0)
        cluster1 = p.c.Cluster(set(["DK"]), 1, 2, 100, 0.01)
        cluster2 = p.c.Cluster(set(["SW"]), 4, 20, 200, 0.05)
        cluster3 = p.c.Cluster(set(["Brasil"]), 4, 30, 100000000,
                               3)  #cluster1.merge_clusters(cluster2)
        cluster4 = p.c.Cluster(set(["NL"]), 5, 50, 4, 4)
        cluster5 = p.c.Cluster(set(["NL"]), 5, 100, 100, 0.01)
        cluster6 = p.c.Cluster(set(["hl"]), 20, 13, 0, 0)
        cluster7 = p.c.Cluster(set(["hl"]), 30, 15, 0, 0)
        cluster8 = p.c.Cluster(set(["hl"]), 40, 13, 0, 0)
        cluster_list = [
            cluster0, cluster1, cluster2, cluster3, cluster4, cluster5,
            cluster6, cluster7, cluster8
        ]
        #print p.slow_closest_pair(cluster_list)
        self.assertEqual(p.slow_closest_pair(cluster_list),
                         p.fast_closest_pair(cluster_list))
    def test_owl1(self):
        s = [Cluster(set(['01101']), 720.281573781, 440.436162917, 223510, 5.7e-05),
             Cluster(set(['01117']), 709.193528999, 417.394467797, 143293, 5.6e-05),
             Cluster(set(['01073']), 704.191210749, 411.014665198, 662047, 7.3e-05),
             Cluster(set(['01015']), 723.907941153, 403.837487318, 112249, 5.6e-05),
             Cluster(set(['01113']), 740.385154867, 436.939588695, 49756, 5.6e-05),
             Cluster(set(['04013']), 214.128077618, 396.893960776, 3072149, 6.8e-05),
             Cluster(set(['06025']), 156.397958859, 393.161127277, 142361, 5.6e-05),
             Cluster(set(['06065']), 146.410389633, 374.21707964, 1545387, 6.1e-05),
             Cluster(set(['06073']), 129.2075529, 387.064888184, 2813833, 6.6e-05),
             Cluster(set(['06059']), 113.997715586, 368.503452566, 2846289, 9.8e-05),
             Cluster(set(['06037']), 105.369854549, 359.050126004, 9519338, 0.00011),
             Cluster(set(['06111']), 93.4973310868, 344.590570899, 753197, 5.8e-05),
             Cluster(set(['06083']), 76.0382837186, 340.420376302, 399347, 6.4e-05),
             Cluster(set(['06029']), 103.787886113, 326.006585349, 661645, 9.7e-05),
             Cluster(set(['06071']), 148.402461892, 350.061039619, 1709434, 7.7e-05),
             Cluster(set(['06107']), 108.085024898, 306.351832438, 368021, 5.8e-05),
             Cluster(set(['06039']), 97.2145136451, 278.975077449, 123109, 6e-05),
             Cluster(set(['06019']), 95.6093812211, 290.162708843, 799407, 6.4e-05),
             Cluster(set(['06081']), 52.6171444847, 262.707477827, 707161, 5.6e-05),
             Cluster(set(['06001']), 61.782098866, 259.312457296, 1443741, 7e-05),
             Cluster(set(['06085']), 63.1509653633, 270.516712105, 1682585, 6.3e-05),
             Cluster(set(['06067']), 74.3547338322, 245.49501455, 1223499, 6.1e-05),
             Cluster(set(['06075']), 52.7404001225, 254.517429395, 776733, 8.4e-05),
             Cluster(set(['06113']), 68.2602083189, 236.862609218, 168660, 5.9e-05),
             Cluster(set(['06101']), 74.2003718491, 229.646592975, 78930, 5.6e-05),
             Cluster(set(['06021']), 65.2043358182, 213.245337355, 26453, 6.9e-05),
             Cluster(set(['06089']), 77.359494209, 188.945068958, 163256, 5.7e-05),
             Cluster(set(['08005']), 380.281283151, 270.268826873, 487967, 5.9e-05),
             Cluster(set(['08001']), 379.950978294, 265.078784954, 363857, 6.6e-05),
             Cluster(set(['08031']), 371.038986573, 266.847932979, 554636, 7.9e-05),
             Cluster(set(['09003']), 925.917212741, 177.152290276, 857183, 5.7e-05),
             Cluster(set(['12073']), 762.463896365, 477.365342219, 239452, 6.1e-05),
             Cluster(set(['13313']), 737.308367745, 378.040993858, 83525, 5.6e-05),
             Cluster(set(['13215']), 745.265661102, 430.987078939, 186291, 5.9e-05),
             Cluster(set(['13067', '13121']), 748.913132176, 398.791948963, 1423757, 6.74388143482e-05),
             Cluster(set(['13063', '13151']), 754.106675876, 406.912690943, 355858, 6.2646387042e-05),
             Cluster(set(['13089', '13247']), 754.838224932, 400.291739409, 735976, 6.68568485929e-05),
             Cluster(set(['13135']), 758.038826857, 395.110327675, 588448, 6.3e-05),
             Cluster(set(['13245']), 796.799727342, 404.391349655, 199775, 5.9e-05),
             Cluster(set(['19163']), 621.490118929, 227.666851619, 158668, 5.6e-05),
             Cluster(set(['17031']), 668.978975824, 219.400257219, 5376741, 6.1e-05),
             Cluster(set(['21019']), 768.726553092, 290.270551648, 49752, 5.8e-05),
             Cluster(set(['21111']), 715.347723878, 301.167740487, 693604, 5.9e-05),
             Cluster(set(['22017']), 570.826412839, 442.202574191, 252161, 6.2e-05),
             Cluster(set(['22071']), 651.338581076, 496.465402252, 484674, 6.4e-05),
             Cluster(set(['25017']), 943.405755498, 156.504310828, 1465396, 5.6e-05),
             Cluster(set(['25025']), 950.299079197, 158.007070966, 689807, 7e-05),
             Cluster(set(['24510', '24005']), 872.39640107, 248.277002427, 1405446, 6.70230005279e-05),
             Cluster(set(['24027']), 867.127763298, 252.141340019, 247842, 6e-05),
             Cluster(set(['24031']), 863.180208628, 255.65657011, 873341, 6.5e-05),
             Cluster(set(['26163']), 746.37046732, 200.570021537, 2061162, 6.4e-05),
             Cluster(set(['26125']), 743.036942153, 192.129690868, 1194156, 5.7e-05),
             Cluster(set(['27123']), 576.516685202, 151.219277482, 511035, 5.6e-05),
             Cluster(set(['27053']), 570.131597541, 151.403325043, 1116200, 5.8e-05),
             Cluster(set(['29189', '29510']), 629.976164517, 297.473005985, 1364504, 6.22965861588e-05),
             Cluster(set(['28027']), 631.700027283, 400.68741948, 30622, 6e-05),
             Cluster(set(['28159']), 663.514261498, 425.274137823, 20160, 5.9e-05),
             Cluster(set(['28049']), 638.051593606, 445.785870317, 250800, 6e-05),
             Cluster(set(['37119']), 813.724315147, 356.853362811, 695454, 5.6e-05),
             Cluster(set(['31055']), 525.799353573, 238.14275337, 463585, 6.2e-05),
             Cluster(set(['31109']), 516.78216337, 250.188023316, 250291, 6.1e-05),
             Cluster(set(['36005', '34013', '34017', '36061', '36081', '36047', '36085', '34039']), 911.004570517, 207.361438421, 9933427, 0.000100484812543),
             Cluster(set(['34003', '34031']), 906.566100671, 202.092249843, 1373167, 6.68631193438e-05),
             Cluster(set(['34023']), 904.976453741, 215.001458637, 750162, 5.9e-05),
             Cluster(set(['34007']), 899.061431482, 232.054232622, 508932, 5.7e-05),
             Cluster(set(['36059']), 917.384980291, 205.43647538, 1334544, 7.6e-05),
             Cluster(set(['36103']), 929.241649488, 199.278463003, 1419369, 6.3e-05),
             Cluster(set(['36119']), 912.141547823, 196.592589736, 923459, 6.5e-05),
             Cluster(set(['39035']), 776.351457758, 216.558042612, 1393978, 5.8e-05),
             Cluster(set(['41005']), 103.421444616, 88.318590492, 338391, 6.6e-05),
             Cluster(set(['41051']), 103.293707198, 79.5194104381, 660486, 9.3e-05),
             Cluster(set(['41067']), 92.2254623376, 76.2593957841, 445342, 7.3e-05),
             Cluster(set(['42101']), 894.72914873, 227.900547575, 1517550, 5.8e-05),
             Cluster(set(['42003']), 809.003419092, 233.899638663, 1281666, 6.1e-05),
             Cluster(set(['47037']), 700.009323976, 350.107265446, 569891, 6.1e-05),
             Cluster(set(['47065']), 732.643747577, 370.017730905, 307896, 6.1e-05),
             Cluster(set(['47093']), 753.012743594, 348.235180569, 382032, 5.6e-05),
             Cluster(set(['48201']), 540.54731652, 504.62993865, 3400578, 6e-05),
             Cluster(set(['48245']), 565.746895809, 504.541799993, 252051, 5.7e-05),
             Cluster(set(['51520']), 784.05333332, 328.847863787, 17367, 5.6e-05),
             Cluster(set(['51610', '51059']), 863.075130421, 262.406379235, 980126, 5.71270489713e-05),
             Cluster(set(['51510', '11001', '51013', '24033']), 868.773385157, 261.367545904, 1691310, 7.01566407105e-05),
             Cluster(set(['51775', '51770']), 821.539811344, 307.579291084, 119658, 6.35522990523e-05),
             Cluster(set(['51680']), 835.264653899, 302.326633095, 65269, 5.8e-05),
             Cluster(set(['51820']), 837.346467474, 285.851438947, 19520, 5.8e-05),
             Cluster(set(['51570']), 868.048530719, 299.360459202, 16897, 5.6e-05),
             Cluster(set(['51840']), 845.843602685, 258.214178983, 23585, 7.1e-05),
             Cluster(set(['51087', '51760']), 865.974521771, 293.191364776, 460090, 7.28875654763e-05),
             Cluster(set(['53011']), 104.00046468, 74.0182527309, 345238, 6.4e-05),
             Cluster(set(['53033']), 125.27486023, 39.1497730391, 1737034, 5.8e-05),
             Cluster(set(['55079']), 664.855000617, 192.484141264, 940164, 7.4e-05),
             Cluster(set(['54009']), 799.221537984, 240.153315109, 25447, 7.7e-05)]

        # with open('owl1.csv', 'w') as f:
        #     f.write('n,x,y\n')
        #     f.writelines('%d,%s,%s\n' % (i, x.horiz_center(), x.vert_center())
        #                  for i, x in enumerate(s))
        expected = 5.2005419351770561, 27, 28

        self.assertEqual(fast_closest_pair(s), expected)
def run_suite():
    """
    Testing code for the functions written for Word Wrangler
    """
    
    # create a TestSuite (and an object)
    suite = poc_simpletest.TestSuite()

    # create a set of 3 clusters
    cluster1 = CC.Cluster([1, 1], 0, 0, 100, 0.00001)
    cluster2 = CC.Cluster([2, 2, 2], 3, 4, 200, 0.00002)
    cluster3 = CC.Cluster([3, 3, 3, 3], 6, 8, 300, 0.00003)
    list_of_clusters = [cluster1, cluster2, cluster3]
        
    # testing the slow_closest_pair function with the 3 cluster list
    suite.run_test(student.slow_closest_pair(list_of_clusters), (5., 0, 1),
                   "Test #1: testing slow_closest_pair on 3 clusters")
    # testing the fast_closest_pair function with the 3 cluster list    
    suite.run_test(student.fast_closest_pair(list_of_clusters), (5., 0, 1),
                   "Test #2: testing fast_closest_pair on 3 clusters")

    # add a fourth cluster to the list
    cluster4 = CC.Cluster([4, 4, 4, 4, 4], 12, 16, 400, 0.00004)
    list_of_clusters.append(cluster4)

    # testing the slow_closest_pair function with the 4 cluster list
    suite.run_test(student.slow_closest_pair(list_of_clusters), (5., 0, 1),
                   "Test #3: testing slow_closest_pair on 4 clusters")
    # testing the fast_closest_pair function with the 4 cluster list    
    suite.run_test(student.fast_closest_pair(list_of_clusters), (5., 0, 1),
                   "Test #4: testing fast_closest_pair on 4 clusters")

    # create a set of 4 clusters
    cluster1 = CC.Cluster(set([]), 0, 0, 1, 0)
    cluster2 = CC.Cluster(set([]), 1, 0, 1, 0)
    cluster3 = CC.Cluster(set([]), 2, 0, 1, 0)
    cluster4 = CC.Cluster(set([]), 3, 0, 1, 0)
    list_of_clusters = [cluster1, cluster2, cluster3, cluster4]
        
    # testing closest_pair_strip on 4 clusters
    suite.run_test(student.closest_pair_strip(list_of_clusters, 1.5, 1.0), (1.0, 1, 2),
                   "Test #5: testing closest_pair_strip on 4 clusters")

    # create a set of 4 clusters
    cluster1 = CC.Cluster(set([]), 1.0, 0.0, 1, 0)
    cluster2 = CC.Cluster(set([]), 4.0, 0.0, 1, 0)
    cluster3 = CC.Cluster(set([]), 5.0, 0.0, 1, 0)
    cluster4 = CC.Cluster(set([]), 7.0, 0.0, 1, 0)
    list_of_clusters = [cluster1, cluster2, cluster3, cluster4]
        
    # testing fast_closest_pair on 4 clusters
    suite.run_test(student.fast_closest_pair(list_of_clusters), (1.0, 1, 2),
                   "Test #6: testing closest_pair_strip on 4 clusters")

    # create a set of 4 clusters
    cluster1 = CC.Cluster(set([]), -4.0, 0.0, 1, 0)
    cluster2 = CC.Cluster(set([]), 0.0, -1.0, 1, 0)
    cluster3 = CC.Cluster(set([]), 0.0, 1.0, 1, 0)
    cluster4 = CC.Cluster(set([]), 4.0, 0.0, 1, 0)
    list_of_clusters = [cluster1, cluster2, cluster3, cluster4]
        
    # testing closest_pair_strip on 4 clusters
    suite.run_test(student.closest_pair_strip(list_of_clusters, 0.0, 4.1231059999999999), (2.0, 1, 2),
                   "Test #7: testing closest_pair_strip on 4 clusters")

    # create a set of 4 clusters
    cluster1 = CC.Cluster(set([]), -4.0, 0.0, 1, 0)
    cluster2 = CC.Cluster(set([]), 0.0, -1.0, 1, 0)
    cluster3 = CC.Cluster(set([]), 0.0, 1.0, 1, 0)
    cluster4 = CC.Cluster(set([]), 4.0, 0.0, 1, 0)
    list_of_clusters = [cluster1, cluster2, cluster3, cluster4]
        
    # testing fast_closest_pair on 4 clusters
    suite.run_test(student.fast_closest_pair(list_of_clusters), (2.0, 1, 2),
                   "Test #8: testing fast_closest_pair on 4 clusters")

    # create a sorted list_of_clusters from a small dataset containing 8 clusters
    fhandle = open("unifiedCancerData_8.txt")
    list_of_clusters = []
    for line in fhandle:
        tokens = line.split(',')
        cluster = CC.Cluster(set([tokens[0]]), float(tokens[1]), float(tokens[2]),
                             int(tokens[3]), float(tokens[4]))
        list_of_clusters.append(cluster)
    list_of_clusters.sort(key = lambda cluster: cluster.horiz_center())
    print "The following list_of_clusters was loaded:"
    for index in range(len(list_of_clusters)):
        print index, list_of_clusters[index]
    print

    # testing the slow_closest_pair function with 8 cluster list
    suite.run_test(student.slow_closest_pair(list_of_clusters), (2.4479655653349655, 5, 7),
                   "Test #9: testing slow_closest_pair on 8 clusters")
    # testing the fast_closest_pair function with 8 cluster list    
    suite.run_test(student.fast_closest_pair(list_of_clusters), (2.4479655653349655, 5, 7),
                   "Test #10: testing fast_closest_pair on 8 clusters")
    # testing the hierarchical_clustering function with 8 clusters
    clustering_result = student.hierarchical_clustering(list_of_clusters, 5)
    for index in range(len(clustering_result)):
        print clustering_result[index]
    print
    # testing the kmeans_clustering function with 8 clusters
    clustering_result = student.kmeans_clustering(list_of_clusters, 5, 3)
    for index in range(len(clustering_result)):
        print clustering_result[index]
    print

    # create a sorted list_of_clusters from a small dataset containing 17 clusters
    fhandle = open("unifiedCancerData_17.txt")
    list_of_clusters = []
    for line in fhandle:
        tokens = line.split(',')
        cluster = CC.Cluster(set([tokens[0]]), float(tokens[1]), float(tokens[2]),
                             int(tokens[3]), float(tokens[4]))
        list_of_clusters.append(cluster)
    list_of_clusters.sort(key = lambda cluster: cluster.horiz_center())
 
    # testing the slow_closest_pair function with 17 cluster list
    suite.run_test(student.slow_closest_pair(list_of_clusters), (1.9439662413427632, 9, 10),
                   "Test #11: testing slow_closest_pair on 17 clusters")
    # testing the fast_closest_pair function with 17 cluster list    
    suite.run_test(student.fast_closest_pair(list_of_clusters), (1.9439662413427632, 9, 10),
                   "Test #12: testing fast_closest_pair on 17 clusters")

    # create a sorted list_of_clusters from a small dataset containing 24 clusters
    fhandle = open("unifiedCancerData_24.txt")
    list_of_clusters = []
    for line in fhandle:
        tokens = line.split(',')
        cluster = CC.Cluster(set([tokens[0]]), float(tokens[1]), float(tokens[2]),
                             int(tokens[3]), float(tokens[4]))
        list_of_clusters.append(cluster)
    list_of_clusters.sort(key = lambda cluster: cluster.horiz_center())
    print "The following list_of_clusters was loaded:"
    for index in range(len(list_of_clusters)):
        print index, list_of_clusters[index]
    print

    # testing the kmeans_clustering function with 24 clusters
    clustering_result = student.kmeans_clustering(list_of_clusters, 10, 1)
    print "This output was created by kmeans_slustering:"
    for index in range(len(clustering_result)):
        print index, clustering_result[index]
    print

    # create a sorted list_of_clusters from a small dataset containing 39 clusters
    fhandle = open("unifiedCancerData_39.txt")
    list_of_clusters = []
    for line in fhandle:
        tokens = line.split(',')
        cluster = CC.Cluster(set([tokens[0]]), float(tokens[1]), float(tokens[2]),
                             int(tokens[3]), float(tokens[4]))
        list_of_clusters.append(cluster)
    list_of_clusters.sort(key = lambda cluster: cluster.horiz_center())
 
    # testing the slow_closest_pair function with 39 cluster list
    suite.run_test(student.slow_closest_pair(list_of_clusters), (1.6612217536988727, 22, 24),
                   "Test #13: testing slow_closest_pair on 39 clusters")
    # testing the fast_closest_pair function with 39 cluster list    
    suite.run_test(student.fast_closest_pair(list_of_clusters), (1.6612217536988727, 22, 24),
                   "Test #14: testing fast_closest_pair on 39 clusters")

    # create a sorted list_of_clusters from a small dataset containing 111 clusters
    fhandle = open("unifiedCancerData_111.csv")
    list_of_clusters = []
    for line in fhandle:
        tokens = line.split(',')
        cluster = CC.Cluster(set([tokens[0]]), float(tokens[1]), float(tokens[2]),
                             int(tokens[3]), float(tokens[4]))
        list_of_clusters.append(cluster)
    list_of_clusters.sort(key = lambda cluster: cluster.horiz_center())
    print "The following list_of_clusters was loaded:"
    for index in range(len(list_of_clusters)):
        print index, list_of_clusters[index]
    print
 
    # testing the slow_closest_pair function with 111 cluster list
    suite.run_test(student.slow_closest_pair(list_of_clusters), (1.266216002018164, 79, 81),
                   "Test #15: testing slow_closest_pair on 111 clusters")
    # testing the fast_closest_pair function with 111 cluster list    
    suite.run_test(student.fast_closest_pair(list_of_clusters), (1.266216002018164, 79, 81),
                   "Test #16: testing fast_closest_pair on 111 clusters")
    # testing the hierarchical_clustering function with 111 clusters
    clustering_result = student.hierarchical_clustering(list_of_clusters, 5)
    for index in range(len(clustering_result)):
        print clustering_result[index]
    print

    # report number of tests and failures
    print
    suite.report_results()