Finite polyhedral complexes¶
This module implements the basic structure of finite polyhedral complexes.
For more information, see PolyhedralComplex
.
AUTHORS:
Yuan Zhou (2021-05): initial implementation
List of PolyhedralComplex methods¶
Maximal cells and cells
Return the dictionary of the maximal cells in this polyhedral complex. |
|
Return an iterator over maximal cells in this polyhedral complex. |
|
Return the sorted list of all maximal cells in this polyhedral complex. |
|
List the maximal cells of dimension \(n\) in this polyhedral complex. |
|
|
Return the sorted list of maximal cells of dim \(n\) in this complex. |
Return |
|
Return the dictionary of the cells in this polyhedral complex. |
|
Return an iterator over cells in this polyhedral complex. |
|
Return the sorted list of all cells in this polyhedral complex. |
|
List the cells of dimension \(n\) in this polyhedral complex. |
|
|
Return the sorted list of \(n\)-cells in this polyhedral complex. |
Return |
|
Return the poset of nonempty cells in the polyhedral complex. |
|
List the maximal cells on the boundary of the polyhedral complex. |
Properties of the polyhedral complex
Return the dimension of the polyhedral complex. |
|
Return the ambient dimension of the polyhedral complex. |
|
Return |
|
Return |
|
Return |
|
Return |
|
Return |
|
Return |
|
Return |
|
Return |
|
Return |
|
Return |
|
Return |
New polyhedral complexes from old ones
Return the connected component containing a cell as a subcomplex. |
|
Return the connected components of this polyhedral complex. |
|
Return the \(n\)-skeleton of this polyhedral complex. |
|
Return the (pure) subcomplex formed by the maximal cells of dim \(n\) in this complex. |
|
Return the boundary subcomplex of this polyhedral complex. |
|
Return the (Cartesian) product of this polyhedral complex with another one. |
|
Return the disjoint union of this polyhedral complex with another one. |
|
Return the union of this polyhedral complex with another one. |
|
Return the join of this polyhedral complex with another one. |
|
Return a new polyhedral complex (with option |
Update polyhedral complex
Make this polyhedral complex immutable. |
|
Add a cell to this polyhedral complex. |
|
Remove a cell from this polyhedral complex. |
Miscellaneous
Return a Graphic object showing the plot of polyhedral complex. |
|
Return a directed graph corresponding to the 1-skeleton of this polyhedral complex, given that it is bounded. |
|
Return a |
Classes and functions¶
- class sage.geometry.polyhedral_complex.PolyhedralComplex(maximal_cells=None, backend=None, maximality_check=True, face_to_face_check=False, is_mutable=True, is_immutable=False, ambient_dim=None)[source]¶
Bases:
GenericCellComplex
A polyhedral complex.
A polyhedral complex \(PC\) is a collection of polyhedra in a certain ambient space \(\RR^n\) such that the following hold.
If a polyhedron \(P\) is in \(PC\), then all the faces of \(P\) are in \(PC\).
If polyhedra \(P\) and \(Q\) are in \(PC\), then \(P \cap Q\) is either empty or a face of both \(P\) and \(Q\).
In this context, a “polyhedron” means the geometric realization of a polyhedron. This is in contrast to
simplicial complex
, whose cells are abstract simplices. The concept of a polyhedral complex generalizes that of a geometric simplicial complex.Note
This class derives from
GenericCellComplex
, and so inherits its methods. Some of those methods are not listed here; see theGeneric Cell Complex
page instead.INPUT:
maximal_cells
– list, tuple, or dictionary (indexed by dimension) of cells of the Complex. Each cell is of classPolyhedron
of the same ambient dimension. To set up a :class:PolyhedralComplex, it is sufficient to provide the maximal faces. Use keyword argumentpartial=True
to set up a partial polyhedral complex, which is a subset of the faces (viewed as relatively open) of a polyhedral complex that is not necessarily closed under taking intersection.maximality_check
– boolean (default:True
); ifTrue
, then the constructor checks that each given maximal cell is indeed maximal, and ignores those that are notface_to_face_check
– boolean (default:False
); ifTrue
, then the constructor checks whether the cells are face-to-face, and it raises aValueError
if they are notis_mutable
andis_immutable
– boolean (default:True
andFalse
respectively); setis_mutable=False
oris_immutable=True
to make this polyhedral complex immutablebackend
– string (optional); the name of the backend used for computations on Sage polyhedra; if it is not given, then each cell has its own backend; otherwise it must be one of the following:'ppl'
– the Parma Polyhedra Library'cdd'
– CDD'normaliz'
– normaliz'polymake'
– polymake'field'
– a generic Sage implementation
ambient_dim
– integer (optional); used to set up an empty complex in the intended ambient space
EXAMPLES:
sage: pc = PolyhedralComplex([ ....: Polyhedron(vertices=[(1/3, 1/3), (0, 0), (1/7, 2/7)]), ....: Polyhedron(vertices=[(1/7, 2/7), (0, 0), (0, 1/4)])]) sage: [p.Vrepresentation() for p in pc.cells_sorted()] [(A vertex at (0, 0), A vertex at (0, 1/4), A vertex at (1/7, 2/7)), (A vertex at (0, 0), A vertex at (1/3, 1/3), A vertex at (1/7, 2/7)), (A vertex at (0, 0), A vertex at (0, 1/4)), (A vertex at (0, 0), A vertex at (1/7, 2/7)), (A vertex at (0, 0), A vertex at (1/3, 1/3)), (A vertex at (0, 1/4), A vertex at (1/7, 2/7)), (A vertex at (1/3, 1/3), A vertex at (1/7, 2/7)), (A vertex at (0, 0),), (A vertex at (0, 1/4),), (A vertex at (1/7, 2/7),), (A vertex at (1/3, 1/3),)] sage: pc.plot() # needs sage.plot Graphics object consisting of 10 graphics primitives sage: pc.is_pure() True sage: pc.is_full_dimensional() True sage: pc.is_compact() True sage: pc.boundary_subcomplex() Polyhedral complex with 4 maximal cells sage: pc.is_convex() True sage: pc.union_as_polyhedron().Hrepresentation() (An inequality (1, -4) x + 1 >= 0, An inequality (-1, 1) x + 0 >= 0, An inequality (1, 0) x + 0 >= 0) sage: pc.face_poset() Finite poset containing 11 elements sage: pc.is_connected() True sage: pc.connected_component() == pc True
>>> from sage.all import * >>> pc = PolyhedralComplex([ ... Polyhedron(vertices=[(Integer(1)/Integer(3), Integer(1)/Integer(3)), (Integer(0), Integer(0)), (Integer(1)/Integer(7), Integer(2)/Integer(7))]), ... Polyhedron(vertices=[(Integer(1)/Integer(7), Integer(2)/Integer(7)), (Integer(0), Integer(0)), (Integer(0), Integer(1)/Integer(4))])]) >>> [p.Vrepresentation() for p in pc.cells_sorted()] [(A vertex at (0, 0), A vertex at (0, 1/4), A vertex at (1/7, 2/7)), (A vertex at (0, 0), A vertex at (1/3, 1/3), A vertex at (1/7, 2/7)), (A vertex at (0, 0), A vertex at (0, 1/4)), (A vertex at (0, 0), A vertex at (1/7, 2/7)), (A vertex at (0, 0), A vertex at (1/3, 1/3)), (A vertex at (0, 1/4), A vertex at (1/7, 2/7)), (A vertex at (1/3, 1/3), A vertex at (1/7, 2/7)), (A vertex at (0, 0),), (A vertex at (0, 1/4),), (A vertex at (1/7, 2/7),), (A vertex at (1/3, 1/3),)] >>> pc.plot() # needs sage.plot Graphics object consisting of 10 graphics primitives >>> pc.is_pure() True >>> pc.is_full_dimensional() True >>> pc.is_compact() True >>> pc.boundary_subcomplex() Polyhedral complex with 4 maximal cells >>> pc.is_convex() True >>> pc.union_as_polyhedron().Hrepresentation() (An inequality (1, -4) x + 1 >= 0, An inequality (-1, 1) x + 0 >= 0, An inequality (1, 0) x + 0 >= 0) >>> pc.face_poset() Finite poset containing 11 elements >>> pc.is_connected() True >>> pc.connected_component() == pc True
pc = PolyhedralComplex([ Polyhedron(vertices=[(1/3, 1/3), (0, 0), (1/7, 2/7)]), Polyhedron(vertices=[(1/7, 2/7), (0, 0), (0, 1/4)])]) [p.Vrepresentation() for p in pc.cells_sorted()] pc.plot() # needs sage.plot pc.is_pure() pc.is_full_dimensional() pc.is_compact() pc.boundary_subcomplex() pc.is_convex() pc.union_as_polyhedron().Hrepresentation() pc.face_poset() pc.is_connected() pc.connected_component() == pc
- add_cell(cell)[source]¶
Add a cell to this polyhedral complex.
INPUT:
cell
– a polyhedron
This changes the polyhedral complex, by adding a new cell and all of its subfaces.
EXAMPLES:
Set up an empty complex in the intended ambient space, then add a cell:
sage: pc = PolyhedralComplex(ambient_dim=2) sage: pc.add_cell(Polyhedron(vertices=[(1, 2), (0, 2)])) sage: pc Polyhedral complex with 1 maximal cell
>>> from sage.all import * >>> pc = PolyhedralComplex(ambient_dim=Integer(2)) >>> pc.add_cell(Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(2))])) >>> pc Polyhedral complex with 1 maximal cell
pc = PolyhedralComplex(ambient_dim=2) pc.add_cell(Polyhedron(vertices=[(1, 2), (0, 2)])) pc
If you add a cell which is already present, there is no effect:
sage: pc.add_cell(Polyhedron(vertices=[(1, 2)])) sage: pc Polyhedral complex with 1 maximal cell sage: pc.dimension() 1
>>> from sage.all import * >>> pc.add_cell(Polyhedron(vertices=[(Integer(1), Integer(2))])) >>> pc Polyhedral complex with 1 maximal cell >>> pc.dimension() 1
pc.add_cell(Polyhedron(vertices=[(1, 2)])) pc pc.dimension()
Add a cell and check that dimension is correctly updated:
sage: pc.add_cell(Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)])) sage: pc.dimension() 2 sage: pc.maximal_cells() {2: {A 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 3 vertices}} sage: pc.is_convex() True
>>> from sage.all import * >>> pc.add_cell(Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(0)), (Integer(0), Integer(2))])) >>> pc.dimension() 2 >>> pc.maximal_cells() {2: {A 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 3 vertices}} >>> pc.is_convex() True
pc.add_cell(Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)])) pc.dimension() pc.maximal_cells() pc.is_convex()
Add another cell and check that the properties are correctly updated:
sage: pc.add_cell(Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)])) sage: pc Polyhedral complex with 2 maximal cells sage: len(pc._cells[1]) 5 sage: pc._face_poset Finite poset containing 11 elements sage: pc._is_convex True sage: pc._polyhedron.vertices_list() [[0, 0], [0, 2], [1, 1], [1, 2]]
>>> from sage.all import * >>> pc.add_cell(Polyhedron(vertices=[(Integer(1), Integer(1)), (Integer(0), Integer(0)), (Integer(1), Integer(2))])) >>> pc Polyhedral complex with 2 maximal cells >>> len(pc._cells[Integer(1)]) 5 >>> pc._face_poset Finite poset containing 11 elements >>> pc._is_convex True >>> pc._polyhedron.vertices_list() [[0, 0], [0, 2], [1, 1], [1, 2]]
pc.add_cell(Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)])) pc len(pc._cells[1]) pc._face_poset pc._is_convex pc._polyhedron.vertices_list()
Add a ray which makes the complex non convex:
sage: pc.add_cell(Polyhedron(rays=[(1, 0)])) sage: pc Polyhedral complex with 3 maximal cells sage: len(pc._cells[1]) 6 sage: (pc._is_convex is False) and (pc._polyhedron is None) True
>>> from sage.all import * >>> pc.add_cell(Polyhedron(rays=[(Integer(1), Integer(0))])) >>> pc Polyhedral complex with 3 maximal cells >>> len(pc._cells[Integer(1)]) 6 >>> (pc._is_convex is False) and (pc._polyhedron is None) True
pc.add_cell(Polyhedron(rays=[(1, 0)])) pc len(pc._cells[1]) (pc._is_convex is False) and (pc._polyhedron is None)
- alexander_whitney(cell, dim_left)[source]¶
The decomposition of
cell
in this complex into left and right factors, suitable for computing cup products.Todo
Implement
alexander_whitney()
of a polyhedral complex.EXAMPLES:
sage: pc = PolyhedralComplex([Polyhedron(vertices=[[0], [1]])]) sage: pc.alexander_whitney(None, 1) Traceback (most recent call last): ... NotImplementedError: alexander_whitney is not implemented for polyhedral complex
>>> from sage.all import * >>> pc = PolyhedralComplex([Polyhedron(vertices=[[Integer(0)], [Integer(1)]])]) >>> pc.alexander_whitney(None, Integer(1)) Traceback (most recent call last): ... NotImplementedError: alexander_whitney is not implemented for polyhedral complex
pc = PolyhedralComplex([Polyhedron(vertices=[[0], [1]])]) pc.alexander_whitney(None, 1)
- ambient_dimension()[source]¶
The ambient dimension of this cell complex: the ambient dimension of each of its cells.
EXAMPLES:
sage: pc = PolyhedralComplex([Polyhedron(vertices=[(1, 2, 3)])]) sage: pc.ambient_dimension() 3 sage: empty_pc = PolyhedralComplex([]) sage: empty_pc.ambient_dimension() -1 sage: pc0 = PolyhedralComplex(ambient_dim=2) sage: pc0.ambient_dimension() 2
>>> from sage.all import * >>> pc = PolyhedralComplex([Polyhedron(vertices=[(Integer(1), Integer(2), Integer(3))])]) >>> pc.ambient_dimension() 3 >>> empty_pc = PolyhedralComplex([]) >>> empty_pc.ambient_dimension() -1 >>> pc0 = PolyhedralComplex(ambient_dim=Integer(2)) >>> pc0.ambient_dimension() 2
pc = PolyhedralComplex([Polyhedron(vertices=[(1, 2, 3)])]) pc.ambient_dimension() empty_pc = PolyhedralComplex([]) empty_pc.ambient_dimension() pc0 = PolyhedralComplex(ambient_dim=2) pc0.ambient_dimension()
- boundary_subcomplex()[source]¶
Return the sub-polyhedral complex that is the boundary of
self
.A point \(P\) is on the boundary of a set \(S\) if \(P\) is in the closure of \(S\) but not in the interior of \(S\).
EXAMPLES:
sage: p1 = Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]) sage: p2 = Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)]) sage: p3 = Polyhedron(vertices=[(1, 2), (0, 2)]) sage: bd = PolyhedralComplex([p1, p2]).boundary_subcomplex() sage: len(bd.n_maximal_cells(2)) 0 sage: len(bd.n_maximal_cells(1)) 4 sage: pt = PolyhedralComplex([p3]) sage: pt.boundary_subcomplex() == pt True
>>> from sage.all import * >>> p1 = Polyhedron(vertices=[(Integer(1), Integer(1)), (Integer(0), Integer(0)), (Integer(1), Integer(2))]) >>> p2 = Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(0)), (Integer(0), Integer(2))]) >>> p3 = Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(2))]) >>> bd = PolyhedralComplex([p1, p2]).boundary_subcomplex() >>> len(bd.n_maximal_cells(Integer(2))) 0 >>> len(bd.n_maximal_cells(Integer(1))) 4 >>> pt = PolyhedralComplex([p3]) >>> pt.boundary_subcomplex() == pt True
p1 = Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]) p2 = Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)]) p3 = Polyhedron(vertices=[(1, 2), (0, 2)]) bd = PolyhedralComplex([p1, p2]).boundary_subcomplex() len(bd.n_maximal_cells(2)) len(bd.n_maximal_cells(1)) pt = PolyhedralComplex([p3]) pt.boundary_subcomplex() == pt
Test on polyhedral complex which is not pure:
sage: pc_non_pure = PolyhedralComplex([p1, p3]) sage: pc_non_pure.boundary_subcomplex() == pc_non_pure.n_skeleton(1) True
>>> from sage.all import * >>> pc_non_pure = PolyhedralComplex([p1, p3]) >>> pc_non_pure.boundary_subcomplex() == pc_non_pure.n_skeleton(Integer(1)) True
pc_non_pure = PolyhedralComplex([p1, p3]) pc_non_pure.boundary_subcomplex() == pc_non_pure.n_skeleton(1)
Test with
maximality_check == False
:sage: pc_invalid = PolyhedralComplex([p2, p3], ....: maximality_check=False) sage: pc_invalid.boundary_subcomplex() == pc_invalid.n_skeleton(1) True
>>> from sage.all import * >>> pc_invalid = PolyhedralComplex([p2, p3], ... maximality_check=False) >>> pc_invalid.boundary_subcomplex() == pc_invalid.n_skeleton(Integer(1)) True
pc_invalid = PolyhedralComplex([p2, p3], maximality_check=False) pc_invalid.boundary_subcomplex() == pc_invalid.n_skeleton(1)
Test unbounded cases:
sage: pc1 = PolyhedralComplex([ ....: Polyhedron(vertices=[[1,0], [0,1]], rays=[[1,0], [0,1]])]) sage: pc1.boundary_subcomplex() == pc1.n_skeleton(1) True sage: pc1b = PolyhedralComplex([Polyhedron( ....: vertices=[[1,0,0], [0,1,0]], rays=[[1,0,0],[0,1,0]])]) sage: pc1b.boundary_subcomplex() == pc1b True sage: pc2 = PolyhedralComplex([ ....: Polyhedron(vertices=[[-1,0], [1,0]], lines=[[0,1]])]) sage: pc2.boundary_subcomplex() == pc2.n_skeleton(1) True sage: pc3 = PolyhedralComplex([ ....: Polyhedron(vertices=[[1,0], [0,1]], rays=[[1,0], [0,1]]), ....: Polyhedron(vertices=[[1,0], [0,-1]], rays=[[1,0], [0,-1]])]) sage: pc3.boundary_subcomplex() == pc3.n_skeleton(1) False
>>> from sage.all import * >>> pc1 = PolyhedralComplex([ ... Polyhedron(vertices=[[Integer(1),Integer(0)], [Integer(0),Integer(1)]], rays=[[Integer(1),Integer(0)], [Integer(0),Integer(1)]])]) >>> pc1.boundary_subcomplex() == pc1.n_skeleton(Integer(1)) True >>> pc1b = PolyhedralComplex([Polyhedron( ... vertices=[[Integer(1),Integer(0),Integer(0)], [Integer(0),Integer(1),Integer(0)]], rays=[[Integer(1),Integer(0),Integer(0)],[Integer(0),Integer(1),Integer(0)]])]) >>> pc1b.boundary_subcomplex() == pc1b True >>> pc2 = PolyhedralComplex([ ... Polyhedron(vertices=[[-Integer(1),Integer(0)], [Integer(1),Integer(0)]], lines=[[Integer(0),Integer(1)]])]) >>> pc2.boundary_subcomplex() == pc2.n_skeleton(Integer(1)) True >>> pc3 = PolyhedralComplex([ ... Polyhedron(vertices=[[Integer(1),Integer(0)], [Integer(0),Integer(1)]], rays=[[Integer(1),Integer(0)], [Integer(0),Integer(1)]]), ... Polyhedron(vertices=[[Integer(1),Integer(0)], [Integer(0),-Integer(1)]], rays=[[Integer(1),Integer(0)], [Integer(0),-Integer(1)]])]) >>> pc3.boundary_subcomplex() == pc3.n_skeleton(Integer(1)) False
pc1 = PolyhedralComplex([ Polyhedron(vertices=[[1,0], [0,1]], rays=[[1,0], [0,1]])]) pc1.boundary_subcomplex() == pc1.n_skeleton(1) pc1b = PolyhedralComplex([Polyhedron( vertices=[[1,0,0], [0,1,0]], rays=[[1,0,0],[0,1,0]])]) pc1b.boundary_subcomplex() == pc1b pc2 = PolyhedralComplex([ Polyhedron(vertices=[[-1,0], [1,0]], lines=[[0,1]])]) pc2.boundary_subcomplex() == pc2.n_skeleton(1) pc3 = PolyhedralComplex([ Polyhedron(vertices=[[1,0], [0,1]], rays=[[1,0], [0,1]]), Polyhedron(vertices=[[1,0], [0,-1]], rays=[[1,0], [0,-1]])]) pc3.boundary_subcomplex() == pc3.n_skeleton(1)
- cell_iterator(increasing=True)[source]¶
An iterator for the cells in this polyhedral complex.
INPUT:
increasing
– boolean (default:True
); ifTrue
, return cells in increasing order of dimension, thus starting with the zero-dimensional cells; otherwise it returns cells in decreasing order of dimension
Note
Among the cells of a fixed dimension, there is no sorting.
EXAMPLES:
sage: pc = PolyhedralComplex([ ....: Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]), ....: Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)])]) sage: len(list(pc.cell_iterator())) 11
>>> from sage.all import * >>> pc = PolyhedralComplex([ ... Polyhedron(vertices=[(Integer(1), Integer(1)), (Integer(0), Integer(0)), (Integer(1), Integer(2))]), ... Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(0)), (Integer(0), Integer(2))])]) >>> len(list(pc.cell_iterator())) 11
pc = PolyhedralComplex([ Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]), Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)])]) len(list(pc.cell_iterator()))
- cells(subcomplex=None)[source]¶
The cells of this polyhedral complex, in the form of a dictionary: the keys are integers, representing dimension, and the value associated to an integer \(d\) is the set of \(d\)-cells.
INPUT:
subcomplex
– (optional) if a subcomplex is given then return the cells which are not in this subcomplex
EXAMPLES:
sage: pc = PolyhedralComplex([ ....: Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]), ....: Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)])]) sage: list(pc.cells().keys()) [2, 1, 0]
>>> from sage.all import * >>> pc = PolyhedralComplex([ ... Polyhedron(vertices=[(Integer(1), Integer(1)), (Integer(0), Integer(0)), (Integer(1), Integer(2))]), ... Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(0)), (Integer(0), Integer(2))])]) >>> list(pc.cells().keys()) [2, 1, 0]
pc = PolyhedralComplex([ Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]), Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)])]) list(pc.cells().keys())
- cells_sorted(subcomplex=None)[source]¶
The sorted list of the cells of this polyhedral complex in non-increasing dimensions.
INPUT:
subcomplex
– (optional) if a subcomplex is given then return the cells which are not in this subcomplex
EXAMPLES:
sage: pc = PolyhedralComplex([ ....: Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]), ....: Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)])]) sage: len(pc.cells_sorted()) 11 sage: pc.cells_sorted()[0].Vrepresentation() (A vertex at (0, 0), A vertex at (0, 2), A vertex at (1, 2))
>>> from sage.all import * >>> pc = PolyhedralComplex([ ... Polyhedron(vertices=[(Integer(1), Integer(1)), (Integer(0), Integer(0)), (Integer(1), Integer(2))]), ... Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(0)), (Integer(0), Integer(2))])]) >>> len(pc.cells_sorted()) 11 >>> pc.cells_sorted()[Integer(0)].Vrepresentation() (A vertex at (0, 0), A vertex at (0, 2), A vertex at (1, 2))
pc = PolyhedralComplex([ Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]), Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)])]) len(pc.cells_sorted()) pc.cells_sorted()[0].Vrepresentation()
- chain_complex(subcomplex=None, augmented=False, verbose=False, check=True, dimensions=None, base_ring=Integer Ring, cochain=False)[source]¶
The chain complex associated to this polyhedral complex.
Todo
Implement chain complexes of a polyhedral complex.
EXAMPLES:
sage: pc = PolyhedralComplex([Polyhedron(vertices=[[0], [1]])]) sage: pc.chain_complex() Traceback (most recent call last): ... NotImplementedError: chain_complex is not implemented for polyhedral complex
>>> from sage.all import * >>> pc = PolyhedralComplex([Polyhedron(vertices=[[Integer(0)], [Integer(1)]])]) >>> pc.chain_complex() Traceback (most recent call last): ... NotImplementedError: chain_complex is not implemented for polyhedral complex
pc = PolyhedralComplex([Polyhedron(vertices=[[0], [1]])]) pc.chain_complex()
- connected_component(cell=None)[source]¶
Return the connected component of this polyhedral complex containing a given cell.
INPUT:
cell
– (default:self.an_element()
) a cell ofself
OUTPUT:
The connected component containing
cell
. If the polyhedral complex is empty or if it does not contain the given cell, raise an error.EXAMPLES:
sage: t1 = Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]) sage: t2 = Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)]) sage: v1 = Polyhedron(vertices=[(1, 1)]) sage: v2 = Polyhedron(vertices=[(0, 2)]) sage: v3 = Polyhedron(vertices=[(-1, 0)]) sage: o = Polyhedron(vertices=[(0, 0)]) sage: r = Polyhedron(rays=[(1, 0)]) sage: l = Polyhedron(vertices=[(-1, 0)], lines=[(1, -1)]) sage: pc1 = PolyhedralComplex([t1, t2]) sage: pc1.connected_component() == pc1 True sage: pc1.connected_component(v1) == pc1 True sage: pc2 = PolyhedralComplex([t1, v2]) sage: pc2.connected_component(t1) == PolyhedralComplex([t1]) True sage: pc2.connected_component(o) == PolyhedralComplex([t1]) True sage: pc2.connected_component(v3) Traceback (most recent call last): ... ValueError: the polyhedral complex does not contain the given cell sage: pc2.connected_component(r) Traceback (most recent call last): ... ValueError: the polyhedral complex does not contain the given cell sage: pc3 = PolyhedralComplex([t1, t2, r]) sage: pc3.connected_component(v2) == pc3 True sage: pc4 = PolyhedralComplex([t1, t2, r, l]) sage: pc4.connected_component(o) == pc3 True sage: pc4.connected_component(v3) Traceback (most recent call last): ... ValueError: the polyhedral complex does not contain the given cell sage: pc5 = PolyhedralComplex([t1, t2, r, l, v3]) sage: pc5.connected_component(v3) == PolyhedralComplex([v3]) True sage: PolyhedralComplex([]).connected_component() Traceback (most recent call last): ... ValueError: the empty polyhedral complex has no connected components
>>> from sage.all import * >>> t1 = Polyhedron(vertices=[(Integer(1), Integer(1)), (Integer(0), Integer(0)), (Integer(1), Integer(2))]) >>> t2 = Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(0)), (Integer(0), Integer(2))]) >>> v1 = Polyhedron(vertices=[(Integer(1), Integer(1))]) >>> v2 = Polyhedron(vertices=[(Integer(0), Integer(2))]) >>> v3 = Polyhedron(vertices=[(-Integer(1), Integer(0))]) >>> o = Polyhedron(vertices=[(Integer(0), Integer(0))]) >>> r = Polyhedron(rays=[(Integer(1), Integer(0))]) >>> l = Polyhedron(vertices=[(-Integer(1), Integer(0))], lines=[(Integer(1), -Integer(1))]) >>> pc1 = PolyhedralComplex([t1, t2]) >>> pc1.connected_component() == pc1 True >>> pc1.connected_component(v1) == pc1 True >>> pc2 = PolyhedralComplex([t1, v2]) >>> pc2.connected_component(t1) == PolyhedralComplex([t1]) True >>> pc2.connected_component(o) == PolyhedralComplex([t1]) True >>> pc2.connected_component(v3) Traceback (most recent call last): ... ValueError: the polyhedral complex does not contain the given cell >>> pc2.connected_component(r) Traceback (most recent call last): ... ValueError: the polyhedral complex does not contain the given cell >>> pc3 = PolyhedralComplex([t1, t2, r]) >>> pc3.connected_component(v2) == pc3 True >>> pc4 = PolyhedralComplex([t1, t2, r, l]) >>> pc4.connected_component(o) == pc3 True >>> pc4.connected_component(v3) Traceback (most recent call last): ... ValueError: the polyhedral complex does not contain the given cell >>> pc5 = PolyhedralComplex([t1, t2, r, l, v3]) >>> pc5.connected_component(v3) == PolyhedralComplex([v3]) True >>> PolyhedralComplex([]).connected_component() Traceback (most recent call last): ... ValueError: the empty polyhedral complex has no connected components
t1 = Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]) t2 = Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)]) v1 = Polyhedron(vertices=[(1, 1)]) v2 = Polyhedron(vertices=[(0, 2)]) v3 = Polyhedron(vertices=[(-1, 0)]) o = Polyhedron(vertices=[(0, 0)]) r = Polyhedron(rays=[(1, 0)]) l = Polyhedron(vertices=[(-1, 0)], lines=[(1, -1)]) pc1 = PolyhedralComplex([t1, t2]) pc1.connected_component() == pc1 pc1.connected_component(v1) == pc1 pc2 = PolyhedralComplex([t1, v2]) pc2.connected_component(t1) == PolyhedralComplex([t1]) pc2.connected_component(o) == PolyhedralComplex([t1]) pc2.connected_component(v3) pc2.connected_component(r) pc3 = PolyhedralComplex([t1, t2, r]) pc3.connected_component(v2) == pc3 pc4 = PolyhedralComplex([t1, t2, r, l]) pc4.connected_component(o) == pc3 pc4.connected_component(v3) pc5 = PolyhedralComplex([t1, t2, r, l, v3]) pc5.connected_component(v3) == PolyhedralComplex([v3]) PolyhedralComplex([]).connected_component()
- connected_components()[source]¶
Return the connected components of this polyhedral complex, as list of (sub-)PolyhedralComplexes.
EXAMPLES:
sage: t1 = Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]) sage: t2 = Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)]) sage: v1 = Polyhedron(vertices=[(1, 1)]) sage: v2 = Polyhedron(vertices=[(0, 2)]) sage: v3 = Polyhedron(vertices=[(-1, 0)]) sage: o = Polyhedron(vertices=[(0, 0)]) sage: r = Polyhedron(rays=[(1, 0)]) sage: l = Polyhedron(vertices=[(-1, 0)], lines=[(1, -1)]) sage: pc1 = PolyhedralComplex([t1, t2]) sage: len(pc1.connected_components()) 1 sage: pc2 = PolyhedralComplex([t1, v2]) sage: len(pc2.connected_components()) 2 sage: pc3 = PolyhedralComplex([t1, t2, r]) sage: len(pc3.connected_components()) 1 sage: pc4 = PolyhedralComplex([t1, t2, r, l]) sage: len(pc4.connected_components()) 2 sage: pc5 = PolyhedralComplex([t1, t2, r, l, v3]) sage: len(pc5.connected_components()) 3 sage: PolyhedralComplex([]).connected_components() Traceback (most recent call last): ... ValueError: the empty polyhedral complex has no connected components
>>> from sage.all import * >>> t1 = Polyhedron(vertices=[(Integer(1), Integer(1)), (Integer(0), Integer(0)), (Integer(1), Integer(2))]) >>> t2 = Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(0)), (Integer(0), Integer(2))]) >>> v1 = Polyhedron(vertices=[(Integer(1), Integer(1))]) >>> v2 = Polyhedron(vertices=[(Integer(0), Integer(2))]) >>> v3 = Polyhedron(vertices=[(-Integer(1), Integer(0))]) >>> o = Polyhedron(vertices=[(Integer(0), Integer(0))]) >>> r = Polyhedron(rays=[(Integer(1), Integer(0))]) >>> l = Polyhedron(vertices=[(-Integer(1), Integer(0))], lines=[(Integer(1), -Integer(1))]) >>> pc1 = PolyhedralComplex([t1, t2]) >>> len(pc1.connected_components()) 1 >>> pc2 = PolyhedralComplex([t1, v2]) >>> len(pc2.connected_components()) 2 >>> pc3 = PolyhedralComplex([t1, t2, r]) >>> len(pc3.connected_components()) 1 >>> pc4 = PolyhedralComplex([t1, t2, r, l]) >>> len(pc4.connected_components()) 2 >>> pc5 = PolyhedralComplex([t1, t2, r, l, v3]) >>> len(pc5.connected_components()) 3 >>> PolyhedralComplex([]).connected_components() Traceback (most recent call last): ... ValueError: the empty polyhedral complex has no connected components
t1 = Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]) t2 = Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)]) v1 = Polyhedron(vertices=[(1, 1)]) v2 = Polyhedron(vertices=[(0, 2)]) v3 = Polyhedron(vertices=[(-1, 0)]) o = Polyhedron(vertices=[(0, 0)]) r = Polyhedron(rays=[(1, 0)]) l = Polyhedron(vertices=[(-1, 0)], lines=[(1, -1)]) pc1 = PolyhedralComplex([t1, t2]) len(pc1.connected_components()) pc2 = PolyhedralComplex([t1, v2]) len(pc2.connected_components()) pc3 = PolyhedralComplex([t1, t2, r]) len(pc3.connected_components()) pc4 = PolyhedralComplex([t1, t2, r, l]) len(pc4.connected_components()) pc5 = PolyhedralComplex([t1, t2, r, l, v3]) len(pc5.connected_components()) PolyhedralComplex([]).connected_components()
- dimension()[source]¶
The dimension of this cell complex: the maximum dimension of its cells.
EXAMPLES:
sage: pc = PolyhedralComplex([ ....: Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]), ....: Polyhedron(vertices=[(1, 2), (0, 2)]) ]) sage: pc.dimension() 2 sage: empty_pc = PolyhedralComplex([]) sage: empty_pc.dimension() -1
>>> from sage.all import * >>> pc = PolyhedralComplex([ ... Polyhedron(vertices=[(Integer(1), Integer(1)), (Integer(0), Integer(0)), (Integer(1), Integer(2))]), ... Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(2))]) ]) >>> pc.dimension() 2 >>> empty_pc = PolyhedralComplex([]) >>> empty_pc.dimension() -1
pc = PolyhedralComplex([ Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]), Polyhedron(vertices=[(1, 2), (0, 2)]) ]) pc.dimension() empty_pc = PolyhedralComplex([]) empty_pc.dimension()
- disjoint_union(right)[source]¶
The disjoint union of this polyhedral complex with another one.
INPUT:
right
– the other polyhedral complex (the right-hand factor)
EXAMPLES:
sage: p1 = Polyhedron(vertices=[(-1, 0), (0, 0), (0, 1)]) sage: p2 = Polyhedron(vertices=[(0, -1), (0, 0), (1, 0)]) sage: p3 = Polyhedron(vertices=[(0, -1), (1, -1), (1, 0)]) sage: pc = PolyhedralComplex([p1]).disjoint_union(PolyhedralComplex([p3])) sage: set(pc.maximal_cell_iterator()) == set([p1, p3]) True sage: pc.disjoint_union(PolyhedralComplex([p2])) Traceback (most recent call last): ... ValueError: the two complexes are not disjoint
>>> from sage.all import * >>> p1 = Polyhedron(vertices=[(-Integer(1), Integer(0)), (Integer(0), Integer(0)), (Integer(0), Integer(1))]) >>> p2 = Polyhedron(vertices=[(Integer(0), -Integer(1)), (Integer(0), Integer(0)), (Integer(1), Integer(0))]) >>> p3 = Polyhedron(vertices=[(Integer(0), -Integer(1)), (Integer(1), -Integer(1)), (Integer(1), Integer(0))]) >>> pc = PolyhedralComplex([p1]).disjoint_union(PolyhedralComplex([p3])) >>> set(pc.maximal_cell_iterator()) == set([p1, p3]) True >>> pc.disjoint_union(PolyhedralComplex([p2])) Traceback (most recent call last): ... ValueError: the two complexes are not disjoint
p1 = Polyhedron(vertices=[(-1, 0), (0, 0), (0, 1)]) p2 = Polyhedron(vertices=[(0, -1), (0, 0), (1, 0)]) p3 = Polyhedron(vertices=[(0, -1), (1, -1), (1, 0)]) pc = PolyhedralComplex([p1]).disjoint_union(PolyhedralComplex([p3])) set(pc.maximal_cell_iterator()) == set([p1, p3]) pc.disjoint_union(PolyhedralComplex([p2]))
- face_poset()[source]¶
The face poset of this polyhedral complex, the poset of nonempty cells, ordered by inclusion.
EXAMPLES:
sage: pc = PolyhedralComplex([ ....: Polyhedron(vertices=[(1/3, 1/3), (0, 0), (1, 2)]), ....: Polyhedron(vertices=[(1, 2), (0, 0), (0, 1/2)])]) sage: poset = pc.face_poset() sage: poset Finite poset containing 11 elements sage: d = {i: i.vertices_matrix() for i in poset} sage: poset.plot(element_labels=d) # needs sage.plot Graphics object consisting of 28 graphics primitives
>>> from sage.all import * >>> pc = PolyhedralComplex([ ... Polyhedron(vertices=[(Integer(1)/Integer(3), Integer(1)/Integer(3)), (Integer(0), Integer(0)), (Integer(1), Integer(2))]), ... Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(0)), (Integer(0), Integer(1)/Integer(2))])]) >>> poset = pc.face_poset() >>> poset Finite poset containing 11 elements >>> d = {i: i.vertices_matrix() for i in poset} >>> poset.plot(element_labels=d) # needs sage.plot Graphics object consisting of 28 graphics primitives
pc = PolyhedralComplex([ Polyhedron(vertices=[(1/3, 1/3), (0, 0), (1, 2)]), Polyhedron(vertices=[(1, 2), (0, 0), (0, 1/2)])]) poset = pc.face_poset() poset d = {i: i.vertices_matrix() for i in poset} poset.plot(element_labels=d) # needs sage.plot
For a nonbounded polyhedral complex:
sage: pc = PolyhedralComplex([ ....: Polyhedron(vertices=[(1/3, 1/3), (0, 0), (1, 2)]), ....: Polyhedron(vertices=[(1, 2), (0, 0), (0, 1/2)]), ....: Polyhedron(vertices=[(-1/2, -1/2)], lines=[(1, -1)]), ....: Polyhedron(rays=[(1, 0)])]) sage: poset = pc.face_poset() sage: poset Finite poset containing 13 elements sage: d = {i:''.join([str(v)+'\n' ....: for v in i.Vrepresentation()]) for i in poset} sage: poset.show(element_labels=d, figsize=15) # not tested sage: pc = PolyhedralComplex([ ....: Polyhedron(rays=[(1,0),(0,1)]), ....: Polyhedron(rays=[(-1,0),(0,1)]), ....: Polyhedron(rays=[(-1,0),(0,-1)]), ....: Polyhedron(rays=[(1,0),(0,-1)])]) sage: pc.face_poset() Finite poset containing 9 elements
>>> from sage.all import * >>> pc = PolyhedralComplex([ ... Polyhedron(vertices=[(Integer(1)/Integer(3), Integer(1)/Integer(3)), (Integer(0), Integer(0)), (Integer(1), Integer(2))]), ... Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(0)), (Integer(0), Integer(1)/Integer(2))]), ... Polyhedron(vertices=[(-Integer(1)/Integer(2), -Integer(1)/Integer(2))], lines=[(Integer(1), -Integer(1))]), ... Polyhedron(rays=[(Integer(1), Integer(0))])]) >>> poset = pc.face_poset() >>> poset Finite poset containing 13 elements >>> d = {i:''.join([str(v)+'\n' ... for v in i.Vrepresentation()]) for i in poset} >>> poset.show(element_labels=d, figsize=Integer(15)) # not tested >>> pc = PolyhedralComplex([ ... Polyhedron(rays=[(Integer(1),Integer(0)),(Integer(0),Integer(1))]), ... Polyhedron(rays=[(-Integer(1),Integer(0)),(Integer(0),Integer(1))]), ... Polyhedron(rays=[(-Integer(1),Integer(0)),(Integer(0),-Integer(1))]), ... Polyhedron(rays=[(Integer(1),Integer(0)),(Integer(0),-Integer(1))])]) >>> pc.face_poset() Finite poset containing 9 elements
pc = PolyhedralComplex([ Polyhedron(vertices=[(1/3, 1/3), (0, 0), (1, 2)]), Polyhedron(vertices=[(1, 2), (0, 0), (0, 1/2)]), Polyhedron(vertices=[(-1/2, -1/2)], lines=[(1, -1)]), Polyhedron(rays=[(1, 0)])]) poset = pc.face_poset() poset d = {i:''.join([str(v)+'\n' for v in i.Vrepresentation()]) for i in poset} poset.show(element_labels=d, figsize=15) # not tested pc = PolyhedralComplex([ Polyhedron(rays=[(1,0),(0,1)]), Polyhedron(rays=[(-1,0),(0,1)]), Polyhedron(rays=[(-1,0),(0,-1)]), Polyhedron(rays=[(1,0),(0,-1)])]) pc.face_poset()
- graph()[source]¶
Return the 1-skeleton of this polyhedral complex, as a graph.
The vertices of the graph are of type
vector
. This raises aNotImplementedError
if the polyhedral complex is unbounded.Warning
This may give the wrong answer if the polyhedral complex was constructed with
maximality_check
set toFalse
.EXAMPLES:
sage: pc = PolyhedralComplex([ ....: Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]), ....: Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)])]) sage: g = pc.graph(); g Graph on 4 vertices sage: g.vertices(sort=True) [(0, 0), (0, 2), (1, 1), (1, 2)] sage: g.edges(sort=True, labels=False) [((0, 0), (0, 2)), ((0, 0), (1, 1)), ((0, 0), (1, 2)), ((0, 2), (1, 2)), ((1, 1), (1, 2))] sage: PolyhedralComplex([Polyhedron(rays=[(1,1)])]).graph() Traceback (most recent call last): ... NotImplementedError: the polyhedral complex is unbounded
>>> from sage.all import * >>> pc = PolyhedralComplex([ ... Polyhedron(vertices=[(Integer(1), Integer(1)), (Integer(0), Integer(0)), (Integer(1), Integer(2))]), ... Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(0)), (Integer(0), Integer(2))])]) >>> g = pc.graph(); g Graph on 4 vertices >>> g.vertices(sort=True) [(0, 0), (0, 2), (1, 1), (1, 2)] >>> g.edges(sort=True, labels=False) [((0, 0), (0, 2)), ((0, 0), (1, 1)), ((0, 0), (1, 2)), ((0, 2), (1, 2)), ((1, 1), (1, 2))] >>> PolyhedralComplex([Polyhedron(rays=[(Integer(1),Integer(1))])]).graph() Traceback (most recent call last): ... NotImplementedError: the polyhedral complex is unbounded
pc = PolyhedralComplex([ Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]), Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)])]) g = pc.graph(); g g.vertices(sort=True) g.edges(sort=True, labels=False) PolyhedralComplex([Polyhedron(rays=[(1,1)])]).graph()
Wrong answer due to
maximality_check=False
:sage: p1 = Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]) sage: p2 = Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)]) sage: p3 = Polyhedron(vertices=[(1, 2), (0, 2)]) sage: PolyhedralComplex([p1, p2]).is_pure() True sage: PolyhedralComplex([p2, p3], maximality_check=True).is_pure() True sage: PolyhedralComplex([p2, p3], maximality_check=False).is_pure() False
>>> from sage.all import * >>> p1 = Polyhedron(vertices=[(Integer(1), Integer(1)), (Integer(0), Integer(0)), (Integer(1), Integer(2))]) >>> p2 = Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(0)), (Integer(0), Integer(2))]) >>> p3 = Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(2))]) >>> PolyhedralComplex([p1, p2]).is_pure() True >>> PolyhedralComplex([p2, p3], maximality_check=True).is_pure() True >>> PolyhedralComplex([p2, p3], maximality_check=False).is_pure() False
p1 = Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]) p2 = Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)]) p3 = Polyhedron(vertices=[(1, 2), (0, 2)]) PolyhedralComplex([p1, p2]).is_pure() PolyhedralComplex([p2, p3], maximality_check=True).is_pure() PolyhedralComplex([p2, p3], maximality_check=False).is_pure()
- is_cell(c)[source]¶
Return whether the given cell
c
is a cell ofself
.EXAMPLES:
sage: p1 = Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]) sage: p2 = Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)]) sage: p3 = Polyhedron(vertices=[(1, 2), (0, 2)]) sage: pc = PolyhedralComplex([p1, p2]) sage: pc.is_cell(p3) True sage: pc.is_cell(Polyhedron(vertices=[(0, 0)])) True
>>> from sage.all import * >>> p1 = Polyhedron(vertices=[(Integer(1), Integer(1)), (Integer(0), Integer(0)), (Integer(1), Integer(2))]) >>> p2 = Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(0)), (Integer(0), Integer(2))]) >>> p3 = Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(2))]) >>> pc = PolyhedralComplex([p1, p2]) >>> pc.is_cell(p3) True >>> pc.is_cell(Polyhedron(vertices=[(Integer(0), Integer(0))])) True
p1 = Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]) p2 = Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)]) p3 = Polyhedron(vertices=[(1, 2), (0, 2)]) pc = PolyhedralComplex([p1, p2]) pc.is_cell(p3) pc.is_cell(Polyhedron(vertices=[(0, 0)]))
- is_compact()[source]¶
Test for boundedness of the polyhedral complex.
EXAMPLES:
sage: p1 = Polyhedron(vertices=[(1, 2), (0, 0), (0, 1/2)]) sage: p2 = Polyhedron(rays=[(1, 0)]) sage: PolyhedralComplex([p1]).is_compact() True sage: PolyhedralComplex([p1, p2]).is_compact() False
>>> from sage.all import * >>> p1 = Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(0)), (Integer(0), Integer(1)/Integer(2))]) >>> p2 = Polyhedron(rays=[(Integer(1), Integer(0))]) >>> PolyhedralComplex([p1]).is_compact() True >>> PolyhedralComplex([p1, p2]).is_compact() False
p1 = Polyhedron(vertices=[(1, 2), (0, 0), (0, 1/2)]) p2 = Polyhedron(rays=[(1, 0)]) PolyhedralComplex([p1]).is_compact() PolyhedralComplex([p1, p2]).is_compact()
- is_connected()[source]¶
Return whether
self
is connected.EXAMPLES:
sage: pc1 = PolyhedralComplex([ ....: Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]), ....: Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)])]) sage: pc1.is_connected() True sage: pc2 = PolyhedralComplex([ ....: Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]), ....: Polyhedron(vertices=[(0, 2)])]) sage: pc2.is_connected() False sage: pc3 = PolyhedralComplex([ ....: Polyhedron(vertices=[(1/3, 1/3), (0, 0), (1, 2)]), ....: Polyhedron(vertices=[(1, 2), (0, 0), (0, 1/2)]), ....: Polyhedron(vertices=[(-1/2, -1/2)], lines=[(1, -1)]), ....: Polyhedron(rays=[(1, 0)])]) sage: pc3.is_connected() False sage: pc4 = PolyhedralComplex([ ....: Polyhedron(vertices=[(1/3, 1/3), (0, 0), (1, 2)]), ....: Polyhedron(rays=[(1, 0)])]) sage: pc4.is_connected() True
>>> from sage.all import * >>> pc1 = PolyhedralComplex([ ... Polyhedron(vertices=[(Integer(1), Integer(1)), (Integer(0), Integer(0)), (Integer(1), Integer(2))]), ... Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(0)), (Integer(0), Integer(2))])]) >>> pc1.is_connected() True >>> pc2 = PolyhedralComplex([ ... Polyhedron(vertices=[(Integer(1), Integer(1)), (Integer(0), Integer(0)), (Integer(1), Integer(2))]), ... Polyhedron(vertices=[(Integer(0), Integer(2))])]) >>> pc2.is_connected() False >>> pc3 = PolyhedralComplex([ ... Polyhedron(vertices=[(Integer(1)/Integer(3), Integer(1)/Integer(3)), (Integer(0), Integer(0)), (Integer(1), Integer(2))]), ... Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(0)), (Integer(0), Integer(1)/Integer(2))]), ... Polyhedron(vertices=[(-Integer(1)/Integer(2), -Integer(1)/Integer(2))], lines=[(Integer(1), -Integer(1))]), ... Polyhedron(rays=[(Integer(1), Integer(0))])]) >>> pc3.is_connected() False >>> pc4 = PolyhedralComplex([ ... Polyhedron(vertices=[(Integer(1)/Integer(3), Integer(1)/Integer(3)), (Integer(0), Integer(0)), (Integer(1), Integer(2))]), ... Polyhedron(rays=[(Integer(1), Integer(0))])]) >>> pc4.is_connected() True
pc1 = PolyhedralComplex([ Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]), Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)])]) pc1.is_connected() pc2 = PolyhedralComplex([ Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]), Polyhedron(vertices=[(0, 2)])]) pc2.is_connected() pc3 = PolyhedralComplex([ Polyhedron(vertices=[(1/3, 1/3), (0, 0), (1, 2)]), Polyhedron(vertices=[(1, 2), (0, 0), (0, 1/2)]), Polyhedron(vertices=[(-1/2, -1/2)], lines=[(1, -1)]), Polyhedron(rays=[(1, 0)])]) pc3.is_connected() pc4 = PolyhedralComplex([ Polyhedron(vertices=[(1/3, 1/3), (0, 0), (1, 2)]), Polyhedron(rays=[(1, 0)])]) pc4.is_connected()
- is_convex()[source]¶
Return whether the set of points in
self
is a convex set.When
self
is convex, the union of its cells is a Polyhedron.See also
EXAMPLES:
sage: p1 = Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]) sage: p2 = Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)]) sage: p3 = Polyhedron(vertices=[(0, 0), (1, 1), (2, 0)]) sage: p4 = Polyhedron(vertices=[(2, 2)]) sage: PolyhedralComplex([p1, p2]).is_convex() True sage: PolyhedralComplex([p1, p3]).is_convex() False sage: PolyhedralComplex([p1, p4]).is_convex() False
>>> from sage.all import * >>> p1 = Polyhedron(vertices=[(Integer(1), Integer(1)), (Integer(0), Integer(0)), (Integer(1), Integer(2))]) >>> p2 = Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(0)), (Integer(0), Integer(2))]) >>> p3 = Polyhedron(vertices=[(Integer(0), Integer(0)), (Integer(1), Integer(1)), (Integer(2), Integer(0))]) >>> p4 = Polyhedron(vertices=[(Integer(2), Integer(2))]) >>> PolyhedralComplex([p1, p2]).is_convex() True >>> PolyhedralComplex([p1, p3]).is_convex() False >>> PolyhedralComplex([p1, p4]).is_convex() False
p1 = Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]) p2 = Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)]) p3 = Polyhedron(vertices=[(0, 0), (1, 1), (2, 0)]) p4 = Polyhedron(vertices=[(2, 2)]) PolyhedralComplex([p1, p2]).is_convex() PolyhedralComplex([p1, p3]).is_convex() PolyhedralComplex([p1, p4]).is_convex()
Test unbounded cases:
sage: pc1 = PolyhedralComplex([ ....: Polyhedron(vertices=[[1,0], [0,1]], rays=[[1,0], [0,1]])]) sage: pc1.is_convex() True sage: pc2 = PolyhedralComplex([ ....: Polyhedron(vertices=[[-1,0], [1,0]], lines=[[0,1]])]) sage: pc2.is_convex() True sage: pc3 = PolyhedralComplex([ ....: Polyhedron(vertices=[[1,0], [0,1]], rays=[[1,0], [0,1]]), ....: Polyhedron(vertices=[[1,0], [0,-1]], rays=[[1,0], [0,-1]])]) sage: pc3.is_convex() False sage: pc4 = PolyhedralComplex([Polyhedron(rays=[[1,0], [-1,1]]), ....: Polyhedron(rays=[[1,0], [-1,-1]])]) sage: pc4.is_convex() False
>>> from sage.all import * >>> pc1 = PolyhedralComplex([ ... Polyhedron(vertices=[[Integer(1),Integer(0)], [Integer(0),Integer(1)]], rays=[[Integer(1),Integer(0)], [Integer(0),Integer(1)]])]) >>> pc1.is_convex() True >>> pc2 = PolyhedralComplex([ ... Polyhedron(vertices=[[-Integer(1),Integer(0)], [Integer(1),Integer(0)]], lines=[[Integer(0),Integer(1)]])]) >>> pc2.is_convex() True >>> pc3 = PolyhedralComplex([ ... Polyhedron(vertices=[[Integer(1),Integer(0)], [Integer(0),Integer(1)]], rays=[[Integer(1),Integer(0)], [Integer(0),Integer(1)]]), ... Polyhedron(vertices=[[Integer(1),Integer(0)], [Integer(0),-Integer(1)]], rays=[[Integer(1),Integer(0)], [Integer(0),-Integer(1)]])]) >>> pc3.is_convex() False >>> pc4 = PolyhedralComplex([Polyhedron(rays=[[Integer(1),Integer(0)], [-Integer(1),Integer(1)]]), ... Polyhedron(rays=[[Integer(1),Integer(0)], [-Integer(1),-Integer(1)]])]) >>> pc4.is_convex() False
pc1 = PolyhedralComplex([ Polyhedron(vertices=[[1,0], [0,1]], rays=[[1,0], [0,1]])]) pc1.is_convex() pc2 = PolyhedralComplex([ Polyhedron(vertices=[[-1,0], [1,0]], lines=[[0,1]])]) pc2.is_convex() pc3 = PolyhedralComplex([ Polyhedron(vertices=[[1,0], [0,1]], rays=[[1,0], [0,1]]), Polyhedron(vertices=[[1,0], [0,-1]], rays=[[1,0], [0,-1]])]) pc3.is_convex() pc4 = PolyhedralComplex([Polyhedron(rays=[[1,0], [-1,1]]), Polyhedron(rays=[[1,0], [-1,-1]])]) pc4.is_convex()
The whole 3d space minus the first orthant is not convex:
sage: pc5 = PolyhedralComplex([ ....: Polyhedron(rays=[[1,0,0], [0,1,0], [0,0,-1]]), ....: Polyhedron(rays=[[1,0,0], [0,-1,0], [0,0,-1]]), ....: Polyhedron(rays=[[1,0,0], [0,-1,0], [0,0,1]]), ....: Polyhedron(rays=[[-1,0,0], [0,-1,0], [0,0,-1]]), ....: Polyhedron(rays=[[-1,0,0], [0,-1,0], [0,0,1]]), ....: Polyhedron(rays=[[-1,0,0], [0,1,0], [0,0,-1]]), ....: Polyhedron(rays=[[-1,0,0], [0,1,0], [0,0,1]])]) sage: pc5.is_convex() False
>>> from sage.all import * >>> pc5 = PolyhedralComplex([ ... Polyhedron(rays=[[Integer(1),Integer(0),Integer(0)], [Integer(0),Integer(1),Integer(0)], [Integer(0),Integer(0),-Integer(1)]]), ... Polyhedron(rays=[[Integer(1),Integer(0),Integer(0)], [Integer(0),-Integer(1),Integer(0)], [Integer(0),Integer(0),-Integer(1)]]), ... Polyhedron(rays=[[Integer(1),Integer(0),Integer(0)], [Integer(0),-Integer(1),Integer(0)], [Integer(0),Integer(0),Integer(1)]]), ... Polyhedron(rays=[[-Integer(1),Integer(0),Integer(0)], [Integer(0),-Integer(1),Integer(0)], [Integer(0),Integer(0),-Integer(1)]]), ... Polyhedron(rays=[[-Integer(1),Integer(0),Integer(0)], [Integer(0),-Integer(1),Integer(0)], [Integer(0),Integer(0),Integer(1)]]), ... Polyhedron(rays=[[-Integer(1),Integer(0),Integer(0)], [Integer(0),Integer(1),Integer(0)], [Integer(0),Integer(0),-Integer(1)]]), ... Polyhedron(rays=[[-Integer(1),Integer(0),Integer(0)], [Integer(0),Integer(1),Integer(0)], [Integer(0),Integer(0),Integer(1)]])]) >>> pc5.is_convex() False
pc5 = PolyhedralComplex([ Polyhedron(rays=[[1,0,0], [0,1,0], [0,0,-1]]), Polyhedron(rays=[[1,0,0], [0,-1,0], [0,0,-1]]), Polyhedron(rays=[[1,0,0], [0,-1,0], [0,0,1]]), Polyhedron(rays=[[-1,0,0], [0,-1,0], [0,0,-1]]), Polyhedron(rays=[[-1,0,0], [0,-1,0], [0,0,1]]), Polyhedron(rays=[[-1,0,0], [0,1,0], [0,0,-1]]), Polyhedron(rays=[[-1,0,0], [0,1,0], [0,0,1]])]) pc5.is_convex()
Test some non-full-dimensional examples:
sage: l = PolyhedralComplex([Polyhedron(vertices=[(1, 2), (0, 2)])]) sage: l.is_convex() True sage: pc1b = PolyhedralComplex([Polyhedron( ....: vertices=[[1,0,0], [0,1,0]], rays=[[1,0,0],[0,1,0]])]) sage: pc1b.is_convex() True sage: pc4b = PolyhedralComplex([ ....: Polyhedron(rays=[[1,0,0], [-1,1,0]]), ....: Polyhedron(rays=[[1,0,0], [-1,-1,0]])]) sage: pc4b.is_convex() False
>>> from sage.all import * >>> l = PolyhedralComplex([Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(2))])]) >>> l.is_convex() True >>> pc1b = PolyhedralComplex([Polyhedron( ... vertices=[[Integer(1),Integer(0),Integer(0)], [Integer(0),Integer(1),Integer(0)]], rays=[[Integer(1),Integer(0),Integer(0)],[Integer(0),Integer(1),Integer(0)]])]) >>> pc1b.is_convex() True >>> pc4b = PolyhedralComplex([ ... Polyhedron(rays=[[Integer(1),Integer(0),Integer(0)], [-Integer(1),Integer(1),Integer(0)]]), ... Polyhedron(rays=[[Integer(1),Integer(0),Integer(0)], [-Integer(1),-Integer(1),Integer(0)]])]) >>> pc4b.is_convex() False
l = PolyhedralComplex([Polyhedron(vertices=[(1, 2), (0, 2)])]) l.is_convex() pc1b = PolyhedralComplex([Polyhedron( vertices=[[1,0,0], [0,1,0]], rays=[[1,0,0],[0,1,0]])]) pc1b.is_convex() pc4b = PolyhedralComplex([ Polyhedron(rays=[[1,0,0], [-1,1,0]]), Polyhedron(rays=[[1,0,0], [-1,-1,0]])]) pc4b.is_convex()
- is_full_dimensional()[source]¶
Return whether this polyhedral complex is full-dimensional: its dimension is equal to its ambient dimension.
EXAMPLES:
sage: p1 = Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]) sage: p2 = Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)]) sage: p3 = Polyhedron(vertices=[(1, 2), (0, 2)]) sage: pc = PolyhedralComplex([p1, p2, p3]) sage: pc.is_full_dimensional() True sage: PolyhedralComplex([p3]).is_full_dimensional() False
>>> from sage.all import * >>> p1 = Polyhedron(vertices=[(Integer(1), Integer(1)), (Integer(0), Integer(0)), (Integer(1), Integer(2))]) >>> p2 = Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(0)), (Integer(0), Integer(2))]) >>> p3 = Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(2))]) >>> pc = PolyhedralComplex([p1, p2, p3]) >>> pc.is_full_dimensional() True >>> PolyhedralComplex([p3]).is_full_dimensional() False
p1 = Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]) p2 = Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)]) p3 = Polyhedron(vertices=[(1, 2), (0, 2)]) pc = PolyhedralComplex([p1, p2, p3]) pc.is_full_dimensional() PolyhedralComplex([p3]).is_full_dimensional()
- is_immutable()[source]¶
Return whether
self
is immutable.EXAMPLES:
sage: pc1 = PolyhedralComplex([Polyhedron(vertices=[[0], [1]])]) sage: pc1.is_immutable() False sage: pc2 = PolyhedralComplex([Polyhedron(vertices=[[0], [1]])], ....: is_mutable=False) sage: pc2.is_immutable() True sage: pc3 = PolyhedralComplex([Polyhedron(vertices=[[0], [1]])], ....: is_immutable=True) sage: pc3.is_immutable() True
>>> from sage.all import * >>> pc1 = PolyhedralComplex([Polyhedron(vertices=[[Integer(0)], [Integer(1)]])]) >>> pc1.is_immutable() False >>> pc2 = PolyhedralComplex([Polyhedron(vertices=[[Integer(0)], [Integer(1)]])], ... is_mutable=False) >>> pc2.is_immutable() True >>> pc3 = PolyhedralComplex([Polyhedron(vertices=[[Integer(0)], [Integer(1)]])], ... is_immutable=True) >>> pc3.is_immutable() True
pc1 = PolyhedralComplex([Polyhedron(vertices=[[0], [1]])]) pc1.is_immutable() pc2 = PolyhedralComplex([Polyhedron(vertices=[[0], [1]])], is_mutable=False) pc2.is_immutable() pc3 = PolyhedralComplex([Polyhedron(vertices=[[0], [1]])], is_immutable=True) pc3.is_immutable()
- is_maximal_cell(c)[source]¶
Return whether the given cell
c
is a maximal cell ofself
.Warning
This may give the wrong answer if the polyhedral complex was constructed with
maximality_check
set toFalse
.EXAMPLES:
sage: p1 = Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]) sage: p2 = Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)]) sage: p3 = Polyhedron(vertices=[(1, 2), (0, 2)]) sage: pc = PolyhedralComplex([p1, p2, p3]) sage: pc.is_maximal_cell(p1) True sage: pc.is_maximal_cell(p3) False
>>> from sage.all import * >>> p1 = Polyhedron(vertices=[(Integer(1), Integer(1)), (Integer(0), Integer(0)), (Integer(1), Integer(2))]) >>> p2 = Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(0)), (Integer(0), Integer(2))]) >>> p3 = Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(2))]) >>> pc = PolyhedralComplex([p1, p2, p3]) >>> pc.is_maximal_cell(p1) True >>> pc.is_maximal_cell(p3) False
p1 = Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]) p2 = Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)]) p3 = Polyhedron(vertices=[(1, 2), (0, 2)]) pc = PolyhedralComplex([p1, p2, p3]) pc.is_maximal_cell(p1) pc.is_maximal_cell(p3)
Wrong answer due to
maximality_check=False
:sage: pc_invalid = PolyhedralComplex([p1, p2, p3], ....: maximality_check=False) sage: pc_invalid.is_maximal_cell(p3) True
>>> from sage.all import * >>> pc_invalid = PolyhedralComplex([p1, p2, p3], ... maximality_check=False) >>> pc_invalid.is_maximal_cell(p3) True
pc_invalid = PolyhedralComplex([p1, p2, p3], maximality_check=False) pc_invalid.is_maximal_cell(p3)
- is_mutable()[source]¶
Return whether
self
is mutable.EXAMPLES:
sage: pc1 = PolyhedralComplex([Polyhedron(vertices=[[0], [1]])]) sage: pc1.is_mutable() True sage: pc2 = PolyhedralComplex([Polyhedron(vertices=[[0], [1]])], ....: is_mutable=False) sage: pc2.is_mutable() False sage: pc1 == pc2 True sage: pc3 = PolyhedralComplex([Polyhedron(vertices=[[0], [1]])], ....: is_immutable=True) sage: pc3.is_mutable() False sage: pc2 == pc3 True
>>> from sage.all import * >>> pc1 = PolyhedralComplex([Polyhedron(vertices=[[Integer(0)], [Integer(1)]])]) >>> pc1.is_mutable() True >>> pc2 = PolyhedralComplex([Polyhedron(vertices=[[Integer(0)], [Integer(1)]])], ... is_mutable=False) >>> pc2.is_mutable() False >>> pc1 == pc2 True >>> pc3 = PolyhedralComplex([Polyhedron(vertices=[[Integer(0)], [Integer(1)]])], ... is_immutable=True) >>> pc3.is_mutable() False >>> pc2 == pc3 True
pc1 = PolyhedralComplex([Polyhedron(vertices=[[0], [1]])]) pc1.is_mutable() pc2 = PolyhedralComplex([Polyhedron(vertices=[[0], [1]])], is_mutable=False) pc2.is_mutable() pc1 == pc2 pc3 = PolyhedralComplex([Polyhedron(vertices=[[0], [1]])], is_immutable=True) pc3.is_mutable() pc2 == pc3
- is_polyhedral_fan()[source]¶
Test if this polyhedral complex is a polyhedral fan.
A polyhedral complex is a fan if all of its (maximal) cells are cones.
EXAMPLES:
sage: p1 = Polyhedron(vertices=[(0, 0), (1, 1), (1, 2)]) sage: p2 = Polyhedron(rays=[(1, 0)]) sage: PolyhedralComplex([p1]).is_polyhedral_fan() False sage: PolyhedralComplex([p2]).is_polyhedral_fan() True sage: halfplane = Polyhedron(rays=[(1, 0), (-1, 0), (0, 1)]) sage: PolyhedralComplex([halfplane]).is_polyhedral_fan() True
>>> from sage.all import * >>> p1 = Polyhedron(vertices=[(Integer(0), Integer(0)), (Integer(1), Integer(1)), (Integer(1), Integer(2))]) >>> p2 = Polyhedron(rays=[(Integer(1), Integer(0))]) >>> PolyhedralComplex([p1]).is_polyhedral_fan() False >>> PolyhedralComplex([p2]).is_polyhedral_fan() True >>> halfplane = Polyhedron(rays=[(Integer(1), Integer(0)), (-Integer(1), Integer(0)), (Integer(0), Integer(1))]) >>> PolyhedralComplex([halfplane]).is_polyhedral_fan() True
p1 = Polyhedron(vertices=[(0, 0), (1, 1), (1, 2)]) p2 = Polyhedron(rays=[(1, 0)]) PolyhedralComplex([p1]).is_polyhedral_fan() PolyhedralComplex([p2]).is_polyhedral_fan() halfplane = Polyhedron(rays=[(1, 0), (-1, 0), (0, 1)]) PolyhedralComplex([halfplane]).is_polyhedral_fan()
- is_pure()[source]¶
Test if this polyhedral complex is pure.
A polyhedral complex is pure if and only if all of its maximal cells have the same dimension.
Warning
This may give the wrong answer if the polyhedral complex was constructed with
maximality_check
set toFalse
.EXAMPLES:
sage: p1 = Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]) sage: p2 = Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)]) sage: p3 = Polyhedron(vertices=[(1, 2), (0, 2)]) sage: pc = PolyhedralComplex([p1, p2, p3]) sage: pc.is_pure() True
>>> from sage.all import * >>> p1 = Polyhedron(vertices=[(Integer(1), Integer(1)), (Integer(0), Integer(0)), (Integer(1), Integer(2))]) >>> p2 = Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(0)), (Integer(0), Integer(2))]) >>> p3 = Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(2))]) >>> pc = PolyhedralComplex([p1, p2, p3]) >>> pc.is_pure() True
p1 = Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]) p2 = Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)]) p3 = Polyhedron(vertices=[(1, 2), (0, 2)]) pc = PolyhedralComplex([p1, p2, p3]) pc.is_pure()
Wrong answer due to
maximality_check=False
:sage: pc_invalid = PolyhedralComplex([p1, p2, p3], ....: maximality_check=False) sage: pc_invalid.is_pure() False
>>> from sage.all import * >>> pc_invalid = PolyhedralComplex([p1, p2, p3], ... maximality_check=False) >>> pc_invalid.is_pure() False
pc_invalid = PolyhedralComplex([p1, p2, p3], maximality_check=False) pc_invalid.is_pure()
- is_simplicial_complex()[source]¶
Test if this polyhedral complex is a simplicial complex.
A polyhedral complex is simplicial if all of its (maximal) cells are simplices, i.e., every cell is a bounded polytope with \(d+1\) vertices, where \(d\) is the dimension of the polytope.
EXAMPLES:
sage: p1 = Polyhedron(vertices=[(0, 0), (1, 1), (1, 2)]) sage: p2 = Polyhedron(rays=[(1, 0)]) sage: PolyhedralComplex([p1]).is_simplicial_complex() True sage: PolyhedralComplex([p2]).is_simplicial_complex() False
>>> from sage.all import * >>> p1 = Polyhedron(vertices=[(Integer(0), Integer(0)), (Integer(1), Integer(1)), (Integer(1), Integer(2))]) >>> p2 = Polyhedron(rays=[(Integer(1), Integer(0))]) >>> PolyhedralComplex([p1]).is_simplicial_complex() True >>> PolyhedralComplex([p2]).is_simplicial_complex() False
p1 = Polyhedron(vertices=[(0, 0), (1, 1), (1, 2)]) p2 = Polyhedron(rays=[(1, 0)]) PolyhedralComplex([p1]).is_simplicial_complex() PolyhedralComplex([p2]).is_simplicial_complex()
- is_simplicial_fan()[source]¶
Test if this polyhedral complex is a simplicial fan.
A polyhedral complex is a simplicial fan if all of its (maximal) cells are simplical cones, i.e., every cell is a pointed cone (with vertex being the origin) generated by \(d\) linearly independent rays, where \(d\) is the dimension of the cone.
EXAMPLES:
sage: p1 = Polyhedron(vertices=[(0, 0), (1, 1), (1, 2)]) sage: p2 = Polyhedron(rays=[(1, 0)]) sage: PolyhedralComplex([p1]).is_simplicial_fan() False sage: PolyhedralComplex([p2]).is_simplicial_fan() True sage: halfplane = Polyhedron(rays=[(1, 0), (-1, 0), (0, 1)]) sage: PolyhedralComplex([halfplane]).is_simplicial_fan() False
>>> from sage.all import * >>> p1 = Polyhedron(vertices=[(Integer(0), Integer(0)), (Integer(1), Integer(1)), (Integer(1), Integer(2))]) >>> p2 = Polyhedron(rays=[(Integer(1), Integer(0))]) >>> PolyhedralComplex([p1]).is_simplicial_fan() False >>> PolyhedralComplex([p2]).is_simplicial_fan() True >>> halfplane = Polyhedron(rays=[(Integer(1), Integer(0)), (-Integer(1), Integer(0)), (Integer(0), Integer(1))]) >>> PolyhedralComplex([halfplane]).is_simplicial_fan() False
p1 = Polyhedron(vertices=[(0, 0), (1, 1), (1, 2)]) p2 = Polyhedron(rays=[(1, 0)]) PolyhedralComplex([p1]).is_simplicial_fan() PolyhedralComplex([p2]).is_simplicial_fan() halfplane = Polyhedron(rays=[(1, 0), (-1, 0), (0, 1)]) PolyhedralComplex([halfplane]).is_simplicial_fan()
- is_subcomplex(other)[source]¶
Return whether
self
is a subcomplex ofother
.INPUT:
other
– a polyhedral complex
Each maximal cell of
self
must be a cell ofother
for this to beTrue
.EXAMPLES:
sage: p1 = Polyhedron(vertices=[(1/3, 1/3), (0, 0), (1, 2)]) sage: p2 = Polyhedron(vertices=[(1, 2), (0, 0), (0, 1/2)]) sage: p3 = Polyhedron(vertices=[(0, 0), (1, 0)]) sage: pc = PolyhedralComplex([p1, Polyhedron(vertices=[(1, 0)])]) sage: pc.is_subcomplex(PolyhedralComplex([p1, p2, p3])) True sage: pc.is_subcomplex(PolyhedralComplex([p1, p2])) False
>>> from sage.all import * >>> p1 = Polyhedron(vertices=[(Integer(1)/Integer(3), Integer(1)/Integer(3)), (Integer(0), Integer(0)), (Integer(1), Integer(2))]) >>> p2 = Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(0)), (Integer(0), Integer(1)/Integer(2))]) >>> p3 = Polyhedron(vertices=[(Integer(0), Integer(0)), (Integer(1), Integer(0))]) >>> pc = PolyhedralComplex([p1, Polyhedron(vertices=[(Integer(1), Integer(0))])]) >>> pc.is_subcomplex(PolyhedralComplex([p1, p2, p3])) True >>> pc.is_subcomplex(PolyhedralComplex([p1, p2])) False
p1 = Polyhedron(vertices=[(1/3, 1/3), (0, 0), (1, 2)]) p2 = Polyhedron(vertices=[(1, 2), (0, 0), (0, 1/2)]) p3 = Polyhedron(vertices=[(0, 0), (1, 0)]) pc = PolyhedralComplex([p1, Polyhedron(vertices=[(1, 0)])]) pc.is_subcomplex(PolyhedralComplex([p1, p2, p3])) pc.is_subcomplex(PolyhedralComplex([p1, p2]))
- join(right)[source]¶
The join of this polyhedral complex with another one.
INPUT:
right
– the other polyhedral complex (the right-hand factor)
EXAMPLES:
sage: pc = PolyhedralComplex([Polyhedron(vertices=[[0], [1]])]) sage: pc_join = pc.join(pc) sage: pc_join Polyhedral complex with 1 maximal cell sage: next(pc_join.maximal_cell_iterator()).vertices() (A vertex at (0, 0, 0), A vertex at (0, 0, 1), A vertex at (0, 1, 1), A vertex at (1, 0, 0))
>>> from sage.all import * >>> pc = PolyhedralComplex([Polyhedron(vertices=[[Integer(0)], [Integer(1)]])]) >>> pc_join = pc.join(pc) >>> pc_join Polyhedral complex with 1 maximal cell >>> next(pc_join.maximal_cell_iterator()).vertices() (A vertex at (0, 0, 0), A vertex at (0, 0, 1), A vertex at (0, 1, 1), A vertex at (1, 0, 0))
pc = PolyhedralComplex([Polyhedron(vertices=[[0], [1]])]) pc_join = pc.join(pc) pc_join next(pc_join.maximal_cell_iterator()).vertices()
- maximal_cell_iterator(increasing=False)[source]¶
An iterator for the maximal cells in this polyhedral complex.
INPUT:
increasing
– boolean (default:False
); ifTrue
, return maximal cells in increasing order of dimension. Otherwise it returns cells in decreasing order of dimension.
Note
Among the cells of a fixed dimension, there is no sorting.
Warning
This may give the wrong answer if the polyhedral complex was constructed with
maximality_check
set toFalse
.EXAMPLES:
sage: p1 = Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]) sage: p2 = Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)]) sage: p3 = Polyhedron(vertices=[(1, 2), (0, 2)]) sage: pc = PolyhedralComplex([p1, p2, p3]) sage: len(list(pc.maximal_cell_iterator())) 2
>>> from sage.all import * >>> p1 = Polyhedron(vertices=[(Integer(1), Integer(1)), (Integer(0), Integer(0)), (Integer(1), Integer(2))]) >>> p2 = Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(0)), (Integer(0), Integer(2))]) >>> p3 = Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(2))]) >>> pc = PolyhedralComplex([p1, p2, p3]) >>> len(list(pc.maximal_cell_iterator())) 2
p1 = Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]) p2 = Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)]) p3 = Polyhedron(vertices=[(1, 2), (0, 2)]) pc = PolyhedralComplex([p1, p2, p3]) len(list(pc.maximal_cell_iterator()))
Wrong answer due to
maximality_check=False
:sage: pc_invalid = PolyhedralComplex([p1, p2, p3], ....: maximality_check=False) sage: len(list(pc_invalid.maximal_cell_iterator())) 3
>>> from sage.all import * >>> pc_invalid = PolyhedralComplex([p1, p2, p3], ... maximality_check=False) >>> len(list(pc_invalid.maximal_cell_iterator())) 3
pc_invalid = PolyhedralComplex([p1, p2, p3], maximality_check=False) len(list(pc_invalid.maximal_cell_iterator()))
- maximal_cells()[source]¶
The maximal cells of this polyhedral complex, in the form of a dictionary: the keys are integers, representing dimension, and the value associated to an integer \(d\) is the set of \(d\)-maximal cells.
Warning
This may give the wrong answer if the polyhedral complex was constructed with
maximality_check
set toFalse
.EXAMPLES:
sage: p1 = Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]) sage: p2 = Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)]) sage: p3 = Polyhedron(vertices=[(1, 2), (0, 2)]) sage: pc = PolyhedralComplex([p1, p2, p3]) sage: len(pc.maximal_cells()[2]) 2 sage: 1 in pc.maximal_cells() False
>>> from sage.all import * >>> p1 = Polyhedron(vertices=[(Integer(1), Integer(1)), (Integer(0), Integer(0)), (Integer(1), Integer(2))]) >>> p2 = Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(0)), (Integer(0), Integer(2))]) >>> p3 = Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(2))]) >>> pc = PolyhedralComplex([p1, p2, p3]) >>> len(pc.maximal_cells()[Integer(2)]) 2 >>> Integer(1) in pc.maximal_cells() False
p1 = Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]) p2 = Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)]) p3 = Polyhedron(vertices=[(1, 2), (0, 2)]) pc = PolyhedralComplex([p1, p2, p3]) len(pc.maximal_cells()[2]) 1 in pc.maximal_cells()
Wrong answer due to
maximality_check=False
:sage: pc_invalid = PolyhedralComplex([p1, p2, p3], ....: maximality_check=False) sage: len(pc_invalid.maximal_cells()[1]) 1
>>> from sage.all import * >>> pc_invalid = PolyhedralComplex([p1, p2, p3], ... maximality_check=False) >>> len(pc_invalid.maximal_cells()[Integer(1)]) 1
pc_invalid = PolyhedralComplex([p1, p2, p3], maximality_check=False) len(pc_invalid.maximal_cells()[1])
- maximal_cells_sorted()[source]¶
Return the sorted list of the maximal cells of this polyhedral complex by non-increasing dimensions.
EXAMPLES:
sage: pc = PolyhedralComplex([ ....: Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]), ....: Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)])]) sage: [p.vertices_list() for p in pc.maximal_cells_sorted()] [[[0, 0], [0, 2], [1, 2]], [[0, 0], [1, 1], [1, 2]]]
>>> from sage.all import * >>> pc = PolyhedralComplex([ ... Polyhedron(vertices=[(Integer(1), Integer(1)), (Integer(0), Integer(0)), (Integer(1), Integer(2))]), ... Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(0)), (Integer(0), Integer(2))])]) >>> [p.vertices_list() for p in pc.maximal_cells_sorted()] [[[0, 0], [0, 2], [1, 2]], [[0, 0], [1, 1], [1, 2]]]
pc = PolyhedralComplex([ Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]), Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)])]) [p.vertices_list() for p in pc.maximal_cells_sorted()]
- n_maximal_cells(n)[source]¶
List of maximal cells of dimension
n
of this polyhedral complex.INPUT:
n
– nonnegative integer; the dimension
Note
The resulting list need not be sorted. If you want a sorted list of \(n\)-cells, use
_n_maximal_cells_sorted()
.Warning
This may give the wrong answer if the polyhedral complex was constructed with
maximality_check
set toFalse
.EXAMPLES:
sage: p1 = Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]) sage: p2 = Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)]) sage: p3 = Polyhedron(vertices=[(1, 2), (0, 2)]) sage: pc = PolyhedralComplex([p1, p2, p3]) sage: len(pc.n_maximal_cells(2)) 2 sage: len(pc.n_maximal_cells(1)) 0
>>> from sage.all import * >>> p1 = Polyhedron(vertices=[(Integer(1), Integer(1)), (Integer(0), Integer(0)), (Integer(1), Integer(2))]) >>> p2 = Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(0)), (Integer(0), Integer(2))]) >>> p3 = Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(2))]) >>> pc = PolyhedralComplex([p1, p2, p3]) >>> len(pc.n_maximal_cells(Integer(2))) 2 >>> len(pc.n_maximal_cells(Integer(1))) 0
p1 = Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]) p2 = Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)]) p3 = Polyhedron(vertices=[(1, 2), (0, 2)]) pc = PolyhedralComplex([p1, p2, p3]) len(pc.n_maximal_cells(2)) len(pc.n_maximal_cells(1))
Wrong answer due to
maximality_check=False
:sage: pc_invalid = PolyhedralComplex([p1, p2, p3], ....: maximality_check=False) sage: len(pc_invalid.n_maximal_cells(1)) 1
>>> from sage.all import * >>> pc_invalid = PolyhedralComplex([p1, p2, p3], ... maximality_check=False) >>> len(pc_invalid.n_maximal_cells(Integer(1))) 1
pc_invalid = PolyhedralComplex([p1, p2, p3], maximality_check=False) len(pc_invalid.n_maximal_cells(1))
- n_skeleton(n)[source]¶
The \(n\)-skeleton of this polyhedral complex.
The \(n\)-skeleton of a polyhedral complex is obtained by discarding all of the cells in dimensions larger than \(n\).
INPUT:
n
– nonnegative integer; the dimension
See also
EXAMPLES:
sage: pc = PolyhedralComplex([ ....: Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]), ....: Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)])]) sage: pc.n_skeleton(2) Polyhedral complex with 2 maximal cells sage: pc.n_skeleton(1) Polyhedral complex with 5 maximal cells sage: pc.n_skeleton(0) Polyhedral complex with 4 maximal cells
>>> from sage.all import * >>> pc = PolyhedralComplex([ ... Polyhedron(vertices=[(Integer(1), Integer(1)), (Integer(0), Integer(0)), (Integer(1), Integer(2))]), ... Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(0)), (Integer(0), Integer(2))])]) >>> pc.n_skeleton(Integer(2)) Polyhedral complex with 2 maximal cells >>> pc.n_skeleton(Integer(1)) Polyhedral complex with 5 maximal cells >>> pc.n_skeleton(Integer(0)) Polyhedral complex with 4 maximal cells
pc = PolyhedralComplex([ Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]), Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)])]) pc.n_skeleton(2) pc.n_skeleton(1) pc.n_skeleton(0)
- plot(**kwds)[source]¶
Return a plot of the polyhedral complex, if it is of dim at most 3.
INPUT:
explosion_factor
– (default: 0) if positive, separate the cells of the complex by extra space. In this case, the following keyword arguments can be passed toexploded_plot()
:center
– (default:None
, denoting the origin) the center of explosionsticky_vertices
– (default:False
) boolean or dict; whether to draw line segments between shared vertices of the given polyhedra. A dict gives options forsage.plot.line()
.sticky_center
– (default:True
) boolean or dict. Whencenter
is a vertex of some of the polyhedra, whether to draw line segments connecting thecenter
to the shifted copies of these vertices. A dict gives options forsage.plot.line()
.
color
– (default:None
) if'rainbow'
, assign a different color to every maximal cell; otherwise, passed on toplot()
.other keyword arguments are passed on to
plot()
.
EXAMPLES:
sage: p1 = Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]) sage: p2 = Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)]) sage: p3 = Polyhedron(vertices=[(0, 0), (0, 2), (-1, 1)]) sage: pc1 = PolyhedralComplex([p1, p2, p3, -p1, -p2, -p3]) sage: bb = dict(xmin=-2, xmax=2, ymin=-3, ymax=3, axes=False) sage: g0 = pc1.plot(color='rainbow', **bb) # needs sage.plot sage: g1 = pc1.plot(explosion_factor=0.5, **bb) # needs sage.plot sage: g2 = pc1.plot(explosion_factor=1, color='rainbow', alpha=0.5, **bb) # needs sage.plot sage: graphics_array([g0, g1, g2]).show(axes=False) # not tested sage: pc2 = PolyhedralComplex([polytopes.hypercube(3)]) sage: pc3 = pc2.subdivide(new_vertices=[(0, 0, 0)]) sage: g3 = pc3.plot(explosion_factor=1, color='rainbow', # needs sage.plot ....: alpha=0.5, axes=False, online=True) sage: pc4 = pc2.subdivide(make_simplicial=True) sage: g4 = pc4.plot(explosion_factor=1, center=(1, -1, 1), fill='blue', # needs sage.plot ....: wireframe='white', point={'color':'red', 'size':10}, ....: alpha=0.6, online=True) sage: pc5 = PolyhedralComplex([ ....: Polyhedron(rays=[[1,0,0], [0,1,0], [0,0,-1]]), ....: Polyhedron(rays=[[1,0,0], [0,-1,0], [0,0,-1]]), ....: Polyhedron(rays=[[1,0,0], [0,-1,0], [0,0,1]]), ....: Polyhedron(rays=[[-1,0,0], [0,-1,0], [0,0,-1]]), ....: Polyhedron(rays=[[-1,0,0], [0,-1,0], [0,0,1]]), ....: Polyhedron(rays=[[-1,0,0], [0,1,0], [0,0,-1]]), ....: Polyhedron(rays=[[-1,0,0], [0,1,0], [0,0,1]])]) sage: g5 = pc5.plot(explosion_factor=0.3, color='rainbow', alpha=0.8, # needs sage.plot ....: point={'size': 20}, axes=False, online=True)
>>> from sage.all import * >>> p1 = Polyhedron(vertices=[(Integer(1), Integer(1)), (Integer(0), Integer(0)), (Integer(1), Integer(2))]) >>> p2 = Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(0)), (Integer(0), Integer(2))]) >>> p3 = Polyhedron(vertices=[(Integer(0), Integer(0)), (Integer(0), Integer(2)), (-Integer(1), Integer(1))]) >>> pc1 = PolyhedralComplex([p1, p2, p3, -p1, -p2, -p3]) >>> bb = dict(xmin=-Integer(2), xmax=Integer(2), ymin=-Integer(3), ymax=Integer(3), axes=False) >>> g0 = pc1.plot(color='rainbow', **bb) # needs sage.plot >>> g1 = pc1.plot(explosion_factor=RealNumber('0.5'), **bb) # needs sage.plot >>> g2 = pc1.plot(explosion_factor=Integer(1), color='rainbow', alpha=RealNumber('0.5'), **bb) # needs sage.plot >>> graphics_array([g0, g1, g2]).show(axes=False) # not tested >>> pc2 = PolyhedralComplex([polytopes.hypercube(Integer(3))]) >>> pc3 = pc2.subdivide(new_vertices=[(Integer(0), Integer(0), Integer(0))]) >>> g3 = pc3.plot(explosion_factor=Integer(1), color='rainbow', # needs sage.plot ... alpha=RealNumber('0.5'), axes=False, online=True) >>> pc4 = pc2.subdivide(make_simplicial=True) >>> g4 = pc4.plot(explosion_factor=Integer(1), center=(Integer(1), -Integer(1), Integer(1)), fill='blue', # needs sage.plot ... wireframe='white', point={'color':'red', 'size':Integer(10)}, ... alpha=RealNumber('0.6'), online=True) >>> pc5 = PolyhedralComplex([ ... Polyhedron(rays=[[Integer(1),Integer(0),Integer(0)], [Integer(0),Integer(1),Integer(0)], [Integer(0),Integer(0),-Integer(1)]]), ... Polyhedron(rays=[[Integer(1),Integer(0),Integer(0)], [Integer(0),-Integer(1),Integer(0)], [Integer(0),Integer(0),-Integer(1)]]), ... Polyhedron(rays=[[Integer(1),Integer(0),Integer(0)], [Integer(0),-Integer(1),Integer(0)], [Integer(0),Integer(0),Integer(1)]]), ... Polyhedron(rays=[[-Integer(1),Integer(0),Integer(0)], [Integer(0),-Integer(1),Integer(0)], [Integer(0),Integer(0),-Integer(1)]]), ... Polyhedron(rays=[[-Integer(1),Integer(0),Integer(0)], [Integer(0),-Integer(1),Integer(0)], [Integer(0),Integer(0),Integer(1)]]), ... Polyhedron(rays=[[-Integer(1),Integer(0),Integer(0)], [Integer(0),Integer(1),Integer(0)], [Integer(0),Integer(0),-Integer(1)]]), ... Polyhedron(rays=[[-Integer(1),Integer(0),Integer(0)], [Integer(0),Integer(1),Integer(0)], [Integer(0),Integer(0),Integer(1)]])]) >>> g5 = pc5.plot(explosion_factor=RealNumber('0.3'), color='rainbow', alpha=RealNumber('0.8'), # needs sage.plot ... point={'size': Integer(20)}, axes=False, online=True)
p1 = Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]) p2 = Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)]) p3 = Polyhedron(vertices=[(0, 0), (0, 2), (-1, 1)]) pc1 = PolyhedralComplex([p1, p2, p3, -p1, -p2, -p3]) bb = dict(xmin=-2, xmax=2, ymin=-3, ymax=3, axes=False) g0 = pc1.plot(color='rainbow', **bb) # needs sage.plot g1 = pc1.plot(explosion_factor=0.5, **bb) # needs sage.plot g2 = pc1.plot(explosion_factor=1, color='rainbow', alpha=0.5, **bb) # needs sage.plot graphics_array([g0, g1, g2]).show(axes=False) # not tested pc2 = PolyhedralComplex([polytopes.hypercube(3)]) pc3 = pc2.subdivide(new_vertices=[(0, 0, 0)]) g3 = pc3.plot(explosion_factor=1, color='rainbow', # needs sage.plot alpha=0.5, axes=False, online=True) pc4 = pc2.subdivide(make_simplicial=True) g4 = pc4.plot(explosion_factor=1, center=(1, -1, 1), fill='blue', # needs sage.plot wireframe='white', point={'color':'red', 'size':10}, alpha=0.6, online=True) pc5 = PolyhedralComplex([ Polyhedron(rays=[[1,0,0], [0,1,0], [0,0,-1]]), Polyhedron(rays=[[1,0,0], [0,-1,0], [0,0,-1]]), Polyhedron(rays=[[1,0,0], [0,-1,0], [0,0,1]]), Polyhedron(rays=[[-1,0,0], [0,-1,0], [0,0,-1]]), Polyhedron(rays=[[-1,0,0], [0,-1,0], [0,0,1]]), Polyhedron(rays=[[-1,0,0], [0,1,0], [0,0,-1]]), Polyhedron(rays=[[-1,0,0], [0,1,0], [0,0,1]])]) g5 = pc5.plot(explosion_factor=0.3, color='rainbow', alpha=0.8, # needs sage.plot point={'size': 20}, axes=False, online=True)
- product(right)[source]¶
The (Cartesian) product of this polyhedral complex with another one.
INPUT:
right
– the other polyhedral complex (the right-hand factor)
OUTPUT: the product
self x right
EXAMPLES:
sage: pc = PolyhedralComplex([Polyhedron(vertices=[[0], [1]])]) sage: pc_square = pc.product(pc) sage: pc_square Polyhedral complex with 1 maximal cell sage: next(pc_square.maximal_cell_iterator()).vertices() (A vertex at (0, 0), A vertex at (0, 1), A vertex at (1, 0), A vertex at (1, 1))
>>> from sage.all import * >>> pc = PolyhedralComplex([Polyhedron(vertices=[[Integer(0)], [Integer(1)]])]) >>> pc_square = pc.product(pc) >>> pc_square Polyhedral complex with 1 maximal cell >>> next(pc_square.maximal_cell_iterator()).vertices() (A vertex at (0, 0), A vertex at (0, 1), A vertex at (1, 0), A vertex at (1, 1))
pc = PolyhedralComplex([Polyhedron(vertices=[[0], [1]])]) pc_square = pc.product(pc) pc_square next(pc_square.maximal_cell_iterator()).vertices()
- relative_boundary_cells()[source]¶
Return the maximal cells of the relative-boundary sub-complex.
A point \(P\) is in the relative boundary of a set \(S\) if \(P\) is in the closure of \(S\) but not in the relative interior of \(S\).
Warning
This may give the wrong answer if the polyhedral complex was constructed with
maximality_check
set toFalse
.EXAMPLES:
sage: p1 = Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]) sage: p2 = Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)]) sage: p3 = Polyhedron(vertices=[(1, 2), (0, 2)]) sage: p4 = Polyhedron(vertices=[(2, 2)]) sage: pc = PolyhedralComplex([p1, p2]) sage: rbd_cells = pc.relative_boundary_cells() sage: len(rbd_cells) 4 sage: all(p.dimension() == 1 for p in rbd_cells) True sage: pc_lower_dim = PolyhedralComplex([p3]) sage: sorted([p.vertices() for p in pc_lower_dim.relative_boundary_cells()]) [(A vertex at (0, 2),), (A vertex at (1, 2),)]
>>> from sage.all import * >>> p1 = Polyhedron(vertices=[(Integer(1), Integer(1)), (Integer(0), Integer(0)), (Integer(1), Integer(2))]) >>> p2 = Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(0)), (Integer(0), Integer(2))]) >>> p3 = Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(2))]) >>> p4 = Polyhedron(vertices=[(Integer(2), Integer(2))]) >>> pc = PolyhedralComplex([p1, p2]) >>> rbd_cells = pc.relative_boundary_cells() >>> len(rbd_cells) 4 >>> all(p.dimension() == Integer(1) for p in rbd_cells) True >>> pc_lower_dim = PolyhedralComplex([p3]) >>> sorted([p.vertices() for p in pc_lower_dim.relative_boundary_cells()]) [(A vertex at (0, 2),), (A vertex at (1, 2),)]
p1 = Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]) p2 = Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)]) p3 = Polyhedron(vertices=[(1, 2), (0, 2)]) p4 = Polyhedron(vertices=[(2, 2)]) pc = PolyhedralComplex([p1, p2]) rbd_cells = pc.relative_boundary_cells() len(rbd_cells) all(p.dimension() == 1 for p in rbd_cells) pc_lower_dim = PolyhedralComplex([p3]) sorted([p.vertices() for p in pc_lower_dim.relative_boundary_cells()])
Test on polyhedral complex which is not pure:
sage: pc_non_pure = PolyhedralComplex([p1, p3, p4]) sage: (set(pc_non_pure.relative_boundary_cells()) ....: == set([f.as_polyhedron() for f in p1.faces(1)] + [p3, p4])) True
>>> from sage.all import * >>> pc_non_pure = PolyhedralComplex([p1, p3, p4]) >>> (set(pc_non_pure.relative_boundary_cells()) ... == set([f.as_polyhedron() for f in p1.faces(Integer(1))] + [p3, p4])) True
pc_non_pure = PolyhedralComplex([p1, p3, p4]) (set(pc_non_pure.relative_boundary_cells()) == set([f.as_polyhedron() for f in p1.faces(1)] + [p3, p4]))
Test with
maximality_check == False
:sage: pc_invalid = PolyhedralComplex([p2, p3], ....: maximality_check=False) sage: (set(pc_invalid.relative_boundary_cells()) ....: == set([f.as_polyhedron() for f in p2.faces(1)])) True
>>> from sage.all import * >>> pc_invalid = PolyhedralComplex([p2, p3], ... maximality_check=False) >>> (set(pc_invalid.relative_boundary_cells()) ... == set([f.as_polyhedron() for f in p2.faces(Integer(1))])) True
pc_invalid = PolyhedralComplex([p2, p3], maximality_check=False) (set(pc_invalid.relative_boundary_cells()) == set([f.as_polyhedron() for f in p2.faces(1)]))
Test unbounded case:
sage: pc3 = PolyhedralComplex([ ....: Polyhedron(vertices=[[1,0], [0,1]], rays=[[1,0], [0,1]]), ....: Polyhedron(vertices=[[1,0], [0,-1]], rays=[[1,0], [0,-1]])]) sage: len(pc3.relative_boundary_cells()) 4
>>> from sage.all import * >>> pc3 = PolyhedralComplex([ ... Polyhedron(vertices=[[Integer(1),Integer(0)], [Integer(0),Integer(1)]], rays=[[Integer(1),Integer(0)], [Integer(0),Integer(1)]]), ... Polyhedron(vertices=[[Integer(1),Integer(0)], [Integer(0),-Integer(1)]], rays=[[Integer(1),Integer(0)], [Integer(0),-Integer(1)]])]) >>> len(pc3.relative_boundary_cells()) 4
pc3 = PolyhedralComplex([ Polyhedron(vertices=[[1,0], [0,1]], rays=[[1,0], [0,1]]), Polyhedron(vertices=[[1,0], [0,-1]], rays=[[1,0], [0,-1]])]) len(pc3.relative_boundary_cells())
- remove_cell(cell, check=False)[source]¶
Remove
cell
fromself
and all the cells that containcell
as a subface.INPUT:
cell
– a cell of the polyhedral complexcheck
– boolean (default:False
); ifTrue
, raise an error ifcell
is not a cell of this complex
This does not return anything; instead, it changes the polyhedral complex.
EXAMPLES:
If you add a cell which is already present, there is no effect:
sage: p1 = Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]) sage: p2 = Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)]) sage: r = Polyhedron(rays=[(1, 0)]) sage: pc = PolyhedralComplex([p1, p2, r]) sage: pc.dimension() 2 sage: pc.remove_cell(Polyhedron(vertices=[(0, 0), (1, 2)])) sage: pc.dimension() 1 sage: pc Polyhedral complex with 5 maximal cells sage: pc.remove_cell(Polyhedron(vertices=[(1, 2)])) sage: pc.dimension() 1 sage: pc Polyhedral complex with 3 maximal cells sage: pc.remove_cell(Polyhedron(vertices=[(0, 0)])) sage: pc.dimension() 0
>>> from sage.all import * >>> p1 = Polyhedron(vertices=[(Integer(1), Integer(1)), (Integer(0), Integer(0)), (Integer(1), Integer(2))]) >>> p2 = Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(0)), (Integer(0), Integer(2))]) >>> r = Polyhedron(rays=[(Integer(1), Integer(0))]) >>> pc = PolyhedralComplex([p1, p2, r]) >>> pc.dimension() 2 >>> pc.remove_cell(Polyhedron(vertices=[(Integer(0), Integer(0)), (Integer(1), Integer(2))])) >>> pc.dimension() 1 >>> pc Polyhedral complex with 5 maximal cells >>> pc.remove_cell(Polyhedron(vertices=[(Integer(1), Integer(2))])) >>> pc.dimension() 1 >>> pc Polyhedral complex with 3 maximal cells >>> pc.remove_cell(Polyhedron(vertices=[(Integer(0), Integer(0))])) >>> pc.dimension() 0
p1 = Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]) p2 = Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)]) r = Polyhedron(rays=[(1, 0)]) pc = PolyhedralComplex([p1, p2, r]) pc.dimension() pc.remove_cell(Polyhedron(vertices=[(0, 0), (1, 2)])) pc.dimension() pc pc.remove_cell(Polyhedron(vertices=[(1, 2)])) pc.dimension() pc pc.remove_cell(Polyhedron(vertices=[(0, 0)])) pc.dimension()
- set_immutable()[source]¶
Make this polyhedral complex immutable.
EXAMPLES:
sage: pc = PolyhedralComplex([Polyhedron(vertices=[[0], [1]])]) sage: pc.is_mutable() True sage: pc.set_immutable() sage: pc.is_mutable() False
>>> from sage.all import * >>> pc = PolyhedralComplex([Polyhedron(vertices=[[Integer(0)], [Integer(1)]])]) >>> pc.is_mutable() True >>> pc.set_immutable() >>> pc.is_mutable() False
pc = PolyhedralComplex([Polyhedron(vertices=[[0], [1]])]) pc.is_mutable() pc.set_immutable() pc.is_mutable()
- stratify(n)[source]¶
Return the pure sub-polyhedral complex which is constructed from the \(n\)-dimensional maximal cells of this polyhedral complex.
See also
Warning
This may give the wrong answer if the polyhedral complex was constructed with
maximality_check
set toFalse
.EXAMPLES:
sage: p1 = Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]) sage: p2 = Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)]) sage: p3 = Polyhedron(vertices=[(1, 2), (0, 2)]) sage: pc = PolyhedralComplex([p1, p2, p3]) sage: pc.stratify(2) == pc True sage: pc.stratify(1) Polyhedral complex with 0 maximal cells
>>> from sage.all import * >>> p1 = Polyhedron(vertices=[(Integer(1), Integer(1)), (Integer(0), Integer(0)), (Integer(1), Integer(2))]) >>> p2 = Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(0)), (Integer(0), Integer(2))]) >>> p3 = Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(2))]) >>> pc = PolyhedralComplex([p1, p2, p3]) >>> pc.stratify(Integer(2)) == pc True >>> pc.stratify(Integer(1)) Polyhedral complex with 0 maximal cells
p1 = Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]) p2 = Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)]) p3 = Polyhedron(vertices=[(1, 2), (0, 2)]) pc = PolyhedralComplex([p1, p2, p3]) pc.stratify(2) == pc pc.stratify(1)
Wrong answer due to
maximality_check=False
:sage: pc_invalid = PolyhedralComplex([p1, p2, p3], ....: maximality_check=False) sage: pc_invalid.stratify(1) Polyhedral complex with 1 maximal cell
>>> from sage.all import * >>> pc_invalid = PolyhedralComplex([p1, p2, p3], ... maximality_check=False) >>> pc_invalid.stratify(Integer(1)) Polyhedral complex with 1 maximal cell
pc_invalid = PolyhedralComplex([p1, p2, p3], maximality_check=False) pc_invalid.stratify(1)
- subdivide(make_simplicial=False, new_vertices=None, new_rays=None)[source]¶
Construct a new polyhedral complex by iterative stellar subdivision of
self
for each new vertex/ray given.Currently, subdivision is only supported for bounded polyhedral complex or polyhedral fan.
INPUT:
make_simplicial
– boolean (default:False
); ifTrue
, the returned polyhedral complex is simplicialnew_vertices
,new_rays
– list (optional); new generators to be added during subdivision
EXAMPLES:
sage: square_vertices = [(1, 1, 1), (-1, 1, 1), (-1, -1, 1), (1, -1, 1)] sage: pc = PolyhedralComplex([ ....: Polyhedron(vertices=[(0, 0, 0)] + square_vertices), ....: Polyhedron(vertices=[(0, 0, 2)] + square_vertices)]) sage: pc.is_compact() and not pc.is_simplicial_complex() True sage: subdivided_pc = pc.subdivide(new_vertices=[(0, 0, 1)]) sage: subdivided_pc Polyhedral complex with 8 maximal cells sage: subdivided_pc.is_simplicial_complex() True sage: simplicial_pc = pc.subdivide(make_simplicial=True) sage: simplicial_pc Polyhedral complex with 4 maximal cells sage: simplicial_pc.is_simplicial_complex() True sage: fan = PolyhedralComplex([Polyhedron(rays=square_vertices)]) sage: fan.is_polyhedral_fan() and not fan.is_simplicial_fan() True sage: fan.subdivide(new_vertices=[(0, 0, 1)]) Traceback (most recent call last): ... ValueError: new vertices cannot be used for subdivision sage: subdivided_fan = fan.subdivide(new_rays=[(0, 0, 1)]) sage: subdivided_fan Polyhedral complex with 4 maximal cells sage: subdivided_fan.is_simplicial_fan() True sage: simplicial_fan = fan.subdivide(make_simplicial=True) sage: simplicial_fan Polyhedral complex with 2 maximal cells sage: simplicial_fan.is_simplicial_fan() True sage: halfspace = PolyhedralComplex([Polyhedron(rays=[(0, 0, 1)], ....: lines=[(1, 0, 0), (0, 1, 0)])]) sage: halfspace.is_simplicial_fan() False sage: subdiv_halfspace = halfspace.subdivide(make_simplicial=True) sage: subdiv_halfspace Polyhedral complex with 4 maximal cells sage: subdiv_halfspace.is_simplicial_fan() True
>>> from sage.all import * >>> square_vertices = [(Integer(1), Integer(1), Integer(1)), (-Integer(1), Integer(1), Integer(1)), (-Integer(1), -Integer(1), Integer(1)), (Integer(1), -Integer(1), Integer(1))] >>> pc = PolyhedralComplex([ ... Polyhedron(vertices=[(Integer(0), Integer(0), Integer(0))] + square_vertices), ... Polyhedron(vertices=[(Integer(0), Integer(0), Integer(2))] + square_vertices)]) >>> pc.is_compact() and not pc.is_simplicial_complex() True >>> subdivided_pc = pc.subdivide(new_vertices=[(Integer(0), Integer(0), Integer(1))]) >>> subdivided_pc Polyhedral complex with 8 maximal cells >>> subdivided_pc.is_simplicial_complex() True >>> simplicial_pc = pc.subdivide(make_simplicial=True) >>> simplicial_pc Polyhedral complex with 4 maximal cells >>> simplicial_pc.is_simplicial_complex() True >>> fan = PolyhedralComplex([Polyhedron(rays=square_vertices)]) >>> fan.is_polyhedral_fan() and not fan.is_simplicial_fan() True >>> fan.subdivide(new_vertices=[(Integer(0), Integer(0), Integer(1))]) Traceback (most recent call last): ... ValueError: new vertices cannot be used for subdivision >>> subdivided_fan = fan.subdivide(new_rays=[(Integer(0), Integer(0), Integer(1))]) >>> subdivided_fan Polyhedral complex with 4 maximal cells >>> subdivided_fan.is_simplicial_fan() True >>> simplicial_fan = fan.subdivide(make_simplicial=True) >>> simplicial_fan Polyhedral complex with 2 maximal cells >>> simplicial_fan.is_simplicial_fan() True >>> halfspace = PolyhedralComplex([Polyhedron(rays=[(Integer(0), Integer(0), Integer(1))], ... lines=[(Integer(1), Integer(0), Integer(0)), (Integer(0), Integer(1), Integer(0))])]) >>> halfspace.is_simplicial_fan() False >>> subdiv_halfspace = halfspace.subdivide(make_simplicial=True) >>> subdiv_halfspace Polyhedral complex with 4 maximal cells >>> subdiv_halfspace.is_simplicial_fan() True
square_vertices = [(1, 1, 1), (-1, 1, 1), (-1, -1, 1), (1, -1, 1)] pc = PolyhedralComplex([ Polyhedron(vertices=[(0, 0, 0)] + square_vertices), Polyhedron(vertices=[(0, 0, 2)] + square_vertices)]) pc.is_compact() and not pc.is_simplicial_complex() subdivided_pc = pc.subdivide(new_vertices=[(0, 0, 1)]) subdivided_pc subdivided_pc.is_simplicial_complex() simplicial_pc = pc.subdivide(make_simplicial=True) simplicial_pc simplicial_pc.is_simplicial_complex() fan = PolyhedralComplex([Polyhedron(rays=square_vertices)]) fan.is_polyhedral_fan() and not fan.is_simplicial_fan() fan.subdivide(new_vertices=[(0, 0, 1)]) subdivided_fan = fan.subdivide(new_rays=[(0, 0, 1)]) subdivided_fan subdivided_fan.is_simplicial_fan() simplicial_fan = fan.subdivide(make_simplicial=True) simplicial_fan simplicial_fan.is_simplicial_fan() halfspace = PolyhedralComplex([Polyhedron(rays=[(0, 0, 1)], lines=[(1, 0, 0), (0, 1, 0)])]) halfspace.is_simplicial_fan() subdiv_halfspace = halfspace.subdivide(make_simplicial=True) subdiv_halfspace subdiv_halfspace.is_simplicial_fan()
- union(right)[source]¶
The union of this polyhedral complex with another one.
INPUT:
right
– the other polyhedral complex (the right-hand factor)
EXAMPLES:
sage: p1 = Polyhedron(vertices=[(-1, 0), (0, 0), (0, 1)]) sage: p2 = Polyhedron(vertices=[(0, -1), (0, 0), (1, 0)]) sage: p3 = Polyhedron(vertices=[(0, -1), (1, -1), (1, 0)]) sage: pc = PolyhedralComplex([p1]).union(PolyhedralComplex([p3])) sage: set(pc.maximal_cell_iterator()) == set([p1, p3]) True sage: pc.union(PolyhedralComplex([p2])) Polyhedral complex with 3 maximal cells sage: p4 = Polyhedron(vertices=[(0, -1), (0, 0), (1, 0), (1, -1)]) sage: pc.union(PolyhedralComplex([p4])) Traceback (most recent call last): ... ValueError: the given cells are not face-to-face
>>> from sage.all import * >>> p1 = Polyhedron(vertices=[(-Integer(1), Integer(0)), (Integer(0), Integer(0)), (Integer(0), Integer(1))]) >>> p2 = Polyhedron(vertices=[(Integer(0), -Integer(1)), (Integer(0), Integer(0)), (Integer(1), Integer(0))]) >>> p3 = Polyhedron(vertices=[(Integer(0), -Integer(1)), (Integer(1), -Integer(1)), (Integer(1), Integer(0))]) >>> pc = PolyhedralComplex([p1]).union(PolyhedralComplex([p3])) >>> set(pc.maximal_cell_iterator()) == set([p1, p3]) True >>> pc.union(PolyhedralComplex([p2])) Polyhedral complex with 3 maximal cells >>> p4 = Polyhedron(vertices=[(Integer(0), -Integer(1)), (Integer(0), Integer(0)), (Integer(1), Integer(0)), (Integer(1), -Integer(1))]) >>> pc.union(PolyhedralComplex([p4])) Traceback (most recent call last): ... ValueError: the given cells are not face-to-face
p1 = Polyhedron(vertices=[(-1, 0), (0, 0), (0, 1)]) p2 = Polyhedron(vertices=[(0, -1), (0, 0), (1, 0)]) p3 = Polyhedron(vertices=[(0, -1), (1, -1), (1, 0)]) pc = PolyhedralComplex([p1]).union(PolyhedralComplex([p3])) set(pc.maximal_cell_iterator()) == set([p1, p3]) pc.union(PolyhedralComplex([p2])) p4 = Polyhedron(vertices=[(0, -1), (0, 0), (1, 0), (1, -1)]) pc.union(PolyhedralComplex([p4]))
- union_as_polyhedron()[source]¶
Return
self
as aPolyhedron
ifself
is convex.EXAMPLES:
sage: p1 = Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]) sage: p2 = Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)]) sage: p3 = Polyhedron(vertices=[(0, 0), (1, 1), (2, 0)]) sage: P = PolyhedralComplex([p1, p2]).union_as_polyhedron() sage: P.vertices_list() [[0, 0], [0, 2], [1, 1], [1, 2]] sage: PolyhedralComplex([p1, p3]).union_as_polyhedron() Traceback (most recent call last): ... ValueError: the polyhedral complex is not convex
>>> from sage.all import * >>> p1 = Polyhedron(vertices=[(Integer(1), Integer(1)), (Integer(0), Integer(0)), (Integer(1), Integer(2))]) >>> p2 = Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(0)), (Integer(0), Integer(2))]) >>> p3 = Polyhedron(vertices=[(Integer(0), Integer(0)), (Integer(1), Integer(1)), (Integer(2), Integer(0))]) >>> P = PolyhedralComplex([p1, p2]).union_as_polyhedron() >>> P.vertices_list() [[0, 0], [0, 2], [1, 1], [1, 2]] >>> PolyhedralComplex([p1, p3]).union_as_polyhedron() Traceback (most recent call last): ... ValueError: the polyhedral complex is not convex
p1 = Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]) p2 = Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)]) p3 = Polyhedron(vertices=[(0, 0), (1, 1), (2, 0)]) P = PolyhedralComplex([p1, p2]).union_as_polyhedron() P.vertices_list() PolyhedralComplex([p1, p3]).union_as_polyhedron()
- wedge(right)[source]¶
The wedge (one-point union) of
self
withright
.Todo
Implement the wedge product of two polyhedral complexes.
EXAMPLES:
sage: pc = PolyhedralComplex([Polyhedron(vertices=[[0], [1]])]) sage: pc.wedge(pc) Traceback (most recent call last): ... NotImplementedError: wedge is not implemented for polyhedral complex
>>> from sage.all import * >>> pc = PolyhedralComplex([Polyhedron(vertices=[[Integer(0)], [Integer(1)]])]) >>> pc.wedge(pc) Traceback (most recent call last): ... NotImplementedError: wedge is not implemented for polyhedral complex
pc = PolyhedralComplex([Polyhedron(vertices=[[0], [1]])]) pc.wedge(pc)
- sage.geometry.polyhedral_complex.cells_list_to_cells_dict(cells_list)[source]¶
Helper function that returns the dictionary whose keys are the dimensions, and the value associated to an integer \(d\) is the set of \(d\)-dimensional polyhedra in the given list.
EXAMPLES:
sage: p1 = Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]) sage: p2 = Polyhedron(vertices=[(1, 1), (0, 0)]) sage: p3 = Polyhedron(vertices=[(0, 0)]) sage: p4 = Polyhedron(vertices=[(1, 1)]) sage: sage.geometry.polyhedral_complex.cells_list_to_cells_dict([p1, p2, p3, p4]) {0: {A 0-dimensional polyhedron in ZZ^2 defined as the convex hull of 1 vertex, A 0-dimensional polyhedron in ZZ^2 defined as the convex hull of 1 vertex}, 1: {A 1-dimensional polyhedron in ZZ^2 defined as the convex hull of 2 vertices}, 2: {A 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 3 vertices}}
>>> from sage.all import * >>> p1 = Polyhedron(vertices=[(Integer(1), Integer(1)), (Integer(0), Integer(0)), (Integer(1), Integer(2))]) >>> p2 = Polyhedron(vertices=[(Integer(1), Integer(1)), (Integer(0), Integer(0))]) >>> p3 = Polyhedron(vertices=[(Integer(0), Integer(0))]) >>> p4 = Polyhedron(vertices=[(Integer(1), Integer(1))]) >>> sage.geometry.polyhedral_complex.cells_list_to_cells_dict([p1, p2, p3, p4]) {0: {A 0-dimensional polyhedron in ZZ^2 defined as the convex hull of 1 vertex, A 0-dimensional polyhedron in ZZ^2 defined as the convex hull of 1 vertex}, 1: {A 1-dimensional polyhedron in ZZ^2 defined as the convex hull of 2 vertices}, 2: {A 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 3 vertices}}
p1 = Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]) p2 = Polyhedron(vertices=[(1, 1), (0, 0)]) p3 = Polyhedron(vertices=[(0, 0)]) p4 = Polyhedron(vertices=[(1, 1)]) sage.geometry.polyhedral_complex.cells_list_to_cells_dict([p1, p2, p3, p4])
- sage.geometry.polyhedral_complex.exploded_plot(polyhedra, center, explosion_factor, sticky_vertices, sticky_center, point, **kwds)[source]¶
Return a plot of several
polyhedra
in one figure with extra space between them.INPUT:
polyhedra
– an iterable ofPolyhedron_base
objectscenter
– (default:None
, denoting the origin) the center of explosionexplosion_factor
– (default: 1) a nonnegative number; translate polyhedra by this factor of the distance fromcenter
to their centersticky_vertices
– (default:False
) boolean or dict; whether to draw line segments between shared vertices of the given polyhedra. A dict gives options forsage.plot.line()
.sticky_center
– (default:True
) boolean or dict. Whencenter
is a vertex of some of the polyhedra, whether to draw line segments connecting thecenter
to the shifted copies of these vertices. A dict gives options forsage.plot.line()
.color
– (default:None
) if'rainbow'
, assign a different color to every maximal cell and every vertex; otherwise, passed on toplot()
other keyword arguments are passed on to
plot()
EXAMPLES:
sage: from sage.geometry.polyhedral_complex import exploded_plot sage: p1 = Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]) sage: p2 = Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)]) sage: p3 = Polyhedron(vertices=[(0, 0), (1, 1), (2, 0)]) sage: exploded_plot([p1, p2, p3]) # needs sage.plot Graphics object consisting of 20 graphics primitives sage: exploded_plot([p1, p2, p3], center=(1, 1)) # needs sage.plot Graphics object consisting of 19 graphics primitives sage: exploded_plot([p1, p2, p3], center=(1, 1), sticky_vertices=True) # needs sage.plot Graphics object consisting of 23 graphics primitives
>>> from sage.all import * >>> from sage.geometry.polyhedral_complex import exploded_plot >>> p1 = Polyhedron(vertices=[(Integer(1), Integer(1)), (Integer(0), Integer(0)), (Integer(1), Integer(2))]) >>> p2 = Polyhedron(vertices=[(Integer(1), Integer(2)), (Integer(0), Integer(0)), (Integer(0), Integer(2))]) >>> p3 = Polyhedron(vertices=[(Integer(0), Integer(0)), (Integer(1), Integer(1)), (Integer(2), Integer(0))]) >>> exploded_plot([p1, p2, p3]) # needs sage.plot Graphics object consisting of 20 graphics primitives >>> exploded_plot([p1, p2, p3], center=(Integer(1), Integer(1))) # needs sage.plot Graphics object consisting of 19 graphics primitives >>> exploded_plot([p1, p2, p3], center=(Integer(1), Integer(1)), sticky_vertices=True) # needs sage.plot Graphics object consisting of 23 graphics primitives
from sage.geometry.polyhedral_complex import exploded_plot p1 = Polyhedron(vertices=[(1, 1), (0, 0), (1, 2)]) p2 = Polyhedron(vertices=[(1, 2), (0, 0), (0, 2)]) p3 = Polyhedron(vertices=[(0, 0), (1, 1), (2, 0)]) exploded_plot([p1, p2, p3]) # needs sage.plot exploded_plot([p1, p2, p3], center=(1, 1)) # needs sage.plot exploded_plot([p1, p2, p3], center=(1, 1), sticky_vertices=True) # needs sage.plot