[pypy-svn] r73733 - in pypy/branch/blackhole-improvement/pypy/tool/algo: . test

arigo at codespeak.net arigo at codespeak.net
Wed Apr 14 13:30:41 CEST 2010


Author: arigo
Date: Wed Apr 14 13:30:39 2010
New Revision: 73733

Modified:
   pypy/branch/blackhole-improvement/pypy/tool/algo/color.py
   pypy/branch/blackhole-improvement/pypy/tool/algo/test/test_color.py
Log:
Rename it to Lexicographic breath-first ordering.


Modified: pypy/branch/blackhole-improvement/pypy/tool/algo/color.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/tool/algo/color.py	(original)
+++ pypy/branch/blackhole-improvement/pypy/tool/algo/color.py	Wed Apr 14 13:30:39 2010
@@ -20,12 +20,12 @@
         self.neighbours[v1].add(v2)
         self.neighbours[v2].add(v1)
 
-    def perfect_elimination_order(self):
+    def lexicographic_order(self):
         sigma = [set(self.neighbours)]
         result = []
         while sigma:
             v = sigma[0].pop()
-            result.append(v)
+            yield v
             newsigma = []
             neighb = self.neighbours[v]
             for s in sigma:
@@ -41,8 +41,6 @@
                 if s2:
                     newsigma.append(s2)
             sigma = newsigma
-        result.reverse()
-        return result
 
 
 _emptyset = frozenset()

Modified: pypy/branch/blackhole-improvement/pypy/tool/algo/test/test_color.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/tool/algo/test/test_color.py	(original)
+++ pypy/branch/blackhole-improvement/pypy/tool/algo/test/test_color.py	Wed Apr 14 13:30:39 2010
@@ -1,7 +1,7 @@
 from pypy.tool.algo.color import DependencyGraph
 
 
-def test_perfect_elimination_order():
+def test_lexicographic_order():
     dg = DependencyGraph()
     dg.add_node('a')
     dg.add_node('b')
@@ -15,8 +15,9 @@
     dg.add_edge('b', 'c')
     dg.add_edge('b', 'e')
     dg.add_edge('e', 'c')
-    order = list(dg.perfect_elimination_order())
+    order = list(dg.lexicographic_order())
     assert len(order) == 5
+    order.reverse()
     assert ''.join(order) in [
         'adbce', 'adbec', 'adcbe', 'adceb', 'adebc', 'adecb',
         'acbde', 'acbed', 'acdbe', 'acdeb', 'acebd', 'acedb',



More information about the Pypy-commit mailing list