Пример #1
0
 def testClosestPairRight(self):
     P = [(1,1), (3,3), (11,5), (45,47), (4,6), (3,5), (65, 3), (33, 22), (3, 7), (3, 11), (4, 14), (4, 4), (4, 16), (4, 3.5)]
     Px = sorted(P, key=lambda tup: tup[0])
     Py = sorted(P, key=lambda tup: tup[1])
 
     pair = cp.closestPair(Px, Py)
     
     self.assertTrue((4,4) in pair)
     self.assertTrue((4, 3.5) in pair)
Пример #2
0
 def testDist(self):
     print ClosestPair.dist((1,1), (4,5))
     l = [(0,2),(6,67),(43,71),(39,107),(189,140)]
     print ClosestPair.closestPair(l)
     pass
Пример #3
0
 def testFindClosestPair(self):
     P = [(1,1), (3,3), (4,6), (3,5), (4, 3.5)]
     pair = cp.findClosestPair(P)
     
     self.assertTrue((3,3) in pair)
     self.assertTrue((4, 3.5) in pair)
Пример #4
0
 def testEclideanDistance(self):
     p = (3, 4)
     q = (5, 6)
     a = math.sqrt(8)
     d = cp.euclideanDistance(p, q)
     self.assertEqual(d, a)