Skip to content

Commit 2c15778

Browse files
authored
implementing a concise function
1 parent 4a29e1c commit 2c15778

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

src/sage/combinat/posets/linear_extensions.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -294,26 +294,21 @@ def is_supergreedy(self):
294294
sage: T.linear_extensions()[0].is_supergreedy()
295295
True
296296
"""
297-
P = self.poset()
298-
H = P.hasse_diagram()
299-
sources = H.sources()
297+
H = self.poset().hasse_diagram()
298+
L = sources = H.sources()
300299
linext = []
301-
if not self:
302-
return True
303-
if self[0] not in sources:
304-
return False
305-
for i in range(len(self)-2):
306-
linext.append(self[i])
300+
for e in self:
301+
if e not in L:
302+
return False
303+
linext.append(e)
307304
for y in reversed(linext):
308305
L = [x for x in H.neighbor_out_iterator(y)
309306
if x not in linext
310307
and all(low in linext for low in H.neighbor_in_iterator(x))]
311308
if L:
312309
break
313310
else:
314-
L = (x for x in sources if x not in linext)
315-
if self[i+1] not in L:
316-
return False
311+
L = sources = [x for x in sources if x not in linext]
317312
return True
318313

319314
def tau(self, i):

0 commit comments

Comments
 (0)