First time here? Check out the FAQ!

Ask Your Question
1

Obtaining integers from a linear extension of a poset.

asked 6 years ago

joakim_uhlin gravatar image

updated 5 years ago

FrédéricC gravatar image

I'm quite new to Sage so this might be a very easy question.

Suppose that I have defined a linear extension of a poset in Sage like this:

P = Poset(([1,2,3,4], [[1,3],[1,4],[2,3]]), linear_extension=True, facade=False)
p = P.linear_extension([1,4,2,3])

Is there a way for me to make this linear extension into a permutation? That is, I would like to obtain the permutation [1,4,2,3] from p.

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 6 years ago

rburing gravatar image

updated 6 years ago

This is not my field, but it seems you can do

sage: map(lambda x: x.element, p)
[1, 4, 2, 3]
sage: sigma = Permutation(map(lambda x: x.element, p))
sage: sigma
[1, 4, 2, 3]
sage: sigma(2)
4
Preview: (hide)
link

Comments

2

More pythonic:

sage: Permutation(x.element for x in p)
[1, 4, 2, 3]

Or just use facade=True

FrédéricC gravatar imageFrédéricC ( 6 years ago )

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 6 years ago

Seen: 346 times

Last updated: Mar 05 '19