def test_works_with_find_path(self): """ (0,0) (1,0) (2,0) """ graph = SquareTileGraph(3,1) path = find_path(graph, (0,0), (2,0)) self.assertEqual(path, [ (1,0), (2,0) ])
def test_simple_path(self): """ 0 1 """ graph = { 0 : [1], 1 : [0], } solution = find_path(graph, 0, 1) self.assertEqual(solution, [1])
def test_no_path(self): """ 0 1|2 3 """ graph = { 0 : [1], 1 : [0], 2 : [3], 3 : [2], } solution = find_path(graph, 0, 3) self.assertEqual(solution, None)
def test_longer_path(self): """ 0 1 2 """ graph = { 0 : [1], 1 : [0,2], 2 : [], } solution = find_path(graph, 0, 2) self.assertEqual(solution, [1,2])
def test_shortest_path(self): """ 0 1 2 3 4 5 6 7 """ graph = { 0 : [1,4], 1 : [0,5,2], 2 : [1,6,3], 3 : [2,7], 4 : [0,5], 5 : [4,1,6], 6 : [5,2,7], 7 : [3,6], } solution = find_path(graph, 0, 3) self.assertEqual([1, 2, 3], solution)