ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 05 Jan 2015 11:26:00 +0100homology of simplicial complexeshttps://ask.sagemath.org/question/9943/homology-of-simplicial-complexes/I am building a simplicial complex as follows:
sage: S = range(1,7)
sage: Z = SimplicialComplex([S])
sage: T = Z.n_skeleton(1)
sage: T.faces()
{0: set([(4,), (5,), (3,), (1,), (6,), (2,)]), 1: set([(2, 4), (3, 6),
(5, 6), (2, 6), (1, 4), (3, 5), (3, 4), (2, 3), (4, 6), (2, 5), (1, 2),
(1, 3), (4, 5), (1, 5), (1, 6)]), -1: set([()])}
sage: T.homology()
{0: 0, 1: Z^10}
So far everything seems good. Then I try adding a face to T.
sage: T.add_face([1,2,6])
sage: T.faces()
{0: set([(4,), (5,), (3,), (1,), (6,), (2,)]), 1: set([(2, 4), (3, 6),
(5, 6), (1, 5), (1, 4), (3, 5), (3, 4), (2, 3), (4, 6), (2, 5), (1, 2),
(1, 3), (1, 6), (2, 6), (4, 5)]), 2: set([(1, 2, 6)]), -1: set([()])}
So the face seems to have been added.
But then:
sage: T.homology()
results in:
{0: 0, 1: Z^10, 2: 0}
But this doesn't make any sense --- it should say `0:0, 1:Z^9, 2:0`, since adding a 2-face kills a class in $H_1(T)$.
Can anyone tell what I'm doing wrong?
Sun, 24 Mar 2013 17:40:49 +0100https://ask.sagemath.org/question/9943/homology-of-simplicial-complexes/Comment by slelievre for <p>I am building a simplicial complex as follows:</p>
<pre><code>sage: S = range(1,7)
sage: Z = SimplicialComplex([S])
sage: T = Z.n_skeleton(1)
sage: T.faces()
{0: set([(4,), (5,), (3,), (1,), (6,), (2,)]), 1: set([(2, 4), (3, 6),
(5, 6), (2, 6), (1, 4), (3, 5), (3, 4), (2, 3), (4, 6), (2, 5), (1, 2),
(1, 3), (4, 5), (1, 5), (1, 6)]), -1: set([()])}
sage: T.homology()
{0: 0, 1: Z^10}
</code></pre>
<p>So far everything seems good. Then I try adding a face to T.</p>
<pre><code>sage: T.add_face([1,2,6])
sage: T.faces()
{0: set([(4,), (5,), (3,), (1,), (6,), (2,)]), 1: set([(2, 4), (3, 6),
(5, 6), (1, 5), (1, 4), (3, 5), (3, 4), (2, 3), (4, 6), (2, 5), (1, 2),
(1, 3), (1, 6), (2, 6), (4, 5)]), 2: set([(1, 2, 6)]), -1: set([()])}
</code></pre>
<p>So the face seems to have been added.</p>
<p>But then:</p>
<pre><code>sage: T.homology()
</code></pre>
<p>results in:</p>
<pre><code>{0: 0, 1: Z^10, 2: 0}
</code></pre>
<p>But this doesn't make any sense --- it should say <code>0:0, 1:Z^9, 2:0</code>, since adding a 2-face kills a class in $H_1(T)$.</p>
<p>Can anyone tell what I'm doing wrong?</p>
https://ask.sagemath.org/question/9943/homology-of-simplicial-complexes/?comment=25399#post-id-25399[2015-01-05: Just fixed code formatting of this 2013 question. By the way, the patch from ticket #14354 mentioned in John Palmieri's answer was merged in Sage 5.9.beta2, and running the example in the question now gives the correct answer.] [Matt: you could mark John's answer as accepted by clicking the tick mark.]Mon, 05 Jan 2015 11:26:00 +0100https://ask.sagemath.org/question/9943/homology-of-simplicial-complexes/?comment=25399#post-id-25399Answer by John Palmieri for <p>I am building a simplicial complex as follows:</p>
<pre><code>sage: S = range(1,7)
sage: Z = SimplicialComplex([S])
sage: T = Z.n_skeleton(1)
sage: T.faces()
{0: set([(4,), (5,), (3,), (1,), (6,), (2,)]), 1: set([(2, 4), (3, 6),
(5, 6), (2, 6), (1, 4), (3, 5), (3, 4), (2, 3), (4, 6), (2, 5), (1, 2),
(1, 3), (4, 5), (1, 5), (1, 6)]), -1: set([()])}
sage: T.homology()
{0: 0, 1: Z^10}
</code></pre>
<p>So far everything seems good. Then I try adding a face to T.</p>
<pre><code>sage: T.add_face([1,2,6])
sage: T.faces()
{0: set([(4,), (5,), (3,), (1,), (6,), (2,)]), 1: set([(2, 4), (3, 6),
(5, 6), (1, 5), (1, 4), (3, 5), (3, 4), (2, 3), (4, 6), (2, 5), (1, 2),
(1, 3), (1, 6), (2, 6), (4, 5)]), 2: set([(1, 2, 6)]), -1: set([()])}
</code></pre>
<p>So the face seems to have been added.</p>
<p>But then:</p>
<pre><code>sage: T.homology()
</code></pre>
<p>results in:</p>
<pre><code>{0: 0, 1: Z^10, 2: 0}
</code></pre>
<p>But this doesn't make any sense --- it should say <code>0:0, 1:Z^9, 2:0</code>, since adding a 2-face kills a class in $H_1(T)$.</p>
<p>Can anyone tell what I'm doing wrong?</p>
https://ask.sagemath.org/question/9943/homology-of-simplicial-complexes/?answer=14691#post-id-14691There's a bug in the `add_face` method. Various information about simplicial complexes is cached, especially when computing homology, and when you call `add_face`, it doesn't modify that cached information, so the homology computation is for the old complex, not the new one. See [here](http://trac.sagemath.org/sage_trac/ticket/14354) for a patch. Meanwhile, as a workaround, do
sage: T.add_face([1,2,6])
sage: T1 = SimplicialComplex(T.facets())
Then `T1` will have the correct facets but no cached data, so its homology will be correct.
Mon, 25 Mar 2013 01:54:54 +0100https://ask.sagemath.org/question/9943/homology-of-simplicial-complexes/?answer=14691#post-id-14691