Removing simplices from a simplicial complex in sage

27 Views Asked by At

The context for this problem is this: given a simplicial complex $X$ and a simplex $\sigma \subseteq X$, I want to define a new simplicial complex $Y_\sigma$ to be the subcomplex of $X$ with vertex set $V(X)-V(\sigma)$. Eventually I want to loop over all such $\sigma$, so I would need some way of keeping this fairly general and automated.

My thought was the following:

  1. Extract the vertex set from $X$.
  2. Use the .faces() function gives me a list of all faces
  3. For any prescribed face $\sigma$ in that list, extract the vertex set $V(\sigma)$
  4. Use .generated_subcomplex() on the difference $V(X) - V(\sigma)$ to obtain $Y_\sigma$.

Steps 1 and 3 are giving me grief, however. The documentation doesn't seem to have any way to get vertices from a simplicial complex. I'm also not sure I understand what the face is as an object; I would have expected sage to also treat it as a simplex/simplicial complex, but I'm not sure if that's actually the case.

Any help is much appreciated!

1

There are 1 best solutions below

1
On BEST ANSWER

This is not really a math question and probably belongs instead on ask.sagemath.org. But I find that I've written an answer, so here it is:

I would recommend using the remove_faces method. If you have a simplex sigma in X, you can do

X.remove_faces([[a] for a in sigma])

Explanation: suppose sigma is the simplex [0,1,3]. Then [[a] for a in sigma] returns [[0], [1], [3]: a list of lists, each one being a single number — a $0$-simplex. If you want to be mathematically correct about it, you could do instead [Simplex([a]) for a in sigma] so that this is actually a list of simplices, not just a list of lists, but Sage lets you be sloppy and treat a list of numbers (like [1]) as a simplex.

Passing this list to X.remove_faces(...) then removes those faces and any other simplices forced by this: if you remove the $0$-simplex [0], then you have to remove all simplices containing it.

Warning: X.remove_faces(...) modifies X. You might instead want to make a copy of X and modify that:

Y = SimplicialComplex(X)
Y.remove_faces(...)

should modify Y but leave X unchanged. If you want to be really careful:

X.set_immutable()  # makes X unchangeable
Y = SimplicialComplex(X, is_mutable=True)  # explicitly make Y changeable, just in case
Y.remove_faces(...)

By the way: X.vertices() will return the list of vertices of X, in response to your statement near the bottom of your question. If you want to know what sort of thing a face is:

sage: T = simplicial_complexes.Torus()
sage: e = T.n_cells(1)[3] # some edge of T
sage: e
(2, 6)
sage: type(e)
<class 'sage.topology.simplicial_complex.Simplex'>

so a simplex in a simplicial complex is a Simplex.