88 tree ,
99 graph ,
1010 heap )
11- from pygorithm .data_structures .graph import WeightedGraph
1211
1312
1413class TestStack (unittest .TestCase ):
@@ -42,15 +41,15 @@ def test_infix_to_postfix(self):
4241 self .assertTrue (resultString , expectedResult )
4342
4443
45- class KruskalTest (unittest .TestCase ):
44+ class TestKruskal (unittest .TestCase ):
4645 def test_minimum_spanning_tree (self ):
4746 """
4847 test inspired from the example at the following link: https://en.wikipedia.org/wiki/Kruskal%27s_algorithm
4948 """
5049 edges_weighted = [((1 , 2 ), 7 ), ((2 , 3 ), 8 ), ((1 , 4 ), 5 ), ((2 , 4 ), 9 ),
5150 ((2 , 5 ), 7 ), ((3 , 5 ), 5 ), ((4 , 6 ), 6 ), ((5 , 6 ), 8 ),
5251 ((5 , 7 ), 9 ), ((6 , 7 ), 11 ), ((4 , 5 ), 15 )]
53- wgraph = WeightedGraph ()
52+ wgraph = graph . WeightedGraph ()
5453 for (u , v ), weight in edges_weighted :
5554 wgraph .add_edge (u , v , weight )
5655 expected = [((1 , 4 ), 5 ), ((3 , 5 ), 5 ), ((4 , 6 ), 6 ), ((1 , 2 ), 7 ), ((2 , 5 ), 7 ), ((5 , 7 ), 9 )]
@@ -61,7 +60,7 @@ def test_minimum_spanning_tree_2(self):
6160 Test inspired by the gif at the left of the page https://en.wikipedia.org/wiki/Kruskal%27s_algorithm
6261 """
6362 edges_weighted = [((1 , 2 ), 3 ), ((1 , 5 ), 1 ), ((2 , 5 ), 4 ), ((2 , 3 ), 5 ), ((3 , 5 ), 6 ), ((3 , 4 ), 2 ), ((4 , 5 ), 7 )]
64- wgraph = WeightedGraph ()
63+ wgraph = graph . WeightedGraph ()
6564 for (u , v ), weight in edges_weighted :
6665 wgraph .add_edge (u , v , weight )
6766 expected = [((1 , 5 ), 1 ), ((3 , 4 ), 2 ), ((1 , 2 ), 3 ), ((2 , 3 ), 5 )]
0 commit comments