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:
- Extract the vertex set from $X$.
- Use the
.faces()function gives me a list of all faces - For any prescribed face $\sigma$ in that list, extract the vertex set $V(\sigma)$
- 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!
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_facesmethod. If you have a simplexsigmainX, you can doExplanation: suppose
sigmais 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(...)modifiesX. You might instead want to make a copy ofXand modify that:should modify
Ybut leaveXunchanged. If you want to be really careful:By the way:
X.vertices()will return the list of vertices ofX, in response to your statement near the bottom of your question. If you want to know what sort of thing a face is:so a simplex in a simplicial complex is a Simplex.