Say we have our route finding algorithm:
def myHeuristicTSP(graph):
/*implementation*/
return route
Now we want to unit test this:
class TestMyHeuristicTSP:
def testNullGraphRaiseValueError(self):
self.assertRaises(ValueError, myHueristicTSP(None))
def testSimpleTwoNodeGraphReturnsRoute:
self.assertEquals(expectedResult, myHeuristicTSP(input))
The question is, for a non-heuristic TSP algorithm, we can give a variety of graphs and check that they always return absolutely the shortest route.
But because a heurtistic algorithm, while is still deterministic, is less predictable, are simply meant to understand how the algorithm is meant to be working, and find those edge cases?
Best Answer
For a heuristic algorithm which is supposed to not return the ideal but a "good enough" solution, you would have various test-cases and check