From 65b7cfe7ecf3c1ce778ea274707ecb1e9b0871f0 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 5 Aug 2022 18:18:55 -0700 Subject: [PATCH 1/6] Triangulation.polyhedral_complex: New --- src/sage/geometry/triangulation/element.py | 42 +++++++++++++++++++--- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/src/sage/geometry/triangulation/element.py b/src/sage/geometry/triangulation/element.py index cf58a76187b..772517a5aa7 100644 --- a/src/sage/geometry/triangulation/element.py +++ b/src/sage/geometry/triangulation/element.py @@ -572,8 +572,7 @@ def fan(self, origin=None): @cached_method def simplicial_complex(self): r""" - Return a simplicial complex from a triangulation of the point - configuration. + Return ``self`` as an (abstract) simplicial complex. OUTPUT: @@ -711,6 +710,42 @@ def interior_facets(self): in self._boundary_simplex_dictionary().items() if len(bounded_simplices) == 2) + def polyhedral_complex(self, **kwds): + """ + Return ``self`` as a :class:`~sage.geometry.polyhedral_complex.PolyhedralComplex`. + + OUTPUT: + + A :class:`~sage.geometry.polyhedral_complex.PolyhedralComplex` whose maximal cells + are the simplices of the triangulation. + + EXAMPLES:: + + sage: P = polytopes.cube() + sage: pc = PointConfiguration(P.vertices()) + sage: T = pc.placing_triangulation(); T + (<0,1,2,7>, <0,1,5,7>, <0,2,3,7>, <0,3,4,7>, <0,4,5,7>, <1,5,6,7>) + sage: C = T.polyhedral_complex(); C + Polyhedral complex with 6 maximal cells + sage: [P.vertices_list() for P in C.maximal_cells_sorted()] + [[[-1, -1, -1], [-1, -1, 1], [-1, 1, 1], [1, -1, -1]], + [[-1, -1, -1], [-1, 1, -1], [-1, 1, 1], [1, 1, -1]], + [[-1, -1, -1], [-1, 1, 1], [1, -1, -1], [1, 1, -1]], + [[-1, -1, 1], [-1, 1, 1], [1, -1, -1], [1, -1, 1]], + [[-1, 1, 1], [1, -1, -1], [1, -1, 1], [1, 1, 1]], + [[-1, 1, 1], [1, -1, -1], [1, 1, -1], [1, 1, 1]]] + """ + from sage.geometry.polyhedral_complex import PolyhedralComplex + from sage.geometry.polyhedron.constructor import Polyhedron + ambient_dim = self.point_configuration().ambient_dim() + points = self.point_configuration().points() + return PolyhedralComplex([Polyhedron(vertices=[points[i] for i in simplex]) + for simplex in self], + ambient_dim=ambient_dim, + maximality_check=False, + face_to_face_check=False, + **kwds) + @cached_method def normal_cone(self): r""" @@ -798,8 +833,7 @@ def normal_cone(self): def adjacency_graph(self): """ - Returns a graph showing which simplices are adjacent in the - triangulation + Return a graph showing which simplices are adjacent in the triangulation OUTPUT: From fff67c3d2f60db85f014b5291ab3f1746199c5e5 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 5 Aug 2022 18:55:49 -0700 Subject: [PATCH 2/6] Triangulation.boundary_{simplicial,polyhedral}_complex: New --- src/sage/geometry/triangulation/element.py | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/src/sage/geometry/triangulation/element.py b/src/sage/geometry/triangulation/element.py index 772517a5aa7..4b6480ac4c8 100644 --- a/src/sage/geometry/triangulation/element.py +++ b/src/sage/geometry/triangulation/element.py @@ -674,6 +674,28 @@ def boundary(self): in self._boundary_simplex_dictionary().items() if len(bounded_simplices) == 1) + @cached_method + def boundary_simplicial_complex(self): + r""" + Return the boundary of ``self`` as an (abstract) simplicial complex. + + OUTPUT: + + A :class:`~sage.topology.simplicial_complex.SimplicialComplex`. + + EXAMPLES:: + + sage: p = polytopes.cuboctahedron() + sage: sc = p.triangulate(engine='internal').boundary_simplicial_complex() + sage: sc + Simplicial complex with 12 vertices and 20 facets + + The boundary of every convex set is a topological sphere:: + + """ + from sage.topology.simplicial_complex import SimplicialComplex + return SimplicialComplex(self.boundary(), maximality_check=False) + @cached_method def interior_facets(self): """ @@ -746,6 +768,48 @@ def polyhedral_complex(self, **kwds): face_to_face_check=False, **kwds) + def boundary_polyhedral_complex(self, **kwds): + r""" + Return the boundary of ``self`` as a :class:`~sage.geometry.polyhedral_complex.PolyhedralComplex`. + + OUTPUT: + + A :class:`~sage.geometry.polyhedral_complex.PolyhedralComplex` whose maximal cells + are the simplices of the boundary of ``self``. + + EXAMPLES:: + + sage: P = polytopes.cube() + sage: pc = PointConfiguration(P.vertices()) + sage: T = pc.placing_triangulation(); T + (<0,1,2,7>, <0,1,5,7>, <0,2,3,7>, <0,3,4,7>, <0,4,5,7>, <1,5,6,7>) + sage: C = T.boundary_polyhedral_complex(); C + Polyhedral complex with 12 maximal cells + sage: [P.vertices_list() for P in C.maximal_cells_sorted()] + [[[-1, -1, -1], [-1, -1, 1], [-1, 1, 1]], + [[-1, -1, -1], [-1, -1, 1], [1, -1, -1]], + [[-1, -1, -1], [-1, 1, -1], [-1, 1, 1]], + [[-1, -1, -1], [-1, 1, -1], [1, 1, -1]], + [[-1, -1, -1], [1, -1, -1], [1, 1, -1]], + [[-1, -1, 1], [-1, 1, 1], [1, -1, 1]], + [[-1, -1, 1], [1, -1, -1], [1, -1, 1]], + [[-1, 1, -1], [-1, 1, 1], [1, 1, -1]], + [[-1, 1, 1], [1, -1, 1], [1, 1, 1]], + [[-1, 1, 1], [1, 1, -1], [1, 1, 1]], + [[1, -1, -1], [1, -1, 1], [1, 1, 1]], + [[1, -1, -1], [1, 1, -1], [1, 1, 1]]] + """ + from sage.geometry.polyhedral_complex import PolyhedralComplex + from sage.geometry.polyhedron.constructor import Polyhedron + ambient_dim = self.point_configuration().ambient_dim() + points = self.point_configuration().points() + return PolyhedralComplex([Polyhedron(vertices=[points[i] for i in simplex]) + for simplex in self.boundary()], + ambient_dim=ambient_dim, + maximality_check=False, + face_to_face_check=False, + **kwds) + @cached_method def normal_cone(self): r""" From 0a09ca45dc4a579a1900b922b156b02836b3340f Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 5 Aug 2022 19:11:21 -0700 Subject: [PATCH 3/6] src/sage/geometry/triangulation/element.py: Add missing example --- src/sage/geometry/triangulation/element.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/sage/geometry/triangulation/element.py b/src/sage/geometry/triangulation/element.py index 4b6480ac4c8..ebb60a72584 100644 --- a/src/sage/geometry/triangulation/element.py +++ b/src/sage/geometry/triangulation/element.py @@ -690,8 +690,11 @@ def boundary_simplicial_complex(self): sage: sc Simplicial complex with 12 vertices and 20 facets - The boundary of every convex set is a topological sphere:: + The boundary of every convex set is a topological sphere, so it has + spherical homology:: + sage: sc.homology() + {0: 0, 1: 0, 2: Z} """ from sage.topology.simplicial_complex import SimplicialComplex return SimplicialComplex(self.boundary(), maximality_check=False) From 0845f0381c559acfa648c9828099ca0c4d38ba8a Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 6 Aug 2022 14:23:29 -0700 Subject: [PATCH 4/6] Triangulation.boundary_simplicial_complex: Expand example --- src/sage/geometry/triangulation/element.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/sage/geometry/triangulation/element.py b/src/sage/geometry/triangulation/element.py index ebb60a72584..48f16e8ed06 100644 --- a/src/sage/geometry/triangulation/element.py +++ b/src/sage/geometry/triangulation/element.py @@ -686,15 +686,22 @@ def boundary_simplicial_complex(self): EXAMPLES:: sage: p = polytopes.cuboctahedron() - sage: sc = p.triangulate(engine='internal').boundary_simplicial_complex() - sage: sc + sage: triangulation = p.triangulate(engine='internal') + sage: bd_sc = triangulation.boundary_simplicial_complex() + sage: bd_sc Simplicial complex with 12 vertices and 20 facets The boundary of every convex set is a topological sphere, so it has spherical homology:: - sage: sc.homology() + sage: bd_sc.homology() {0: 0, 1: 0, 2: Z} + + It is a subcomplex of ``self`` as a :meth:`simplicial_complex`:: + + sage: sc = triangulation.simplicial_complex() + sage: all(f in sc for f in bd_sc.maximal_faces()) + True """ from sage.topology.simplicial_complex import SimplicialComplex return SimplicialComplex(self.boundary(), maximality_check=False) From 80165ba864883114469c4dfd14c11796f8bab256 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 6 Aug 2022 14:27:03 -0700 Subject: [PATCH 5/6] Triangulation.boundary_polyhedral_complex: Expand example --- src/sage/geometry/triangulation/element.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/sage/geometry/triangulation/element.py b/src/sage/geometry/triangulation/element.py index 48f16e8ed06..a2572cf24d2 100644 --- a/src/sage/geometry/triangulation/element.py +++ b/src/sage/geometry/triangulation/element.py @@ -793,9 +793,9 @@ def boundary_polyhedral_complex(self, **kwds): sage: pc = PointConfiguration(P.vertices()) sage: T = pc.placing_triangulation(); T (<0,1,2,7>, <0,1,5,7>, <0,2,3,7>, <0,3,4,7>, <0,4,5,7>, <1,5,6,7>) - sage: C = T.boundary_polyhedral_complex(); C + sage: bd_C = T.boundary_polyhedral_complex(); bd_C Polyhedral complex with 12 maximal cells - sage: [P.vertices_list() for P in C.maximal_cells_sorted()] + sage: [P.vertices_list() for P in bd_C.maximal_cells_sorted()] [[[-1, -1, -1], [-1, -1, 1], [-1, 1, 1]], [[-1, -1, -1], [-1, -1, 1], [1, -1, -1]], [[-1, -1, -1], [-1, 1, -1], [-1, 1, 1]], @@ -808,6 +808,12 @@ def boundary_polyhedral_complex(self, **kwds): [[-1, 1, 1], [1, 1, -1], [1, 1, 1]], [[1, -1, -1], [1, -1, 1], [1, 1, 1]], [[1, -1, -1], [1, 1, -1], [1, 1, 1]]] + + It is a subcomplex of ``self`` as a :meth:`polyhedral_complex`:: + + sage: C = T.polyhedral_complex() + sage: bd_C.is_subcomplex(C) + True """ from sage.geometry.polyhedral_complex import PolyhedralComplex from sage.geometry.polyhedron.constructor import Polyhedron From 65134f1606814d4b3e94e87d84c0b18576bfa180 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 6 Aug 2022 15:23:25 -0700 Subject: [PATCH 6/6] src/sage/geometry/triangulation/element.py: Docstring improvements --- src/sage/geometry/triangulation/element.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/sage/geometry/triangulation/element.py b/src/sage/geometry/triangulation/element.py index a2572cf24d2..a0e76c3bf54 100644 --- a/src/sage/geometry/triangulation/element.py +++ b/src/sage/geometry/triangulation/element.py @@ -227,8 +227,9 @@ class Triangulation(Element): """ def __init__(self, triangulation, parent, check=True): """ - The constructor of a ``Triangulation`` object. Note that an - internal reference to the underlying ``PointConfiguration`` is + The constructor of a ``Triangulation`` object. + + Note that an internal reference to the underlying ``PointConfiguration`` is kept. INPUT: @@ -236,12 +237,11 @@ def __init__(self, triangulation, parent, check=True): - ``parent`` -- a :class:`~sage.geometry.triangulation.point_configuration.PointConfiguration` - - ``triangulation`` -- an iterable of integers or iterable of - iterables (e.g. a list of lists). In the first case, the - integers specify simplices via - :meth:`PointConfiguration.simplex_to_int`. In the second - case, the point indices of the maximal simplices of the - triangulation. + - ``triangulation`` -- an iterable of integers or an iterable of + iterables (e.g. a list of lists), specifying the maximal simplices + of the triangulation. In the first case, each integer specifies a simplex + by the correspondence :meth:`PointConfiguration.simplex_to_int`. In the second + case, a simplex is specified by listing the indices of the included points. - ``check`` -- boolean. Whether to perform checks that the triangulation is, indeed, a triangulation of the point @@ -370,7 +370,7 @@ def __getitem__(self, i): def __len__(self): """ - Returns the length of the triangulation. + Return the length of the triangulation. TESTS:: @@ -597,7 +597,7 @@ def simplicial_complex(self): @cached_method def _boundary_simplex_dictionary(self): """ - Return facets and the simplices they bound + Return facets and the simplices they bound. TESTS:: @@ -913,7 +913,7 @@ def normal_cone(self): def adjacency_graph(self): """ - Return a graph showing which simplices are adjacent in the triangulation + Return a graph showing which simplices are adjacent in the triangulation. OUTPUT: