예제 #1
0
 def test_found_free_y(self):
     matrix = [[7, 4, 3], [3, 1, 2], [3, 0, 0]]
     h = Hungarian(matrix)
     h._init_labels()
     h.matching = {}
     h.inverse_matching = {}
     t = h._find_augmenting_path({0: None}, {0}, set())
     self.assertEqual(t, (0, 0, {0: None}))
예제 #2
0
 def test_neighbourhood_s_equals_t(self):
     matrix = [[7, 4, 3], [3, 1, 2], [3, 0, 0]]
     h = Hungarian(matrix)
     h._init_labels()
     h.matching = {0: 0}
     h.inverse_matching = {0: 0}
     h._update_labels = MagicMock()
     copy_find_augmenting_path = h._find_augmenting_path
     h._find_augmenting_path = MagicMock()
     copy_find_augmenting_path({1: None, 0: 1}, {1, 0}, {0})
     h._update_labels.assert_called_once_with({1, 0}, {0})
예제 #3
0
    def test_found_matched_y(self):
        matrix = [[7, 4, 3], [3, 1, 2], [3, 0, 0]]
        h = Hungarian(matrix)
        h._init_labels()
        h.matching = {0: 0}
        h.inverse_matching = {0: 0}

        copy_find_augmenting_path = h._find_augmenting_path
        h._find_augmenting_path = MagicMock()
        copy_find_augmenting_path({1: None}, {1}, set())

        h._find_augmenting_path.assert_called_once_with({
            1: None,
            0: 1
        }, {1, 0}, {0})