From 34529353f524802681f26009e7049f8f00ac7f0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jori=20M=C3=A4ntysalo?= Date: Sat, 12 Sep 2015 07:44:27 +0300 Subject: [PATCH 1/2] Added is_upward_planar() to lattices. --- src/sage/combinat/posets/lattices.py | 50 ++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/sage/combinat/posets/lattices.py b/src/sage/combinat/posets/lattices.py index 8bb34533b4c..e6862f7435d 100644 --- a/src/sage/combinat/posets/lattices.py +++ b/src/sage/combinat/posets/lattices.py @@ -639,6 +639,56 @@ def is_atomic(self): return False return True + def is_upward_planar(self): + r""" + Return ``True`` if the lattice is (upward) planar, and ``False`` + otherwise. + + A lattice is upward planar if it's Hasse diagram has an upward + planar drawing. In other words, it can be drawn without + crossing lines and every covering relation directed upwards. + + This is called planar lattice in many papers. Name here is + chosen to prevent confusion with planarity in graphs. + + 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_upward_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_upward_planar() + False + sage: Po.is_upward_planar() + True + + TESTS:: + + sage: Posets.ChainPoset(0).is_upward_planar() + True + sage: Posets.ChainPoset(1).is_upward_planar() + True + """ + from sage.graphs.graph import Graph + # The 8-element Boolean lattice is the smallest non-planar lattice. + if self.cardinality() < 8: + return True + g = Graph(self._hasse_diagram) + 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. From 52a657ffca7acde0f622daffdbf0c066ea60887c Mon Sep 17 00:00:00 2001 From: Nathann Cohen Date: Mon, 21 Sep 2015 12:59:33 +0200 Subject: [PATCH 2/2] trac #19191: Additional documentation --- src/sage/combinat/posets/lattices.py | 52 ++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/src/sage/combinat/posets/lattices.py b/src/sage/combinat/posets/lattices.py index e6862f7435d..3e9637c4c37 100644 --- a/src/sage/combinat/posets/lattices.py +++ b/src/sage/combinat/posets/lattices.py @@ -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. @@ -639,17 +640,29 @@ def is_atomic(self): return False return True - def is_upward_planar(self): + def is_planar(self): r""" - Return ``True`` if the lattice is (upward) planar, and ``False`` + Return ``True`` if the lattice is *upward* planar, and ``False`` otherwise. - A lattice is upward planar if it's Hasse diagram has an upward - planar drawing. In other words, it can be drawn without - crossing lines and every covering relation directed upwards. + 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