# Using SimplicalComplex on a set of sets

Say I have something like this:

[{{1,2},{2,3}} , {{1,2},{3,4}}]


So I have a list of sets consisting of subsets of $1,2,...,n\space$ (in general the lists I am interested in are longer). I get these by using Subset(X,n). Now I want to look at the simplicial complex with facets {1,2},{2,3} and then the simplical complex with facets {1,3},{3,6} and so on.

Now the SimplicialComplex command only works for lists like so:

SimplicialComplex([[0,1], [1,2], [0,2]])


My question is: what is the best way to go from my set of sets to a list of lists?

More generally what is the best way to deal the fact that most enumerative combinatorics I can do in sage gives me sets but for SimplicialComplex I need lists?

edit retag close merge delete

Sort by » oldest newest most voted

I don't think I understand your question: in what way don't sets work when defining a simplicial complex? I tried the following in Sage 5.11, Sage 5.6, and in the most recent beta release, and it worked in all of them:

sage: S =  Set([Set([1,2]),Set([2,3])])
sage: SimplicialComplex(S)
Simplicial complex with vertex set (1, 2, 3) and facets {(1, 2), (2, 3)}

sage: S = [{1,2}, {2,3}]
sage: SimplicialComplex(S)
Simplicial complex with vertex set (1, 2, 3) and facets {(1, 2), (2, 3)}

sage: S = Subsets({1,2,3}, 2)
sage: SimplicialComplex(S)
Simplicial complex with vertex set (1, 2, 3) and facets {(1, 3), (1, 2), (2, 3)}


In the documentation that you cited, it says

maximal_faces should be a list or tuple or set (indeed, anything which may be converted to a set) whose elements are lists (or tuples, etc.) of vertices.

So sets should be allowed, and they seem to work.

more

Interesting. I am using the online sage notebook at http://www.sagenb.org/ and sets of sets do not work for me. I get the error TypeError: unhashable type: 'set' when I try the second option you describe above. And for the other two the simplical complexes I get are incorrect.

( 2013-10-02 01:50:58 +0200 )edit
<p>sagenb.org seems to be running Sage 5.4, which is rather old. That's the problem. I'll see if the version can be updated.

( 2013-10-02 11:53:39 +0200 )edit

@alexandru-papiu just in case: notice that there is a difference between Sage Set and python set (note the case).

( 2013-10-02 14:04:04 +0200 )edit

It looks like sagenb.org will get updated some time this week.

( 2013-10-02 14:53:21 +0200 )edit

I do not know whether it is the "best" way, but at least a short and readable way to transform a set of sets S into a list of lists L:

sage: S =  Set([Set([1,2]),Set([2,3])]) ; S
{{1, 2}, {2, 3}}

sage: L = [i.list() for i in S] ; L
[[1, 2], [2, 3]]

sage: C = SimplicialComplex(L) ; C
Simplicial complex with vertex set (1, 2, 3) and facets {(1, 2), (2, 3)}

more