Ask Your Question
1

Adding more cover relations in a poset

asked 2024-11-11 15:04:33 +0100

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 ${S_1,\ldots, S_n}$. Assume that the extra cover relation in $Q$ is $S_1$ is covered by $S_2$. 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?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
3

answered 2024-11-11 15:40:55 +0100

FrédéricC gravatar image

use frozenset or Set, not set

edit flag offensive delete link more

Comments

Thanks! frozenset worked.

Dharm gravatar imageDharm ( 2024-11-11 16:09:54 +0100 )edit

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: 2024-11-11 15:04:33 +0100

Seen: 69 times

Last updated: Nov 11