Processing math: 100%

First time here? Check out the FAQ!

Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Adding more cover relations in a poset

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?