1
0
Fork 0

Test that edge/vertex order is irrelevant

This commit is contained in:
Joris van Rantwijk 2023-02-14 21:08:15 +01:00
parent 71a7dfc9a3
commit 64851c98c5
1 changed files with 9 additions and 0 deletions

View File

@ -182,6 +182,15 @@ class TestMaximumWeightMatching(unittest.TestCase):
mwm([(0,1,7), (0,4,6), (1,2,9), (2,3,8), (3,4,9), (2,5,1), (4,5,1)]), mwm([(0,1,7), (0,4,6), (1,2,9), (2,3,8), (3,4,9), (2,5,1), (4,5,1)]),
[(1,2), (3,4)]) [(1,2), (3,4)])
def test45_flip_order(self):
"""test that order of edges and vertices is irrelevant"""
edges = [(0,1,2), (0,4,3), (1,2,7), (1,5,1), (2,3,9), (2,5,4), (3,4,8), (3,5,4)]
self.assertEqual(mwm(edges), [(1,2), (3,4)])
self.assertEqual(mwm(list(reversed(edges))), [(3,4), (1,2)])
self.assertEqual(mwm([(y, x, w) for (x, y, w) in edges]), [(2,1), (4,3)])
edges = [(0,2,4), (0,3,4), (0,4,1), (1,2,8), (1,5,3), (2,3,9), (3,4,7), (4,5,2)]
self.assertEqual(mwm(edges), [(1,2), (3,4)])
def test_fail_bad_input(self): def test_fail_bad_input(self):
"""bad input values""" """bad input values"""
with self.assertRaises(TypeError): with self.assertRaises(TypeError):