Ask Your Question
0

Using `SimplicalComplex` on a set of sets

asked 2013-09-29 22:12:02 +0200

Alexandru Papiu gravatar image

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]])

See here for more info on finite simplical complexes in sage.

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 flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2013-09-30 11:33:37 +0200

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.

edit flag offensive delete link more

Comments

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.

Alexandru Papiu gravatar imageAlexandru Papiu ( 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.

John Palmieri gravatar imageJohn Palmieri ( 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).

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

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

John Palmieri gravatar imageJohn Palmieri ( 2013-10-02 14:53:21 +0200 )edit
1

answered 2013-09-30 07:44:36 +0200

tmonteil gravatar image

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)}
edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2013-09-29 22:12:02 +0200

Seen: 500 times

Last updated: Sep 30 '13