Exemplo n.º 1
0
 def test_mst_prim_missing_node(self):
     with self.assertRaises(NodeNotFound):
         list(mst_prim(self.graph, 999))
Exemplo n.º 2
0
 def test_mst_prim_tree(self):
     self.assertEqual(list(mst_prim(self.graph, 1)),
                      [(1, 2, 3), (2, 8, 8), (8, 6, 5),
                       (8, 7, 6), (6, 3, 7), (6, 5, 9),
                       (3, 4, 15)])
Exemplo n.º 3
0
 def test_mst_prim_digraph(self):
     with self.assertRaises(NotUndirectedGraph):
         list(mst_prim(self.digraph, 1))
Exemplo n.º 4
0
 def test_mst_prim_sum(self):
     for i in range(1, 9):
         self.assertEqual(
             sum([weight for u, v, weight in mst_prim(self.graph, i)]),
             53)