Skip to content

Commit

Permalink
Trac #19191: LatticePoset: add is_planar()
Browse files Browse the repository at this point in the history
Add `is_planar()` to `LatticePoset`. See
http://www.sciencedirect.com/science/article/pii/0095895676900241 for
definition.

URL: http://trac.sagemath.org/19191
Reported by: jmantysalo
Ticket author(s): Nathann Cohen, Jori Mäntysalo
Reviewer(s): Jori Mäntysalo, Nathann Cohen
  • Loading branch information
Release Manager authored and vbraun committed Sep 22, 2015
2 parents d83db35 + 52a657f commit 7ca4917
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions src/sage/combinat/posets/lattices.py
Expand Up @@ -33,6 +33,7 @@
:meth:`~FiniteLatticePoset.is_modular` | Return ``True`` if the lattice is lower modular.
:meth:`~FiniteLatticePoset.is_modular_element` | Return ``True`` if given element is modular in the lattice.
:meth:`~FiniteLatticePoset.is_upper_semimodular` | Return ``True`` if the lattice is upper semimodular.
:meth:`~FiniteLatticePoset.is_planar` | Return ``True`` if the lattice is *upward* planar, and ``False`` otherwise.
:meth:`~FiniteLatticePoset.is_supersolvable` | Return ``True`` if the lattice is supersolvable.
:meth:`~FiniteJoinSemilattice.join` | Return the join of given elements in the join semi-lattice.
:meth:`~FiniteJoinSemilattice.join_matrix` | Return the matrix of joins of all elements of the join semi-lattice.
Expand Down Expand Up @@ -738,6 +739,79 @@ def is_atomic(self):
return False
return True

def is_planar(self):
r"""
Return ``True`` if the lattice is *upward* planar, and ``False``
otherwise.
A lattice is upward planar if its Hasse diagram has a planar drawing in
the `\mathbb{R}^2` plane, in such a way that `x` is strictly below `y`
(on the vertical axis) whenever `x<y` in the lattice.
Note that the scientific litterature on posets often omits "upward" and
shortens it to "planar lattice" (e.g. [GW14]_), which can cause
confusion with the notion of graph planarity in graph theory.
.. NOTE::
Not all lattices which are planar -- in the sense of graph planarity
-- admit such a planar drawing (see example below).
ALGORITHM:
Using the result from [Platt76]_, this method returns its result by
testing that the hasse diagram of the lattice is planar (in the sense of
graph theory) when an edge is added between the top and bottom elements.
EXAMPLES:
The Boolean lattice of `2^3` elements is not upward planar, even if
it's covering relations graph is planar::
sage: B3 = Posets.BooleanLattice(3)
sage: B3.is_planar()
False
sage: G = B3.cover_relations_graph()
sage: G.is_planar()
True
Ordinal product of planar lattices is obviously planar. Same does
not apply to cartesian products::
sage: P = Posets.PentagonPoset()
sage: Pc = P.product(P)
sage: Po = P.ordinal_product(P)
sage: Pc.is_planar()
False
sage: Po.is_planar()
True
TESTS::
sage: Posets.ChainPoset(0).is_planar()
True
sage: Posets.ChainPoset(1).is_planar()
True
REFERENCES:
.. [GW14] G. Gratzer and F. Wehrung,
Lattice Theory: Special Topics and Applications Vol. 1,
Springer, 2014.
.. [Platt76] C. R. Platt,
Planar lattices and planar graphs,
Journal of Combinatorial Theory Series B,
Vol 21, no. 1 (1976): 30-39.
"""
# The 8-element Boolean lattice is the smallest non-planar lattice.
if self.cardinality() < 8:
return True
g = self._hasse_diagram.copy(immutable=False)
g.add_edge(0, self.cardinality()-1)
return g.is_planar()

def is_modular(self, L=None):
r"""
Return ``True`` if the lattice is modular and ``False`` otherwise.
Expand Down

0 comments on commit 7ca4917

Please sign in to comment.