コード例 #1
0
 def testConstructNearestNeighbourMatrix(self):
     """
     Construct the nearest neighbour matrix from a distance matrix
     """
     distanceMatrix = [[0,13,21,22],[13,0,12,13],[21,12,0,13],[22,13,13,0]]
     nearestNeighbour = constructNearestNeighbourMatrix(distanceMatrix)
     self.assertEqual(nearestNeighbour,
                      [[0,-68,-60,-60],[-68,0,-60,-60],[-60,-60,0,-68],[-60,-60,-68,0]])
コード例 #2
0
 def testConstructNearestNeighbourMatrix(self):
     """
     Construct the nearest neighbour matrix from a distance matrix
     """
     distanceMatrix = [[0, 13, 21, 22], [13, 0, 12, 13], [21, 12, 0, 13],
                       [22, 13, 13, 0]]
     nearestNeighbour = constructNearestNeighbourMatrix(distanceMatrix)
     self.assertEqual(nearestNeighbour,
                      [[0, -68, -60, -60], [-68, 0, -60, -60],
                       [-60, -60, 0, -68], [-60, -60, -68, 0]])
コード例 #3
0
 def testFindNearestNeighbourMatrix(self):
     distanceMatrix = [[0, 13, 16, 10], [13, 0, 21, 15], [16, 21, 0, 18],
                       [10, 15, 18, 0]]
     nearestNeighbour = constructNearestNeighbourMatrix(distanceMatrix)
     print nearestNeighbour
コード例 #4
0
 def testFindNearestNeighbourMatrix(self):
     distanceMatrix = [[0,13,16,10],[13,0,21,15],[16,21,0,18],[10,15,18,0]]
     nearestNeighbour = constructNearestNeighbourMatrix(distanceMatrix)
     print nearestNeighbour