Ticket #11293: trac_11293-review.patch

File trac_11293-review.patch, 1.4 KB (added by saliola, 10 years ago)
  • sage/combinat/posets/posets.py

    # HG changeset patch
    # User Franco Saliola <saliola@gmail.com>
    # Date 1304537446 14400
    # Node ID 5618206552041d6cceb98855b37358dfaff3602d
    # Parent  6d95d3c83827c0d3a5aece4a75a83456eaa4b608
    trac_11293: reviewer patch; efficiency improvements
    
    diff -r 6d95d3c83827 -r 561820655204 sage/combinat/posets/posets.py
    a b  
    717717
    718718        - Rob Beezer (2011-05-04)
    719719        """
    720         return [r for r in self.relations_iterator()]
     720        return list(self.relations_iterator())
    721721
    722722    def relations_iterator(self):
    723723        r"""
     
    743743
    744744        - Rob Beezer (2011-05-04)
    745745        """
    746         # Relies on vertices 0 to n-1 in the Hasse diagram being a
    747         # linear extension of the elements of the poset
    748         n = self._hasse_diagram.order()
     746        # Relies on vertices the fact that _elements correspond to the rows and
     747        # columns of the lequal matrix
     748        leq_mat = self.lequal_matrix()
     749        n = leq_mat.nrows()
     750        elements = self._elements
    749751        for i in range(n):
    750752            for j in range(i+1, n):
    751                 if self._hasse_diagram.is_less_than(i, j):
    752                     yield [self._vertex_to_element(i), self._vertex_to_element(j)]
     753                if leq_mat[i,j]:
     754                    yield [elements[i], elements[j]]
    753755
    754756    def is_lequal(self, x, y):
    755757        """