def test_shortest_path(self): g = graph.UniGraph(10) for i in range(10): g.add( (i, (i+1)%10), ) # A loop self.assertTrue(g.has_edge(i, (i+1)%10)) self.assertTrue(g.has_edge((i+1)%10, i)) self.assertEquals(3, graph.shortest_path(g, 0, 3)) self.assertEquals(2, graph.shortest_path(g, 0, 8))
def test_shortest_path_no_route(self): g = graph.UniGraph(5) self.assertEquals(-1, graph.shortest_path(g, 0, 1))