Processing math: 100%

First time here? Check out the FAQ!

Ask Your Question
1

Adding more cover relations in a poset

asked 0 years ago

Dharm gravatar image

I have a poset P already defined in SageMath. I would like to define a new poset Q on the underlying set of P such that every cover relation of P is a cover relation in Q, i.e., I want to add more cover relations in P. I got to know that a poset in Sage is immutable (i.e. I can't modify one once it is built). Is it true?

The elements of P are sets S1,,Sn. Assume that the extra cover relation in Q is S1 is covered by S2. I am doing the following to define Q:

Rel={ };
for i in P:
      if i==S_1:
          Rel.update({i : P.upper_covers(i) +[S_2]})
      else:
          Rel.update({i : P.upper_covers(i)})
Q = Poset(Rel)

I am getting the following error: TypeError: unhashable type: 'set'

Whereas the following code works:

Rel={ };
for i in P:
     Rel.update({i : P.upper_covers(i)})
Q = Poset(Rel)

Could anyone please help me with this?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
3

answered 0 years ago

FrédéricC gravatar image

use frozenset or Set, not set

Preview: (hide)
link

Comments

Thanks! frozenset worked.

Dharm gravatar imageDharm ( 0 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: 0 years ago

Seen: 100 times

Last updated: Nov 11 '24