Skip to content

Commit

Permalink
Made some changes in tests for data structures
Browse files Browse the repository at this point in the history
  • Loading branch information
OmkarPathak committed Aug 16, 2017
1 parent 539ce39 commit dc6ed0c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions tests/test_data_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
tree,
graph,
heap)
from pygorithm.data_structures.graph import WeightedGraph


class TestStack(unittest.TestCase):
Expand Down Expand Up @@ -42,15 +41,15 @@ def test_infix_to_postfix(self):
self.assertTrue(resultString, expectedResult)


class KruskalTest(unittest.TestCase):
class TestKruskal(unittest.TestCase):
def test_minimum_spanning_tree(self):
"""
test inspired from the example at the following link: https://en.wikipedia.org/wiki/Kruskal%27s_algorithm
"""
edges_weighted = [((1, 2), 7), ((2, 3), 8), ((1, 4), 5), ((2, 4), 9),
((2, 5), 7), ((3, 5), 5), ((4, 6), 6), ((5, 6), 8),
((5, 7), 9), ((6, 7), 11), ((4, 5), 15)]
wgraph = WeightedGraph()
wgraph = graph.WeightedGraph()
for (u, v), weight in edges_weighted:
wgraph.add_edge(u, v, weight)
expected = [((1, 4), 5), ((3, 5), 5), ((4, 6), 6), ((1, 2), 7), ((2, 5), 7), ((5, 7), 9)]
Expand All @@ -61,7 +60,7 @@ def test_minimum_spanning_tree_2(self):
Test inspired by the gif at the left of the page https://en.wikipedia.org/wiki/Kruskal%27s_algorithm
"""
edges_weighted = [((1, 2), 3), ((1, 5), 1), ((2, 5), 4), ((2, 3), 5), ((3, 5), 6), ((3, 4), 2), ((4, 5), 7)]
wgraph = WeightedGraph()
wgraph = graph.WeightedGraph()
for (u, v), weight in edges_weighted:
wgraph.add_edge(u, v, weight)
expected = [((1, 5), 1), ((3, 4), 2), ((1, 2), 3), ((2, 3), 5)]
Expand Down

0 comments on commit dc6ed0c

Please sign in to comment.