* assert'u yapistir

This commit is contained in:
Eray Özkural
2005-07-18 12:58:37 +00:00
parent 6450349f76
commit a2fe2361a4
2 changed files with 10 additions and 3 deletions
+2
View File
@@ -88,5 +88,7 @@ class digraph(object):
def topological_sort(self):
l = []
self.dfs(lambda u: l.append(u))
l.reverse()
return l
+8 -3
View File
@@ -11,10 +11,15 @@ class GraphTestCase(unittest.TestCase):
g0.from_list([ (1,2), (1,3), (2,3), (3,4), (4, 5), (4,1)])
g1 = graph.digraph()
g1.from_list([ (0,2), (0,3), (3,4), (2,4), (5,4) ])
g1.from_list([ (0,2), (0,3), (3,4), (2,4), (0,5), (5,4) ])
self.g1 = g1
def testCycle(self):
pass
def testTopologicalSort(self):
print self.g1.topological_sort()
order = self.g1.topological_sort()
self.assertEqual(order[0], 0)
self.assertEqual(order[len(order)-1], 4)
suite = unittest.makeSuite(GraphTestCase)