Skip to content

Commit 47d3187

Browse files
committed
Test add_edge in CheckCycleUndirectedGraph
This test is failing and is showing why the current implementation for CheckCycleUndirectedGraph is not correct.
1 parent c988139 commit 47d3187

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/test_data_structure.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,24 @@ def test_cycle_in_directed_graph(self):
192192
myGraph.add_edge(3, 3)
193193

194194
self.assertTrue(myGraph.check_cycle())
195+
196+
def test_add_edge_in_undirected_graph(self):
197+
myGraph = graph.CheckCycleUndirectedGraph()
198+
myGraph.add_edge(0, 1)
199+
myGraph.add_edge(0, 2)
200+
201+
setFrom0 = myGraph.graph[0]
202+
setFrom1 = myGraph.graph[1]
203+
setFrom2 = myGraph.graph[2]
204+
205+
self.assertIsNotNone(setFrom0)
206+
self.assertIsNotNone(setFrom1)
207+
self.assertIsNotNone(setFrom2)
208+
209+
self.assertIn(1, setFrom0)
210+
self.assertIn(0, setFrom1)
211+
self.assertIn(2, setFrom0)
212+
self.assertIn(0, setFrom2)
195213

196214
def test_cycle_in_undirected_graph(self):
197215
myGraph = graph.CheckCycleUndirectedGraph()

0 commit comments

Comments
 (0)