Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
trac #17540: Empty poset
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanncohen committed Dec 24, 2014
1 parent 216d59e commit ced5aff
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/sage/combinat/posets/posets.py
Expand Up @@ -2469,6 +2469,15 @@ def dimension(self, certificate=False):
sage: P.dimension() # not tested - around 4s
4
TESTS:
Empty Poset::
sage: Poset().dimension()
0
sage: Poset().dimension(certificate=1)
[]
References:
.. [FT00] Stefan Felsner, William T. Trotter,
Expand All @@ -2477,6 +2486,9 @@ def dimension(self, certificate=False):
2000, Volume 17, Issue 2, pp 167-177,
http://link.springer.com/article/10.1023%2FA%3A1006429830221
"""
if self.cardinality() == 0:
return [] if certificate else 0

from sage.numerical.mip import MixedIntegerLinearProgram, MIPSolverException
P = Poset(self._hasse_diagram) # work on an int-labelled poset
hasse_diagram = P.hasse_diagram()
Expand Down

0 comments on commit ced5aff

Please sign in to comment.