Ask Your Question

why remove_face uses alexander duality?

asked 2011-04-27 05:56:04 -0500

EmersonL gravatar image

updated 2011-05-03 23:05:43 -0500

The method for simplicial complexes remove_face is very slow for not to say that never ends. The documentation describes the used algorithm, but it seems pretty unefficient. I think it is easier simply to remove the facets containing the face to delete F, and for each facet add the faces not containing F. That is the join of the boundary of F and the complement of F (the link). Why to use such elaborate algorithm?

edit retag flag offensive close merge delete


Please write a new version; if it works and is faster, it can be merged into Sage. The Alexander duality method could also use work, I think.

John Palmieri gravatar imageJohn Palmieri ( 2011-04-27 06:05:40 -0500 )edit

3 answers

Sort by » oldest newest most voted

answered 2011-05-11 23:54:34 -0500

EmersonL gravatar image

updated 2011-05-12 00:40:49 -0500

try this:



edit flag offensive delete link more

answered 2011-05-04 09:12:00 -0500

(This is really a comment for EmersonL's answer, but it's too long to fit, plus I wanted to format it nicely.)

I'm not getting any speed-up with your version. I added it to the file, calling it "remove_face2", and I added one line:

FACE = Simplex(FACE)

at the beginning so that you can enter a list of vertices, not necessarily an actual simplex. Then I did this:

sage: S = range(1,8)
sage: timeit('Z = SimplicialComplex(S, [S]); Z.remove_face([1,2,3])')
625 loops, best of 3: 675 µs per loop
sage: timeit('Z = SimplicialComplex(S, [S]); Z.remove_face2([1,2,3])')
625 loops, best of 3: 940 µs per loop

I tried a few other examples, and the old version was faster for most of them, comparable for all of them. Can you give some examples where your code is faster?

edit flag offensive delete link more

answered 2011-05-03 06:56:34 -0500

EmersonL gravatar image

updated 2011-05-03 10:07:12 -0500

benjaminfjones gravatar image

This is the code I got. I'm still novice with python stuff...

def remove_face(SC,FACE):
    """Remove the Simplex FACE from the SimplicialComplex SC, by taking
    the facets of SC not containing FACE, union with
    ffboundary=SimplicialComplex(FACE,FACE.faces()) # boundary
    b=Set([elem for elem in SC.facets() if FACE.is_face(elem)==False])
    return SC2

There is a minor problem now in case that FACE is not a face of SC. Maybe an error can be added, but I think the algorithm is right, and the problem is in the way the link is computed.

The problem is that the link of a simplex not being a face in the complex is not the simplicial complex {()} (the irrelevant complex), but simply {} (the void complex). The link definition doesn't include the empty set in this case, so the answer is tecnically wrong.

If the link is void, the join would be void, and no faces are added or removed... Besides, if the link makes this difference, it can be used as a test for a simplex being a face (since {} is supposed to be false).

I tested the examples to compare results with sage documentation (here FACE must be a Simplex), but with real examples (a bit bigger), I didn't manage to wait for sage, while my algorithm was about a second... Regards!

edit flag offensive delete link more


See for a patch implementing this.

John Palmieri gravatar imageJohn Palmieri ( 2011-07-25 13:25:47 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2011-04-27 05:56:04 -0500

Seen: 167 times

Last updated: May 12 '11