Exemplo n.º 1
0
 def test_max_path_negative_edge(self):
     self.digraph.add_edge(1, 1000, w=-1)
     with self.assertRaises(NegativeEdgeWeight):
         max_path(self.digraph, weight_attribute='w')
     self.digraph.remove_edge(1, 1000)
Exemplo n.º 2
0
 def test_max_path_graph(self):
     with self.assertRaises(NotDAG):
         max_path(self.graph)
Exemplo n.º 3
0
 def test_max_path_digraph_with_cycle(self):
     self.digraph.add_edge(10, 8, w=4)
     with self.assertRaises(NotDAG):
         max_path(self.digraph)
     self.digraph.remove_edge(10, 8)
Exemplo n.º 4
0
 def test_max_path(self):
     pred, distance = max_path(self.digraph, weight_attribute='w')
     self.assertEqual(59, max(distance.values()))
     self.assertEqual(pred,
                      {3: 2, 4: 3, 5: 3, 6: 4,
                       7: 5, 8: 6, 9: 8, 10: 8})