def test_furthest_node(self): Content = namedtuple('Content', ['name']) n1 = Node(Content('n1')) n2 = Node(Content('n2')) n3 = Node(Content('n3')) n4 = Node(Content('n4')) n1.add_neighbors(n2) n2.add_neighbors(n3) n2.add_neighbors(n4) _, d = find_furthest_node(n1, [n1, n2, n3, n4]) self.assertEqual(d, 2) _, d = find_furthest_node(n2, [n1, n2, n3, n4]) self.assertEqual(d, 1)
def test_from_n1(self): furthest, distance = find_furthest_node(self.n1, self.nodes) self.assertTrue(furthest == self.n4 or furthest == self.n5) self.assertEqual(distance, 2)
def test_from_n5(self): furthest, distance = find_furthest_node(self.n5, self.nodes) self.assertTrue(furthest == self.n2) self.assertEqual(distance, 3)
def test_from_n4(self): furthest, distance = find_furthest_node(self.n4, self.nodes) self.assertTrue(furthest == self.n5 or self.n1 == furthest) self.assertEqual(distance, 2)