Commits

Shu Zong Chen committed c728a5b

Initial leveler works

  • Participants
  • Parent commits 2a53596

Comments (0)

Files changed (1)

File dependency_graph.py

 
 	def sort_into_levels(self):
 		TS = self.topological_sort()
-		print "Found sort", TS
+		levels = {}
 		for n in TS:
-			print "--------\nTesting", n
 			ancestors = self.ancestors_of(n)
+			if len(ancestors):
+				m = max([levels[i] for i in ancestors])
+				levels[n] = m + 1
+			else:
+				# roots have level 0
+				levels[n] = 0
+			return levels
+
 			
 
 	@property
 
 		def test_leveler(self):
 			g = dependency_graph(self.double_ends)
-			print g.sort_into_levels()
+			g.sort_into_levels()
 				
 	unittest.main()