8
8
tree ,
9
9
graph ,
10
10
heap )
11
- from pygorithm .data_structures .graph import WeightedGraph
12
11
13
12
14
13
class TestStack (unittest .TestCase ):
@@ -42,15 +41,15 @@ def test_infix_to_postfix(self):
42
41
self .assertTrue (resultString , expectedResult )
43
42
44
43
45
- class KruskalTest (unittest .TestCase ):
44
+ class TestKruskal (unittest .TestCase ):
46
45
def test_minimum_spanning_tree (self ):
47
46
"""
48
47
test inspired from the example at the following link: https://en.wikipedia.org/wiki/Kruskal%27s_algorithm
49
48
"""
50
49
edges_weighted = [((1 , 2 ), 7 ), ((2 , 3 ), 8 ), ((1 , 4 ), 5 ), ((2 , 4 ), 9 ),
51
50
((2 , 5 ), 7 ), ((3 , 5 ), 5 ), ((4 , 6 ), 6 ), ((5 , 6 ), 8 ),
52
51
((5 , 7 ), 9 ), ((6 , 7 ), 11 ), ((4 , 5 ), 15 )]
53
- wgraph = WeightedGraph ()
52
+ wgraph = graph . WeightedGraph ()
54
53
for (u , v ), weight in edges_weighted :
55
54
wgraph .add_edge (u , v , weight )
56
55
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):
61
60
Test inspired by the gif at the left of the page https://en.wikipedia.org/wiki/Kruskal%27s_algorithm
62
61
"""
63
62
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 ()
65
64
for (u , v ), weight in edges_weighted :
66
65
wgraph .add_edge (u , v , weight )
67
66
expected = [((1 , 5 ), 1 ), ((3 , 4 ), 2 ), ((1 , 2 ), 3 ), ((2 , 3 ), 5 )]
0 commit comments